123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563 |
- using AliyunOssLibrary.Model;
- using LYFZ.Network.OssOperation;
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- namespace LYFZ.Software.MainBusiness.MultipleFileImport
- {
- public partial class frmAliyunOssDetail : LYFZ.ComponentLibrary.BaseContentsFormMain
- {
- public System.Windows.Forms.Timer timerUpdateDataGridView = new System.Windows.Forms.Timer();
- public frmAliyunOssDetail()
- {
- InitializeComponent();
- btnClickInit();
- // TableControl切换时;
- tabControlEx1.SelectedIndexChanged += TabControlEx1_SelectedIndexChanged;
- // 定时刷新DataGridView;
- timerUpdateDataGridView.Tick += TimerUpdateDataGridView_Tick;
- timerUpdateDataGridView.Interval = 15000;
- timerUpdateDataGridView.Enabled = true;
- }
- private void TimerUpdateDataGridView_Tick(object sender, EventArgs e)
- {
- switch (this.tabControlEx1.SelectedIndex)
- {
- case 0:
- FillupNeedUploadDataGridView();
- break;
- case 1:
- FillupNeedDownloadDataGridView();
- break;
- case 2:
- FillupHasUploadDataGridView();
- break;
- case 3:
- FillupHasDownloadDataGridView();
- break;
- default:
- break;
- }
- }
- private void TabControlEx1_SelectedIndexChanged(object sender, EventArgs e)
- {
- switch (this.tabControlEx1.SelectedIndex)
- {
- case 0:
- FillupNeedUploadDataGridView();
- break;
- case 1:
- FillupNeedDownloadDataGridView();
- break;
- case 2:
- FillupHasUploadDataGridView();
- break;
- case 3:
- FillupHasDownloadDataGridView();
- break;
- default:
- break;
- }
- }
- void btnClickInit()
- {
- // 上传操作;
- this.btn_refresh_upload.Click += Btn_refresh_upload_Click;
- this.btn_priority_upload.Click += Btn_priority_upload_Click;
- this.btn_startupload.Click += Btn_startupload_Click;
- this.btn_stopupload.Click += Btn_stopupload_Click;
- this.btn_cancelupload.Click += Btn_cancelupload_Click;
- this.btn_allstartupload.Click += Btn_allstartupload_Click;
- this.btn_allstopupload.Click += Btn_allstopupload_Click;
- // 下载操作;
- this.btn_refresh_download.Click += Btn_refresh_download_Click;
- this.btn_priority_download.Click += Btn_priority_download_Click;
- this.btn_stopdownload.Click += Btn_stopdownload_Click;
- this.btn_startdownload.Click += Btn_startdownload_Click;
- this.btn_allstartdownload.Click += Btn_allstartdownload_Click;
- this.btn_allstopdownload.Click += Btn_allstopdownload_Click;
- }
- #region 下载按钮操作
- private void Btn_allstopdownload_Click(object sender, EventArgs e)
- {
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_download.Rows.Count > 0)
- {
- foreach (DataGridViewRow dr in this.dgv_need_download.Rows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetDownloadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.DownloadStatus.StopDownloading);
- }
- }
- }
- private void Btn_allstartdownload_Click(object sender, EventArgs e)
- {
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_download.Rows.Count > 0 )
- {
- foreach (DataGridViewRow dr in this.dgv_need_download.Rows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetDownloadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.DownloadStatus.Downloading);
- }
- }
- }
- private void Btn_startdownload_Click(object sender, EventArgs e)
- {
- if (this.dgv_need_download.SelectedRows.Count == 0)
- {
- MessageBox.Show("请选中要操作的行");
- return;
- }
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_download.SelectedRows != null)
- {
- foreach (DataGridViewRow dr in this.dgv_need_download.SelectedRows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetDownloadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.DownloadStatus.Downloading);
- break;
- }
- }
- }
- private void Btn_stopdownload_Click(object sender, EventArgs e)
- {
- if (this.dgv_need_download.SelectedRows.Count == 0)
- {
- MessageBox.Show("请选中要操作的行");
- return;
- }
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_download.SelectedRows != null)
- {
- foreach (DataGridViewRow dr in this.dgv_need_download.SelectedRows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetDownloadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.DownloadStatus.StopDownloading);
- break;
- }
- }
- }
- private void Btn_priority_download_Click(object sender, EventArgs e)
- {
- if (this.dgv_need_download.SelectedRows.Count == 0)
- {
- MessageBox.Show("请选中要操作的行");
- return;
- }
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_download.SelectedRows != null)
- {
- foreach (DataGridViewRow dr in this.dgv_need_download.SelectedRows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetPriority(orderDetail.upload_id, false);
- break;
- }
- }
- }
- private void Btn_refresh_download_Click(object sender, EventArgs e)
- {
- FillupNeedDownloadDataGridView();
- }
- #endregion
- #region 上传按钮操作
- private void Btn_allstopupload_Click(object sender, EventArgs e)
- {
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_upload.Rows.Count > 0 )
- {
- foreach (DataGridViewRow dr in this.dgv_need_upload.Rows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.StopUploading);
- }
- }
- }
- private void Btn_allstartupload_Click(object sender, EventArgs e)
- {
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_upload.Rows.Count > 0)
- {
- foreach (DataGridViewRow dr in this.dgv_need_upload.Rows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.Uploading);
- }
- }
- }
- private void Btn_cancelupload_Click(object sender, EventArgs e)
- {
- if (this.dgv_need_upload.SelectedRows.Count == 0)
- {
- MessageBox.Show("请选中要操作的行");
- return;
- }
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_upload.SelectedRows != null)
- {
- foreach (DataGridViewRow dr in this.dgv_need_upload.SelectedRows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.CancelUpload);
- break;
- }
- }
- }
- private void Btn_stopupload_Click(object sender, EventArgs e)
- {
- if (this.dgv_need_upload.SelectedRows.Count == 0)
- {
- MessageBox.Show("请选中要操作的行");
- return;
- }
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_upload.SelectedRows != null)
- {
- foreach (DataGridViewRow dr in this.dgv_need_upload.SelectedRows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.StopUploading);
- break;
- }
- }
- }
- private void Btn_startupload_Click(object sender, EventArgs e)
- {
- if (this.dgv_need_upload.SelectedRows.Count == 0)
- {
- MessageBox.Show("请选中要操作的行");
- return;
- }
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_upload.SelectedRows != null)
- {
- foreach (DataGridViewRow dr in this.dgv_need_upload.SelectedRows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetUploadOpt(orderDetail.upload_id, AliyunOssLibrary.Enumerate.UploadStatus.Uploading);
- break;
- }
- }
- }
- private void Btn_priority_upload_Click(object sender, EventArgs e)
- {
- if (this.dgv_need_upload.SelectedRows.Count == 0)
- {
- MessageBox.Show("请选中要操作的行");
- return;
- }
- Upload_Order_Detail orderDetail = new Upload_Order_Detail();
- if (this.dgv_need_upload.SelectedRows != null)
- {
- foreach (DataGridViewRow dr in this.dgv_need_upload.SelectedRows)
- {
- orderDetail = (Upload_Order_Detail)dr.Tag;
- OssProcess.SetPriority(orderDetail.upload_id, true);
- break;
- }
- }
- }
- private void Btn_refresh_upload_Click(object sender, EventArgs e)
- {
- FillupNeedUploadDataGridView();
- }
- #endregion
- private void frmAliyunOssDetail_Load(object sender, EventArgs e)
- {
- }
- #region 填充数据列表
- private void FillupNeedUploadDataGridView()
- {
- if (this.tabControlEx1.SelectedIndex != 0)
- return;
- List<AliyunOssLibrary.Model.SafeUploadOrderDetail> listResult;
- AliyunOssLibrary.Enumerate.OrderListType type = AliyunOssLibrary.Enumerate.OrderListType.NeedUpload;
- if (LYFZ.Network.OssOperation.OssProcess.GetUploadOrDownload(out listResult, type))
- {
- dgv_need_upload.Rows.Clear();
- this.tx_need_upload_count.Text = string.Format("数量:{0}", listResult.Count);
- foreach (AliyunOssLibrary.Model.SafeUploadOrderDetail so in listResult)
- {
- DataGridViewRow dgvRow = new DataGridViewRow();
- dgvRow.CreateCells(this.dgv_need_upload);
- dgvRow.Tag = so;
- dgvRow.Cells[0].Value = so.upload_id;
- dgvRow.Cells[1].Value = so.download_branch_name;
- if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype)
- {
- dgvRow.Cells[2].Value = "原片";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype)
- {
- dgvRow.Cells[2].Value = "初修";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype)
- {
- dgvRow.Cells[2].Value = "精修";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype)
- {
- dgvRow.Cells[2].Value = "设计";
- }
- dgvRow.Cells[3].Value = so.upload_order;
- dgvRow.Cells[4].Value = so.upload_images;
- if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.NotUploaded)
- {
- dgvRow.Cells[5].Value = "未上传";
- }
- else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.Uploading)
- {
- dgvRow.Cells[5].Value = "上传中";
- }
- else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.StopUploading)
- {
- dgvRow.Cells[5].Value = "停止上传";
- }
- else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.Uploaded)
- {
- dgvRow.Cells[5].Value = "已上传";
- }
- dgvRow.Cells[6].Value = so.upload_datetime;
- dgvRow.Cells[7].Value = string.Format("{0}/{1}", so.UploadCount, so.upload_images.Split('|').Count());
- this.dgv_need_upload.Rows.Add(dgvRow);
- }
- }
- }
- private void FillupNeedDownloadDataGridView()
- {
- if (this.tabControlEx1.SelectedIndex != 1)
- return;
- List<AliyunOssLibrary.Model.SafeUploadOrderDetail> listResult;
- AliyunOssLibrary.Enumerate.OrderListType type = AliyunOssLibrary.Enumerate.OrderListType.NeedDownload;
- if (LYFZ.Network.OssOperation.OssProcess.GetUploadOrDownload(out listResult, type))
- {
- this.dgv_need_download.Rows.Clear();
- this.tx_need_download_count.Text = string.Format("数量:{0}", listResult.Count);
- foreach (AliyunOssLibrary.Model.SafeUploadOrderDetail so in listResult)
- {
- DataGridViewRow dgvRow = new DataGridViewRow();
- dgvRow.CreateCells(this.dgv_need_download);
- dgvRow.Tag = so;
- dgvRow.Cells[0].Value = so.upload_id;
- dgvRow.Cells[1].Value = so.upload_branch_name;
- if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype)
- {
- dgvRow.Cells[2].Value = "原片";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype)
- {
- dgvRow.Cells[2].Value = "初修";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype)
- {
- dgvRow.Cells[2].Value = "精修";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype)
- {
- dgvRow.Cells[2].Value = "设计";
- }
- dgvRow.Cells[3].Value = so.upload_order;
- dgvRow.Cells[4].Value = so.upload_images;
- if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.NotDownloaded)
- {
- dgvRow.Cells[5].Value = "未下载";
- }
- else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.Downloading)
- {
- dgvRow.Cells[5].Value = "下载中";
- }
- else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.StopDownloading)
- {
- dgvRow.Cells[5].Value = "停止下载";
- }
- else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.Downloaded)
- {
- dgvRow.Cells[5].Value = "已下载";
- }
- dgvRow.Cells[6].Value = so.upload_datetime;
- dgvRow.Cells[7].Value = string.Format("{0}/{1}", so.DownloadCount, so.upload_images.Split('|').Count());
- this.dgv_need_download.Rows.Add(dgvRow);
- }
- }
- }
- private void FillupHasUploadDataGridView()
- {
- if (this.tabControlEx1.SelectedIndex != 2)
- return;
- List<AliyunOssLibrary.Model.SafeUploadOrderDetail> listResult;
- AliyunOssLibrary.Enumerate.OrderListType type = AliyunOssLibrary.Enumerate.OrderListType.HasUpload;
- if (LYFZ.Network.OssOperation.OssProcess.GetUploadOrDownload(out listResult, type))
- {
- this.dgv_has_upload.Rows.Clear();
- this.tx_has_upload_count.Text = string.Format("数量:{0}", listResult.Count);
- foreach (AliyunOssLibrary.Model.SafeUploadOrderDetail so in listResult)
- {
- DataGridViewRow dgvRow = new DataGridViewRow();
- dgvRow.CreateCells(this.dgv_has_upload);
- dgvRow.Tag = so;
- dgvRow.Cells[0].Value = so.upload_id;
- dgvRow.Cells[1].Value = so.download_branch_name;
- if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype)
- {
- dgvRow.Cells[2].Value = "原片";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype)
- {
- dgvRow.Cells[2].Value = "初修";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype)
- {
- dgvRow.Cells[2].Value = "精修";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype)
- {
- dgvRow.Cells[2].Value = "设计";
- }
- dgvRow.Cells[3].Value = so.upload_order;
- if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.NotUploaded)
- {
- dgvRow.Cells[4].Value = "未上传";
- }
- else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.Uploading)
- {
- dgvRow.Cells[4].Value = "上传中";
- }
- else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.StopUploading)
- {
- dgvRow.Cells[4].Value = "停止上传";
- }
- else if (so.upload_status == (int)AliyunOssLibrary.Enumerate.UploadStatus.Uploaded)
- {
- dgvRow.Cells[4].Value = "已上传";
- }
- dgvRow.Cells[5].Value = so.upload_datetime;
- this.dgv_has_upload.Rows.Add(dgvRow);
- }
- }
- }
- private void FillupHasDownloadDataGridView()
- {
- if (this.tabControlEx1.SelectedIndex != 3)
- return;
- List<AliyunOssLibrary.Model.SafeUploadOrderDetail> listResult;
- AliyunOssLibrary.Enumerate.OrderListType type = AliyunOssLibrary.Enumerate.OrderListType.HasDownload;
- if (LYFZ.Network.OssOperation.OssProcess.GetUploadOrDownload(out listResult, type))
- {
- this.dgv_has_download.Rows.Clear();
- this.tx_has_download_count.Text = string.Format("数量:{0}", listResult.Count);
- foreach (AliyunOssLibrary.Model.SafeUploadOrderDetail so in listResult)
- {
- DataGridViewRow dgvRow = new DataGridViewRow();
- dgvRow.CreateCells(this.dgv_has_download);
- dgvRow.Tag = so;
- dgvRow.Cells[0].Value = so.upload_id;
- dgvRow.Cells[1].Value = so.upload_branch_name;
- if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.OImgtype)
- {
- dgvRow.Cells[2].Value = "原片";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.EImgtype)
- {
- dgvRow.Cells[2].Value = "初修";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.FImgtype)
- {
- dgvRow.Cells[2].Value = "精修";
- }
- else if (so.upload_image_type == (int)AliyunOssLibrary.Enumerate.ImageType.DImgtype)
- {
- dgvRow.Cells[2].Value = "设计";
- }
- dgvRow.Cells[3].Value = so.upload_order;
- if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.NotDownloaded)
- {
- dgvRow.Cells[4].Value = "未下载";
- }
- else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.Downloading)
- {
- dgvRow.Cells[4].Value = "下载中";
- }
- else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.StopDownloading)
- {
- dgvRow.Cells[4].Value = "停止下载";
- }
- else if (so.download_status == (int)AliyunOssLibrary.Enumerate.DownloadStatus.Downloaded)
- {
- dgvRow.Cells[4].Value = "已下载";
- }
- dgvRow.Cells[5].Value = so.upload_datetime;
- this.dgv_has_download.Rows.Add(dgvRow);
- }
- }
- }
- #endregion
- }
- }
|