星火微课系统客户端
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

UploadWindow.xaml.cs 8.4KB

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