frmAliyunOssDetail.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. using AliyunOssLibrary.Model;
  2. using LYFZ.Network.OssOperation;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.ComponentModel;
  6. using System.Data;
  7. using System.Drawing;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Windows.Forms;
  11. namespace LYFZ.Software.MainBusiness.MultipleFileImport
  12. {
  13. public partial class frmAliyunOssDetail : LYFZ.ComponentLibrary.BaseContentsFormMain
  14. {
  15. public System.Windows.Forms.Timer timerUpdateDataGridView = new System.Windows.Forms.Timer();
  16. public frmAliyunOssDetail()
  17. {
  18. InitializeComponent();
  19. btnClickInit();
  20. // TableControl切换时;
  21. tabControlEx1.SelectedIndexChanged += TabControlEx1_SelectedIndexChanged;
  22. // 定时刷新DataGridView;
  23. timerUpdateDataGridView.Tick += TimerUpdateDataGridView_Tick;
  24. timerUpdateDataGridView.Interval = 15000;
  25. timerUpdateDataGridView.Enabled = true;
  26. }
  27. private void TimerUpdateDataGridView_Tick(object sender, EventArgs e)
  28. {
  29. switch (this.tabControlEx1.SelectedIndex)
  30. {
  31. case 0:
  32. FillupNeedUploadDataGridView();
  33. break;
  34. case 1:
  35. FillupNeedDownloadDataGridView();
  36. break;
  37. case 2:
  38. FillupHasUploadDataGridView();
  39. break;
  40. case 3:
  41. FillupHasDownloadDataGridView();
  42. break;
  43. default:
  44. break;
  45. }
  46. }
  47. private void TabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
  48. {
  49. switch (this.tabControlEx1.SelectedIndex)
  50. {
  51. case 0:
  52. FillupNeedUploadDataGridView();
  53. break;
  54. case 1:
  55. FillupNeedDownloadDataGridView();
  56. break;
  57. case 2:
  58. FillupHasUploadDataGridView();
  59. break;
  60. case 3:
  61. FillupHasDownloadDataGridView();
  62. break;
  63. default:
  64. break;
  65. }
  66. }
  67. void btnClickInit()
  68. {
  69. // 上传操作;
  70. this.btn_refresh_upload.Click += Btn_refresh_upload_Click;
  71. this.btn_priority_upload.Click += Btn_priority_upload_Click;
  72. this.btn_startupload.Click += Btn_startupload_Click;
  73. this.btn_stopupload.Click += Btn_stopupload_Click;
  74. this.btn_cancelupload.Click += Btn_cancelupload_Click;
  75. this.btn_allstartupload.Click += Btn_allstartupload_Click;
  76. this.btn_allstopupload.Click += Btn_allstopupload_Click;
  77. // 下载操作;
  78. this.btn_refresh_download.Click += Btn_refresh_download_Click;
  79. this.btn_priority_download.Click += Btn_priority_download_Click;
  80. this.btn_stopdownload.Click += Btn_stopdownload_Click;
  81. this.btn_startdownload.Click += Btn_startdownload_Click;
  82. this.btn_allstartdownload.Click += Btn_allstartdownload_Click;
  83. this.btn_allstopdownload.Click += Btn_allstopdownload_Click;
  84. }
  85. #region 下载按钮操作
  86. private void Btn_allstopdownload_Click(object sender, EventArgs e)
  87. {
  88. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  89. if (this.dgv_need_download.Rows.Count > 0)
  90. {
  91. foreach (DataGridViewRow dr in this.dgv_need_download.Rows)
  92. {
  93. orderDetail = (Upload_Order_Detail)dr.Tag;
  94. OssProcess.SetDownloadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.DownloadStatus.StopDownloading);
  95. }
  96. }
  97. }
  98. private void Btn_allstartdownload_Click(object sender, EventArgs e)
  99. {
  100. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  101. if (this.dgv_need_download.Rows.Count > 0 )
  102. {
  103. foreach (DataGridViewRow dr in this.dgv_need_download.Rows)
  104. {
  105. orderDetail = (Upload_Order_Detail)dr.Tag;
  106. OssProcess.SetDownloadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.DownloadStatus.Downloading);
  107. }
  108. }
  109. }
  110. private void Btn_startdownload_Click(object sender, EventArgs e)
  111. {
  112. if (this.dgv_need_download.SelectedRows.Count == 0)
  113. {
  114. MessageBox.Show("请选中要操作的行");
  115. return;
  116. }
  117. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  118. if (this.dgv_need_download.SelectedRows != null)
  119. {
  120. foreach (DataGridViewRow dr in this.dgv_need_download.SelectedRows)
  121. {
  122. orderDetail = (Upload_Order_Detail)dr.Tag;
  123. OssProcess.SetDownloadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.DownloadStatus.Downloading);
  124. break;
  125. }
  126. }
  127. }
  128. private void Btn_stopdownload_Click(object sender, EventArgs e)
  129. {
  130. if (this.dgv_need_download.SelectedRows.Count == 0)
  131. {
  132. MessageBox.Show("请选中要操作的行");
  133. return;
  134. }
  135. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  136. if (this.dgv_need_download.SelectedRows != null)
  137. {
  138. foreach (DataGridViewRow dr in this.dgv_need_download.SelectedRows)
  139. {
  140. orderDetail = (Upload_Order_Detail)dr.Tag;
  141. OssProcess.SetDownloadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.DownloadStatus.StopDownloading);
  142. break;
  143. }
  144. }
  145. }
  146. private void Btn_priority_download_Click(object sender, EventArgs e)
  147. {
  148. if (this.dgv_need_download.SelectedRows.Count == 0)
  149. {
  150. MessageBox.Show("请选中要操作的行");
  151. return;
  152. }
  153. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  154. if (this.dgv_need_download.SelectedRows != null)
  155. {
  156. foreach (DataGridViewRow dr in this.dgv_need_download.SelectedRows)
  157. {
  158. orderDetail = (Upload_Order_Detail)dr.Tag;
  159. OssProcess.SetPriority(orderDetail.upload_id, false);
  160. break;
  161. }
  162. }
  163. }
  164. private void Btn_refresh_download_Click(object sender, EventArgs e)
  165. {
  166. FillupNeedDownloadDataGridView();
  167. }
  168. #endregion
  169. #region 上传按钮操作
  170. private void Btn_allstopupload_Click(object sender, EventArgs e)
  171. {
  172. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  173. if (this.dgv_need_upload.Rows.Count > 0 )
  174. {
  175. foreach (DataGridViewRow dr in this.dgv_need_upload.Rows)
  176. {
  177. orderDetail = (Upload_Order_Detail)dr.Tag;
  178. OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.StopUploading);
  179. }
  180. }
  181. }
  182. private void Btn_allstartupload_Click(object sender, EventArgs e)
  183. {
  184. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  185. if (this.dgv_need_upload.Rows.Count > 0)
  186. {
  187. foreach (DataGridViewRow dr in this.dgv_need_upload.Rows)
  188. {
  189. orderDetail = (Upload_Order_Detail)dr.Tag;
  190. OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.Uploading);
  191. }
  192. }
  193. }
  194. private void Btn_cancelupload_Click(object sender, EventArgs e)
  195. {
  196. if (this.dgv_need_upload.SelectedRows.Count == 0)
  197. {
  198. MessageBox.Show("请选中要操作的行");
  199. return;
  200. }
  201. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  202. if (this.dgv_need_upload.SelectedRows != null)
  203. {
  204. foreach (DataGridViewRow dr in this.dgv_need_upload.SelectedRows)
  205. {
  206. orderDetail = (Upload_Order_Detail)dr.Tag;
  207. OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.CancelUpload);
  208. break;
  209. }
  210. }
  211. }
  212. private void Btn_stopupload_Click(object sender, EventArgs e)
  213. {
  214. if (this.dgv_need_upload.SelectedRows.Count == 0)
  215. {
  216. MessageBox.Show("请选中要操作的行");
  217. return;
  218. }
  219. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  220. if (this.dgv_need_upload.SelectedRows != null)
  221. {
  222. foreach (DataGridViewRow dr in this.dgv_need_upload.SelectedRows)
  223. {
  224. orderDetail = (Upload_Order_Detail)dr.Tag;
  225. OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.StopUploading);
  226. break;
  227. }
  228. }
  229. }
  230. private void Btn_startupload_Click(object sender, EventArgs e)
  231. {
  232. if (this.dgv_need_upload.SelectedRows.Count == 0)
  233. {
  234. MessageBox.Show("请选中要操作的行");
  235. return;
  236. }
  237. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  238. if (this.dgv_need_upload.SelectedRows != null)
  239. {
  240. foreach (DataGridViewRow dr in this.dgv_need_upload.SelectedRows)
  241. {
  242. orderDetail = (Upload_Order_Detail)dr.Tag;
  243. OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.Uploading);
  244. break;
  245. }
  246. }
  247. }
  248. private void Btn_priority_upload_Click(object sender, EventArgs e)
  249. {
  250. if (this.dgv_need_upload.SelectedRows.Count == 0)
  251. {
  252. MessageBox.Show("请选中要操作的行");
  253. return;
  254. }
  255. Upload_Order_Detail orderDetail = new Upload_Order_Detail();
  256. if (this.dgv_need_upload.SelectedRows != null)
  257. {
  258. foreach (DataGridViewRow dr in this.dgv_need_upload.SelectedRows)
  259. {
  260. orderDetail = (Upload_Order_Detail)dr.Tag;
  261. OssProcess.SetPriority(orderDetail.upload_id, true);
  262. break;
  263. }
  264. }
  265. }
  266. private void Btn_refresh_upload_Click(object sender, EventArgs e)
  267. {
  268. FillupNeedUploadDataGridView();
  269. }
  270. #endregion
  271. private void frmAliyunOssDetail_Load(object sender, EventArgs e)
  272. {
  273. }
  274. #region 填充数据列表
  275. private void FillupNeedUploadDataGridView()
  276. {
  277. if (this.tabControlEx1.SelectedIndex != 0)
  278. return;
  279. List<AliyunOssLibrary.Model.SafeUploadOrderDetail> listResult;
  280. AliyunOssLibrary.Enumerate.OrderListType type = AliyunOssLibrary.Enumerate.OrderListType.NeedUpload;
  281. if (LYFZ.Network.OssOperation.OssProcess.GetUploadOrDownload(out listResult, type))
  282. {
  283. dgv_need_upload.Rows.Clear();
  284. this.tx_need_upload_count.Text = string.Format("数量:{0}", listResult.Count);
  285. foreach (AliyunOssLibrary.Model.SafeUploadOrderDetail so in listResult)
  286. {
  287. DataGridViewRow dgvRow = new DataGridViewRow();
  288. dgvRow.CreateCells(this.dgv_need_upload);
  289. dgvRow.Tag = so;
  290. dgvRow.Cells[0].Value = so.upload_id;
  291. dgvRow.Cells[1].Value = so.download_branch_name;
  292. if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype)
  293. {
  294. dgvRow.Cells[2].Value = "原片";
  295. }
  296. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype)
  297. {
  298. dgvRow.Cells[2].Value = "初修";
  299. }
  300. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype)
  301. {
  302. dgvRow.Cells[2].Value = "精修";
  303. }
  304. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype)
  305. {
  306. dgvRow.Cells[2].Value = "设计";
  307. }
  308. dgvRow.Cells[3].Value = so.upload_order;
  309. dgvRow.Cells[4].Value = so.upload_images;
  310. if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.NotUploaded)
  311. {
  312. dgvRow.Cells[5].Value = "未上传";
  313. }
  314. else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.Uploading)
  315. {
  316. dgvRow.Cells[5].Value = "上传中";
  317. }
  318. else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.StopUploading)
  319. {
  320. dgvRow.Cells[5].Value = "停止上传";
  321. }
  322. else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.Uploaded)
  323. {
  324. dgvRow.Cells[5].Value = "已上传";
  325. }
  326. dgvRow.Cells[6].Value = so.upload_datetime;
  327. dgvRow.Cells[7].Value = string.Format("{0}/{1}", so.UploadCount, so.upload_images.Split('|').Count());
  328. this.dgv_need_upload.Rows.Add(dgvRow);
  329. }
  330. }
  331. }
  332. private void FillupNeedDownloadDataGridView()
  333. {
  334. if (this.tabControlEx1.SelectedIndex != 1)
  335. return;
  336. List<AliyunOssLibrary.Model.SafeUploadOrderDetail> listResult;
  337. AliyunOssLibrary.Enumerate.OrderListType type = AliyunOssLibrary.Enumerate.OrderListType.NeedDownload;
  338. if (LYFZ.Network.OssOperation.OssProcess.GetUploadOrDownload(out listResult, type))
  339. {
  340. this.dgv_need_download.Rows.Clear();
  341. this.tx_need_download_count.Text = string.Format("数量:{0}", listResult.Count);
  342. foreach (AliyunOssLibrary.Model.SafeUploadOrderDetail so in listResult)
  343. {
  344. DataGridViewRow dgvRow = new DataGridViewRow();
  345. dgvRow.CreateCells(this.dgv_need_download);
  346. dgvRow.Tag = so;
  347. dgvRow.Cells[0].Value = so.upload_id;
  348. dgvRow.Cells[1].Value = so.upload_branch_name;
  349. if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype)
  350. {
  351. dgvRow.Cells[2].Value = "原片";
  352. }
  353. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype)
  354. {
  355. dgvRow.Cells[2].Value = "初修";
  356. }
  357. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype)
  358. {
  359. dgvRow.Cells[2].Value = "精修";
  360. }
  361. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype)
  362. {
  363. dgvRow.Cells[2].Value = "设计";
  364. }
  365. dgvRow.Cells[3].Value = so.upload_order;
  366. dgvRow.Cells[4].Value = so.upload_images;
  367. if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.NotDownloaded)
  368. {
  369. dgvRow.Cells[5].Value = "未下载";
  370. }
  371. else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.Downloading)
  372. {
  373. dgvRow.Cells[5].Value = "下载中";
  374. }
  375. else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.StopDownloading)
  376. {
  377. dgvRow.Cells[5].Value = "停止下载";
  378. }
  379. else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.Downloaded)
  380. {
  381. dgvRow.Cells[5].Value = "已下载";
  382. }
  383. dgvRow.Cells[6].Value = so.upload_datetime;
  384. dgvRow.Cells[7].Value = string.Format("{0}/{1}", so.DownloadCount, so.upload_images.Split('|').Count());
  385. this.dgv_need_download.Rows.Add(dgvRow);
  386. }
  387. }
  388. }
  389. private void FillupHasUploadDataGridView()
  390. {
  391. if (this.tabControlEx1.SelectedIndex != 2)
  392. return;
  393. List<AliyunOssLibrary.Model.SafeUploadOrderDetail> listResult;
  394. AliyunOssLibrary.Enumerate.OrderListType type = AliyunOssLibrary.Enumerate.OrderListType.HasUpload;
  395. if (LYFZ.Network.OssOperation.OssProcess.GetUploadOrDownload(out listResult, type))
  396. {
  397. this.dgv_has_upload.Rows.Clear();
  398. this.tx_has_upload_count.Text = string.Format("数量:{0}", listResult.Count);
  399. foreach (AliyunOssLibrary.Model.SafeUploadOrderDetail so in listResult)
  400. {
  401. DataGridViewRow dgvRow = new DataGridViewRow();
  402. dgvRow.CreateCells(this.dgv_has_upload);
  403. dgvRow.Tag = so;
  404. dgvRow.Cells[0].Value = so.upload_id;
  405. dgvRow.Cells[1].Value = so.download_branch_name;
  406. if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype)
  407. {
  408. dgvRow.Cells[2].Value = "原片";
  409. }
  410. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype)
  411. {
  412. dgvRow.Cells[2].Value = "初修";
  413. }
  414. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype)
  415. {
  416. dgvRow.Cells[2].Value = "精修";
  417. }
  418. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype)
  419. {
  420. dgvRow.Cells[2].Value = "设计";
  421. }
  422. dgvRow.Cells[3].Value = so.upload_order;
  423. if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.NotUploaded)
  424. {
  425. dgvRow.Cells[4].Value = "未上传";
  426. }
  427. else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.Uploading)
  428. {
  429. dgvRow.Cells[4].Value = "上传中";
  430. }
  431. else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.StopUploading)
  432. {
  433. dgvRow.Cells[4].Value = "停止上传";
  434. }
  435. else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.Uploaded)
  436. {
  437. dgvRow.Cells[4].Value = "已上传";
  438. }
  439. dgvRow.Cells[5].Value = so.upload_datetime;
  440. this.dgv_has_upload.Rows.Add(dgvRow);
  441. }
  442. }
  443. }
  444. private void FillupHasDownloadDataGridView()
  445. {
  446. if (this.tabControlEx1.SelectedIndex != 3)
  447. return;
  448. List<AliyunOssLibrary.Model.SafeUploadOrderDetail> listResult;
  449. AliyunOssLibrary.Enumerate.OrderListType type = AliyunOssLibrary.Enumerate.OrderListType.HasDownload;
  450. if (LYFZ.Network.OssOperation.OssProcess.GetUploadOrDownload(out listResult, type))
  451. {
  452. this.dgv_has_download.Rows.Clear();
  453. this.tx_has_download_count.Text = string.Format("数量:{0}", listResult.Count);
  454. foreach (AliyunOssLibrary.Model.SafeUploadOrderDetail so in listResult)
  455. {
  456. DataGridViewRow dgvRow = new DataGridViewRow();
  457. dgvRow.CreateCells(this.dgv_has_download);
  458. dgvRow.Tag = so;
  459. dgvRow.Cells[0].Value = so.upload_id;
  460. dgvRow.Cells[1].Value = so.upload_branch_name;
  461. if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype)
  462. {
  463. dgvRow.Cells[2].Value = "原片";
  464. }
  465. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype)
  466. {
  467. dgvRow.Cells[2].Value = "初修";
  468. }
  469. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype)
  470. {
  471. dgvRow.Cells[2].Value = "精修";
  472. }
  473. else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype)
  474. {
  475. dgvRow.Cells[2].Value = "设计";
  476. }
  477. dgvRow.Cells[3].Value = so.upload_order;
  478. if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.NotDownloaded)
  479. {
  480. dgvRow.Cells[4].Value = "未下载";
  481. }
  482. else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.Downloading)
  483. {
  484. dgvRow.Cells[4].Value = "下载中";
  485. }
  486. else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.StopDownloading)
  487. {
  488. dgvRow.Cells[4].Value = "停止下载";
  489. }
  490. else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.Downloaded)
  491. {
  492. dgvRow.Cells[4].Value = "已下载";
  493. }
  494. dgvRow.Cells[5].Value = so.upload_datetime;
  495. this.dgv_has_download.Rows.Add(dgvRow);
  496. }
  497. }
  498. }
  499. #endregion
  500. }
  501. }