|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287 |
- using Common.system;
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- using System.Windows.Data;
- using System.Windows.Documents;
- using System.Windows.Input;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using System.Windows.Shapes;
- using XHWK.Model;
- using XHWK.WKTool.DAL;
-
- namespace XHWK.WKTool
- {
- /// <summary>
- /// UploadWindow.xaml 的交互逻辑
- /// </summary>
- public partial class UploadWindow : Window
- {
- /// <summary>
- /// 调用接口
- /// </summary>
- private readonly Interface @interface = new Interface();
- /// <summary>
- /// 前台数据
- /// </summary>
- internal LoginPageData pageData = new LoginPageData();
- /// <summary>
- /// 文件名
- /// </summary>
- private string Resourcename = string.Empty;
- /// <summary>
- /// 文件大小
- /// </summary>
- private long Resourcesize = 0;
- /// <summary>
- /// 文件类型
- /// </summary>
- private string Suffix = string.Empty;
- /// <summary>
- /// 唯一编号
- /// </summary>
- private string Guid = string.Empty;
- public UploadWindow()
- {
- InitializeComponent();
- }
- /// <summary>
- /// 初始化
- /// </summary>
- public void Initialize(string _resourcename,long _resourcesize,string _suffix,string _guid)
- {
- Resourcename = _resourcename;
- Resourcesize = _resourcesize;
- Suffix = _suffix;
- Guid = _guid;
- Tsubjectbook();
- }
- /// <summary>
- /// 教材接口调用
- /// </summary>
- /// <returns></returns>
- private void Tsubjectbook()
- {
- int code = @interface.TsubjectbookList();
- if (code == 0)
- {
- for (int i = 0; i < APP.TsubjectbookList.Count; i++)
- {
- pageData.bookList.Add(new ComboBoxBean()
- {
- Key = APP.TsubjectbookList[i].Lsbid,
- Value = $"{APP.TsubjectbookList[i].Subjectname} {APP.TsubjectbookList[i].Bookname}"
- });
- }
- book_list.SelectedIndex = 0;
- DataContext = pageData;
- Director();
- }
- else
- {
- MessageWindow.Show(APP.ServerMsg);
- }
- }
- /// <summary>
- /// 章节接口调用
- /// </summary>
- private void Director()
- {
- int selectIndex = book_list.SelectedIndex;
- if(selectIndex<0)
- {
- selectIndex = 0;
- }
- int code = @interface.DirectorList(APP.TsubjectbookList[selectIndex].Lsbid,2,APP.UserInfo.Userid);
- if (code == 0)
- {
- pageData.zhangjieList.Clear();
- //pageData.zhangjieList.Add(new ComboBoxBean()
- //{
- // Key = 999999,
- // Value = "全部"
- //});
- for (int i = 0; i < APP.DirectorList.Count; i++)
- {
- Model_DirectorList item = APP.DirectorList[i];
- pageData.zhangjieList.Add(new ComboBoxBean()
- {
- Key = item.directorid,
- Value = item.directorname
- });
- addChild(item);
- }
- cmbTeachingMaterial.SelectedIndex = 0;
- }
- else
- {
- MessageWindow.Show(APP.ServerMsg);
- }
- }
- /// <summary>
- /// 子章节递归
- /// </summary>
- /// <param name="directorList"></param>
- private void addChild(Model_DirectorList directorList)
- {
- if (directorList.children != null && directorList.children.Count > 0)
- {
- foreach (Model_DirectorList child in directorList.children)
- {
- pageData.zhangjieList.Add(new ComboBoxBean()
- {
- Key = child.directorid,
- Value = getSpace(child.directorlevel) + child.directorname
- });
- if (child.children != null && child.children.Count > 0)
- {
- addChild(child);
- }
- }
- }
- }
- /// <summary>
- /// 章节是否加空格符
- /// </summary>
- /// <param name="num"></param>
- /// <returns></returns>
- private string getSpace(int num)
- {
- string str = "";
- for (int i = 0; i < num; i++)
- {
- str += " ";
- }
- return str;
- }
- private void Window_Loaded(object sender, RoutedEventArgs e)
- {
-
- }
-
- private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
- {
-
- }
- /// <summary>
- /// 教材下拉框改变事件
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void toolbar_list_SelectionChanged(object sender, SelectionChangedEventArgs e)
- {
- Director();
- }
-
- private void BtnDown_Click(object sender, RoutedEventArgs e)
- {
- this.Hide();
- }
- /// <summary>
- /// 上传到个人空间
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void BtnStart_Click(object sender, RoutedEventArgs e)
- {
-
- try
- {
- DAL_Upload dAL_Upload = new DAL_Upload();
- if (dAL_Upload.UploadVideoTwo(Guid, out string ErrMessage))
- {
-
-
- // converted: 0
- //createid: 80
- //directorid: 1009
- //duration: 39
- //imgUrl: ""
- //level: 2
- //lsbid: 40
- //mp4code: "h264"
- //resourcebelong: 3
- //resourceclass: 2
- //resourcecover: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.jpg"
- //resourcename: "weather_pic"
- //resourcesize: 6105268
- //resourcetype: 0
- //resourceurl: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.mp4"
- //schoolid: 12
- //suffix: "mp4"
- //uid: 80
- Model_ResourceAdd model_ResourceAdd = new Model_ResourceAdd();
- model_ResourceAdd.converted = 0;
- model_ResourceAdd.createid = APP.UserInfo.Userid;
- model_ResourceAdd.directorid = Convert.ToInt32(cmbTeachingMaterial.SelectedValue.ToString());
- model_ResourceAdd.duration = APP.ResourceAddTwo.duration;
- model_ResourceAdd.imgUrl = "";
- model_ResourceAdd.level = 2;
- model_ResourceAdd.lsbid = Convert.ToInt32(book_list.SelectedValue.ToString());
- model_ResourceAdd.mp4code = APP.ResourceAddTwo.mp4code;
- model_ResourceAdd.resourcebelong = 3;
- model_ResourceAdd.resourceclass = 2;
- model_ResourceAdd.resourcecover = APP.ResourceAddTwo.coverpath;
- model_ResourceAdd.resourcename = Resourcename;
- model_ResourceAdd.resourcesize = Resourcesize;//zxy 文件大小
- model_ResourceAdd.resourcetype = 0;
- model_ResourceAdd.resourceurl = APP.ResourceAddTwo.videopath;
- model_ResourceAdd.schoolid = APP.UserInfo.Schoolid;
- if (Suffix.Equals("FLV"))
- {
- Suffix = "flv";
- }
- else if (Suffix.Equals("AVI"))
- {
- Suffix = "avi";
- }
- else
- {
- Suffix = "mp4";
- }
-
- model_ResourceAdd.suffix = Suffix;
- //model_ResourceAdd.uid = 0;//zxy
- int code = @interface.ResourceAdd(model_ResourceAdd);
- if (code == 0)
- {
- MessageWindow.Show("视频上传成功!");
- Hide();
- }
- else
- {
- MessageWindow.Show(APP.ServerMsg);
- }
- }
- else
- {
- MessageWindow.Show(ErrMessage);
- }
- }
- catch (Exception ex)
- {
- MessageWindow.Show("视频上传失败!");
- Hide();
- LogHelper.WriteErrLog("【UploadWindow】(BtnStart_Click)" + ex.Message, ex);
- }
- }
- }
- public class LoginPageData : NotifyModel
- {
- public ObservableCollection<ComboBoxBean> bookList { get; set; }
-
- public ObservableCollection<ComboBoxBean> zhangjieList { get; set; }
-
- public LoginPageData()
- {
- bookList = new ObservableCollection<ComboBoxBean>();
- zhangjieList = new ObservableCollection<ComboBoxBean>();
- }
- }
- }
|