private void DownloadDicom(FileListItem selectedFile, DataListItem dataListItem, string selectedDicomPackageLocalPath, 云数据类型Enum 云数据类型Enum) { DownloadFileWorker.Download( selectedFile, selectedDicomPackageLocalPath, delegate(string filename) { UIUtil.Invoke(this, delegate { try { //string tempPath = selectedDicomPackageLocalPath.Substring(0, selectedDicomPackageLocalPath.LastIndexOf(Path.DirectorySeparatorChar)); //System.Diagnostics.Process.Start(tempPath); //ResumeGUI(); while (!File.Exists(selectedDicomPackageLocalPath)) { } string destFileRAR = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(selectedDicomPackageLocalPath), System.IO.Path.GetFileNameWithoutExtension(selectedDicomPackageLocalPath) + ".zip"); File.Copy(selectedDicomPackageLocalPath, destFileRAR); File.Delete(selectedDicomPackageLocalPath); selectedDicomPackageLocalPath = destFileRAR; //System.Diagnostics.Process.Start(System.IO.Path.GetDirectoryName(selectedDicomPackageLocalPath)); string destFolder = AirwayPatients.BaseDicomFolder + "\\" + dataListItem.PatientName + "_" + dataListItem.StudyInstanceUID; //解压缩并用dicomviewer打开 FileDAO.upZip(selectedDicomPackageLocalPath, destFolder); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }); }, delegate(string errMsg) { UIUtil.Invoke(this, delegate { MessageBox.Show("下载发生异常!", "提示"); }); }, delegate(Exception ex) { UIUtil.Invoke(this, delegate { Util.ShowExceptionMessage(ex); }); }, delegate(ProgressArgs progressArgs) { UIUtil.Invoke(this, delegate { Console.WriteLine(progressArgs.Percentage.Value); Progress.Value = progressArgs.Percentage.Value; tbPercent.Text = ((progressArgs.Percentage.Value * 100).ToString("F2")).ToString() + " %"; txtFileSize.Text = FileDAO.HumanReadableFilesize(progressArgs.Total - progressArgs.Remains) + " / " + FileDAO.HumanReadableFilesize(_selectedFile.FileSize); tbSpeed.Text = progressArgs.Speed.HasValue ? FileDAO.HumanReadableFilesize((long)progressArgs.Speed.Value) + "/s" : ""; Console.WriteLine(progressArgs); }); }, 云数据类型Enum); }
private void GetFile(DataListItem dataItem) { MESPDownloadUpload.UserId = dataItem.UserId; MESPDownloadUpload.OrderId = MESPDownloadUpload.OrderNo = dataItem.DataID; try { ThreadPool.QueueUserWorkItem(delegate { new MESPDownloadUpload().FetchFileListAsync( _云数据类型Enum, new EventHandler <ExceptionArgs>( delegate(Object senderInner, ExceptionArgs eInner) { ///MessageBox.Show("未找到文件!"); }), new EventHandler <FileListFinishedArgs>(delegate(Object senderInner, FileListFinishedArgs eInner) { Dispatcher.BeginInvoke(new Action(delegate() { _selectedFile = eInner.Result[0]; txtFileName.Text = _dataItem.PatientName; txtFileType.Text = _云数据类型Enum == 云数据类型Enum.Dicom数据压缩包 ? "DICOM" : "处理数据"; txtFileSize.Text = "0.00 / " + FileDAO.HumanReadableFilesize(_selectedFile.FileSize); //Progress.Maximum = selectedFile.FileSize; Progress.Maximum = 1; string filename = System.IO.Path.Combine(AirwayPatients.BaseDicomFolder, _selectedFile.FileName); filename = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filename), System.IO.Path.GetFileNameWithoutExtension(filename) + ".temp"); string selectedDicomPackageLocalPath = ""; try { selectedDicomPackageLocalPath = new FileInfo(filename).FullName; } catch (Exception) { //filename = @"C:\AirwayVE\CT\" + items.PatientName + ".zip"; //filename = Path.Combine(AirwayPatients.BaseDicomFolder, items.PatientName + ".zip"); selectedDicomPackageLocalPath = new FileInfo(filename).FullName; } ThreadPool.QueueUserWorkItem(delegate { DownloadDicom(_selectedFile, dataItem, selectedDicomPackageLocalPath, 云数据类型Enum.Dicom数据压缩包); }); } )); })); } ); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }