星火微课系统客户端
Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

UploadWindow.xaml.cs 9.6KB

vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
vor 4 Jahren
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. using Common.system;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Collections.ObjectModel;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using System.Windows;
  9. using System.Windows.Controls;
  10. using System.Windows.Data;
  11. using System.Windows.Documents;
  12. using System.Windows.Input;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using System.Windows.Shapes;
  16. using XHWK.Model;
  17. using XHWK.WKTool.DAL;
  18. namespace XHWK.WKTool
  19. {
  20. /// <summary>
  21. /// UploadWindow.xaml 的交互逻辑
  22. /// </summary>
  23. public partial class UploadWindow : Window
  24. {
  25. /// <summary>
  26. /// 调用接口
  27. /// </summary>
  28. private readonly Interface @interface = new Interface();
  29. /// <summary>
  30. /// 前台数据
  31. /// </summary>
  32. internal LoginPageData pageData = new LoginPageData();
  33. /// <summary>
  34. /// 文件名
  35. /// </summary>
  36. private string Resourcename = string.Empty;
  37. /// <summary>
  38. /// 文件大小
  39. /// </summary>
  40. private long Resourcesize = 0;
  41. /// <summary>
  42. /// 文件类型
  43. /// </summary>
  44. private string Suffix = string.Empty;
  45. /// <summary>
  46. /// 唯一编号
  47. /// </summary>
  48. private string Guid = string.Empty;
  49. public UploadWindow()
  50. {
  51. InitializeComponent();
  52. }
  53. /// <summary>
  54. /// 初始化
  55. /// </summary>
  56. public void Initialize(string _resourcename,long _resourcesize,string _suffix,string _guid)
  57. {
  58. Resourcename = _resourcename;
  59. Resourcesize = _resourcesize;
  60. Suffix = _suffix;
  61. Guid = _guid;
  62. Tsubjectbook();
  63. }
  64. /// <summary>
  65. /// 教材接口调用
  66. /// </summary>
  67. /// <returns></returns>
  68. private void Tsubjectbook()
  69. {
  70. int code = @interface.TsubjectbookList();
  71. if (code == 0)
  72. {
  73. for (int i = 0; i < APP.TsubjectbookList.Count; i++)
  74. {
  75. pageData.bookList.Add(new ComboBoxBean()
  76. {
  77. Key = APP.TsubjectbookList[i].Lsbid,
  78. Value = $"{APP.TsubjectbookList[i].Subjectname} {APP.TsubjectbookList[i].Bookname}"
  79. });
  80. }
  81. book_list.SelectedIndex = 0;
  82. DataContext = pageData;
  83. Director();
  84. }
  85. else
  86. {
  87. MessageWindow.Show(APP.ServerMsg);
  88. }
  89. }
  90. /// <summary>
  91. /// 章节接口调用
  92. /// </summary>
  93. private void Director()
  94. {
  95. int selectIndex = book_list.SelectedIndex;
  96. if(selectIndex<0)
  97. {
  98. selectIndex = 0;
  99. }
  100. int code = @interface.DirectorList(APP.TsubjectbookList[selectIndex].Lsbid,2,APP.UserInfo.Userid);
  101. if (code == 0)
  102. {
  103. pageData.zhangjieList.Clear();
  104. //pageData.zhangjieList.Add(new ComboBoxBean()
  105. //{
  106. // Key = 999999,
  107. // Value = "全部"
  108. //});
  109. for (int i = 0; i < APP.DirectorList.Count; i++)
  110. {
  111. Model_DirectorList item = APP.DirectorList[i];
  112. pageData.zhangjieList.Add(new ComboBoxBean()
  113. {
  114. Key = item.directorid,
  115. Value = item.directorname
  116. });
  117. addChild(item);
  118. }
  119. cmbTeachingMaterial.SelectedIndex = 0;
  120. }
  121. else
  122. {
  123. MessageWindow.Show(APP.ServerMsg);
  124. }
  125. }
  126. /// <summary>
  127. /// 子章节递归
  128. /// </summary>
  129. /// <param name="directorList"></param>
  130. private void addChild(Model_DirectorList directorList)
  131. {
  132. if (directorList.children != null && directorList.children.Count > 0)
  133. {
  134. foreach (Model_DirectorList child in directorList.children)
  135. {
  136. pageData.zhangjieList.Add(new ComboBoxBean()
  137. {
  138. Key = child.directorid,
  139. Value = getSpace(child.directorlevel) + child.directorname
  140. });
  141. if (child.children != null && child.children.Count > 0)
  142. {
  143. addChild(child);
  144. }
  145. }
  146. }
  147. }
  148. /// <summary>
  149. /// 章节是否加空格符
  150. /// </summary>
  151. /// <param name="num"></param>
  152. /// <returns></returns>
  153. private string getSpace(int num)
  154. {
  155. string str = "";
  156. for (int i = 0; i < num; i++)
  157. {
  158. str += " ";
  159. }
  160. return str;
  161. }
  162. private void Window_Loaded(object sender, RoutedEventArgs e)
  163. {
  164. }
  165. private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
  166. {
  167. }
  168. /// <summary>
  169. /// 教材下拉框改变事件
  170. /// </summary>
  171. /// <param name="sender"></param>
  172. /// <param name="e"></param>
  173. private void toolbar_list_SelectionChanged(object sender, SelectionChangedEventArgs e)
  174. {
  175. Director();
  176. }
  177. private void BtnDown_Click(object sender, RoutedEventArgs e)
  178. {
  179. this.Hide();
  180. }
  181. /// <summary>
  182. /// 上传到个人空间
  183. /// </summary>
  184. /// <param name="sender"></param>
  185. /// <param name="e"></param>
  186. private void BtnStart_Click(object sender, RoutedEventArgs e)
  187. {
  188. try
  189. {
  190. DAL_Upload dAL_Upload = new DAL_Upload();
  191. if (dAL_Upload.UploadVideoTwo(Guid, out string ErrMessage))
  192. {
  193. // converted: 0
  194. //createid: 80
  195. //directorid: 1009
  196. //duration: 39
  197. //imgUrl: ""
  198. //level: 2
  199. //lsbid: 40
  200. //mp4code: "h264"
  201. //resourcebelong: 3
  202. //resourceclass: 2
  203. //resourcecover: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.jpg"
  204. //resourcename: "weather_pic"
  205. //resourcesize: 6105268
  206. //resourcetype: 0
  207. //resourceurl: "12/resource/20200917/4f297df0-f8c0-11ea-adf5-81f24b97d4ff/weather_pic.mp4"
  208. //schoolid: 12
  209. //suffix: "mp4"
  210. //uid: 80
  211. Model_ResourceAdd model_ResourceAdd = new Model_ResourceAdd();
  212. model_ResourceAdd.converted = 0;
  213. model_ResourceAdd.createid = APP.UserInfo.Userid;
  214. model_ResourceAdd.directorid = Convert.ToInt32(cmbTeachingMaterial.SelectedValue.ToString());
  215. model_ResourceAdd.duration = APP.ResourceAddTwo.duration;
  216. model_ResourceAdd.imgUrl = "";
  217. model_ResourceAdd.level = 2;
  218. model_ResourceAdd.lsbid = Convert.ToInt32(book_list.SelectedValue.ToString());
  219. model_ResourceAdd.mp4code = APP.ResourceAddTwo.mp4code;
  220. model_ResourceAdd.resourcebelong = 3;
  221. model_ResourceAdd.resourceclass = 2;
  222. model_ResourceAdd.resourcecover = APP.ResourceAddTwo.coverpath;
  223. model_ResourceAdd.resourcename = Resourcename;
  224. model_ResourceAdd.resourcesize = Resourcesize;//zxy 文件大小
  225. model_ResourceAdd.resourcetype = 0;
  226. model_ResourceAdd.resourceurl = APP.ResourceAddTwo.videopath;
  227. model_ResourceAdd.schoolid = APP.UserInfo.Schoolid;
  228. if (Suffix.Equals("FLV"))
  229. {
  230. Suffix = "flv";
  231. }
  232. else if (Suffix.Equals("AVI"))
  233. {
  234. Suffix = "avi";
  235. }
  236. else
  237. {
  238. Suffix = "mp4";
  239. }
  240. model_ResourceAdd.suffix = Suffix;
  241. //model_ResourceAdd.uid = 0;//zxy
  242. int code = @interface.ResourceAdd(model_ResourceAdd);
  243. if (code == 0)
  244. {
  245. MessageWindow.Show("视频上传成功!");
  246. Hide();
  247. }
  248. else
  249. {
  250. MessageWindow.Show(APP.ServerMsg);
  251. }
  252. }
  253. else
  254. {
  255. MessageWindow.Show(ErrMessage);
  256. }
  257. }
  258. catch (Exception ex)
  259. {
  260. MessageWindow.Show("视频上传失败!");
  261. Hide();
  262. LogHelper.WriteErrLog("【UploadWindow】(BtnStart_Click)" + ex.Message, ex);
  263. }
  264. }
  265. }
  266. public class LoginPageData : NotifyModel
  267. {
  268. public ObservableCollection<ComboBoxBean> bookList { get; set; }
  269. public ObservableCollection<ComboBoxBean> zhangjieList { get; set; }
  270. public LoginPageData()
  271. {
  272. bookList = new ObservableCollection<ComboBoxBean>();
  273. zhangjieList = new ObservableCollection<ComboBoxBean>();
  274. }
  275. }
  276. }