public void Login()
        {
            LungCare.SupportPlatform.Models.LoginRequest LoginRequest = new LungCare.SupportPlatform.Models.LoginRequest();
            LoginRequest.UserName = "******";
            LoginRequest.Password = "******";
            LoginRequest.Sender   = "PC Client";

            ThreadPool.QueueUserWorkItem(delegate
            {
                LoginWorker.SendLoginRequest(
                    LoginRequest.UserName,
                    LoginRequest.Password,
                    successCallback : delegate(LungCare.SupportPlatform.Models.LoginResponse response)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        LungCare.SupportPlatform.Security.TokenManager.Token      = response.Token;
                        LungCare.SupportPlatform.Security.SessionManager.UserName = LoginRequest.UserName;


                        LungCare.SupportPlatform.UI.UploadProgressWnd upw = new LungCare.SupportPlatform.UI.UploadProgressWnd();
                        //upw.Owner = LungCare_Airway_PlanNav.MainWindow.Instance;

                        InstitutionName       = "Zhongshan Hospital,Fudan Univ.";
                        PatientName           = "Gan^ Fuming";
                        PatientAge            = "062Y";
                        PatientSex            = "M";
                        SeriesInstanceUID     = "1.2.840.113619.2.55.3.269126727.31.1438774442.877.3";
                        StudyInstanceUID      = "1.2.840.113619.2.55.3.269126727.31.1438774442.873";
                        acquisitionDate       = "20150807";
                        acquisitionTime       = "130902";
                        upw.FileName          = filename;
                        upw.InstitutionName   = InstitutionName;
                        upw.PatientAge        = PatientAge;
                        upw.PatientName       = PatientName;
                        upw.PatientSex        = PatientSex;
                        upw.SeriesInstanceUID = SeriesInstanceUID;
                        upw.StudyInstanceUID  = StudyInstanceUID;
                        upw.acquisitionDate   = acquisitionDate;
                        upw.acquisitionTime   = acquisitionTime;

                        upw.ShowDialog();
                    }
                    //));
                },
                    failureCallback : delegate(string failureReason)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        //MessageBox.Show("登录失败。" + failureReason, "", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Asterisk);
                    }
                    //));
                },
                    errorCallback : delegate(Exception ex)
                {
                    //Dispatcher.Invoke(new Action(delegate
                    {
                        Util.ShowExceptionMessage(ex, "登录出错。");
                    }
                    //));
                });
            });
        }
        public void Ask4PickFile()
        {
            // labelDownloadInfo
            // lbUploadError
            // uploadProgress
            // btnUploadFile
            // btn续传
            var openFileDialog = new Microsoft.Win32.OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                filename = openFileDialog.FileName;
                string ext = new FileInfo(filename).Extension.ToLower();

                if (ext != ".rar" && ext != ".zip" && ext != ".7z" && ext != ".tar" && ext != ".iso")
                {
                    MessageBox.Show("请选择压缩包。", "", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                if (new FileInfo(filename).Length > 500 * 1024 * 1024)
                {
                    MessageBox.Show(string.Format("您选择的压缩包过大,体积为{0},请选择500M以下的压缩包。", HumanReadableFilesize(new FileInfo(filename).Length)), "", MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }

                StartParseDicom();

                MainWindow.Instance.DisableAll();
                Cursor = System.Windows.Input.Cursors.Wait;
                lbDicomError.Visibility   = lbParsingDicom.Visibility = Visibility.Hidden;
                lbParsingDicom.Visibility = Visibility.Visible;

                btnUploadFile.IsEnabled = false;

                ThreadPool.QueueUserWorkItem(delegate
                {
                    // haozipc x I:\AirwayCTZip\20150812\甘福明.rar -oi:/temp/20151005
                    //string tmpFolder = System.IO.Path.Combine("i:/temp/" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "_" + Guid.NewGuid().ToString("N"));
                    //string tmpFolder = System.IO.Path.Combine(Path.GetTempPath() + "/temp/" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + "_" + Guid.NewGuid().ToString("N"));
                    //string tmpFolder = Path.Combine(Path.GetTempPath(), DateTime.Now.ToString("yyyyMMdd-HHmmss"));
                    string tmpFolder = Path.Combine("c:/lctmp/", DateTime.Now.ToString("yyyyMMdd-HHmmss"));

                    string haozipExe = new FileInfo(Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, @"HaoZipC.exe")).FullName;

                    if (!File.Exists(haozipExe))
                    {
                        MessageBox.Show("没有找到" + haozipExe + "。无法解压缩压缩包。");
                        DicomOnError();
                        Dispatcher.Invoke(new Action(delegate
                        {
                            MainWindow.Instance.EnableAll();
                            lbDicomError.Visibility   = Visibility.Visible;
                            lbParsingDicom.Visibility = Visibility.Hidden;
                            btnUploadFile.IsEnabled   = true;
                            Cursor = System.Windows.Input.Cursors.Arrow;
                        }));
                        return;
                    }

                    //string haozipExe = @"C:\Program Files\2345Soft\HaoZip\HaoZipC.exe";
                    string args = string.Format("x \"{0}\" -o\"{1}\"", filename, tmpFolder);

                    Console.WriteLine(haozipExe);
                    Console.WriteLine(args);

                    ProcessStartInfo psi = new ProcessStartInfo(haozipExe, args);
                    psi.CreateNoWindow   = true;
                    psi.WindowStyle      = ProcessWindowStyle.Hidden;

                    Process process = Process.Start(psi);
                    process.WaitForExit();
                    Console.WriteLine("ExitCode: " + process.ExitCode);

                    //Process.Start(tmpFolder);

                    string[] files = Directory.GetFiles(tmpFolder, "*.*", SearchOption.AllDirectories);

                    bool foundDicom = false;
                    foreach (var item in files)
                    {
                        Console.WriteLine(item);

                        if (!HasValidHeader(item))
                        {
                            FileInfo fi = new FileInfo(item);
                            if (fi.Extension.ToString() == ".dcm" || (fi.Length > 500000 && fi.Length < 600000))
                            {
                            }
                            else
                            {
                                continue;
                            }
                        }

                        try
                        {
                            Console.WriteLine("dicom " + item);

                            var file               = DicomFile.Open(item);
                            string patientName     = file.Dataset.Get <string>(DicomTag.PatientName);
                            string patientSex      = file.Dataset.Get <string>(DicomTag.PatientSex);
                            string patientAge      = file.Dataset.Get <string>(DicomTag.PatientAge);
                            string institutionName = file.Dataset.Get <string>(DicomTag.InstitutionName);
                            string acquisitionDate = file.Dataset.Get <string>(DicomTag.AcquisitionDate);
                            string acquisitionTime = file.Dataset.Get <string>(DicomTag.AcquisitionTime);

                            string studyInstanceUID  = file.Dataset.Get <string>(DicomTag.StudyInstanceUID);
                            string seriesInstanceUID = file.Dataset.Get <string>(DicomTag.SeriesInstanceUID);

                            LungCare.SupportPlatform.Models.CTDicomInfo CTDicomInfo = new LungCare.SupportPlatform.Models.CTDicomInfo();
                            CTDicomInfo.PatientName       = patientName;
                            CTDicomInfo.PatientSex        = patientSex;
                            CTDicomInfo.PatientAge        = patientAge;
                            CTDicomInfo.InstitutionName   = institutionName;
                            CTDicomInfo.AcquisitionDate   = acquisitionDate;
                            CTDicomInfo.AcquisitionTime   = acquisitionTime;
                            CTDicomInfo.StudyInstanceUID  = studyInstanceUID;
                            CTDicomInfo.SeriesInstanceUID = seriesInstanceUID;

                            CTDicomInfo.FileName = item;
                            //CTDicomInfo.FileName = new FileInfo(_fileName).Name;
                            //CTDicomInfo.UserId = SessionManager.UserName;
                            //CTDicomInfo.Token = SessionManager.UserName;
                            CTDicomInfo.DataID          = Guid.NewGuid().ToString("N");
                            CTDicomInfo.UploadTimestamp = DateTime.Now;
                            CTDicomInfo.Status          = "已上传";
                            CTDicomInfo.AdditionalData  = string.Format("{0} 已上传", DateTime.Now.ToString("yyyyMMdd HHmm"));

                            InstitutionName      = institutionName;
                            PatientAge           = patientAge;
                            PatientName          = patientName;
                            PatientSex           = patientSex;
                            SeriesInstanceUID    = seriesInstanceUID;
                            StudyInstanceUID     = studyInstanceUID;
                            this.acquisitionDate = acquisitionDate;
                            this.acquisitionTime = acquisitionTime;

                            StringBuilder sb = new StringBuilder();
                            sb.AppendLine(PatientName);
                            sb.AppendLine(PatientAge);
                            sb.AppendLine(PatientSex);
                            sb.AppendLine(acquisitionDate + " " + acquisitionTime);

                            //this.Dispatcher.BeginInvoke(new Action(delegate ()
                            //{
                            //    //lbDicomInfo.Content = sb.ToString();
                            //}));

                            Console.WriteLine(patientName);

                            if (!string.IsNullOrEmpty(patientName))
                            {
                                foundDicom = true;
                                break;
                            }
                        }
                        catch (Exception exDicom)
                        {
                            Console.WriteLine(exDicom.Message);
                        }
                    }

                    try
                    {
                        Directory.Delete(tmpFolder, true);
                    }
                    catch (Exception deleteEx)
                    {
                        Console.WriteLine(deleteEx.Message);
                    }

                    if (!foundDicom)
                    {
                        DicomOnError();
                        Dispatcher.Invoke(new Action(delegate
                        {
                            MainWindow.Instance.EnableAll();
                            lbDicomError.Visibility   = Visibility.Visible;
                            lbParsingDicom.Visibility = Visibility.Hidden;
                            btnUploadFile.IsEnabled   = true;
                            Cursor = System.Windows.Input.Cursors.Arrow;
                        }));
                        return;
                    }

                    GC.Collect();

                    //ThreadPool.QueueUserWorkItem(delegate
                    //{
                    StartUpload();
                    MainWindow.Instance.EnableAll();

                    Dispatcher.Invoke(new Action(delegate
                    {
                        Cursor = System.Windows.Input.Cursors.Arrow;

                        lbDicomError.Visibility = lbParsingDicom.Visibility = Visibility.Hidden;
                        btnUploadFile.IsEnabled = true;

                        LungCare.SupportPlatform.UI.UploadProgressWnd upw = new LungCare.SupportPlatform.UI.UploadProgressWnd();
                        upw.Owner = MainWindow.Instance;

                        upw.FileName          = filename;
                        upw.InstitutionName   = InstitutionName;
                        upw.PatientAge        = PatientAge;
                        upw.PatientName       = PatientName;
                        upw.PatientSex        = PatientSex;
                        upw.SeriesInstanceUID = SeriesInstanceUID;
                        upw.StudyInstanceUID  = StudyInstanceUID;
                        upw.acquisitionDate   = acquisitionDate;
                        upw.acquisitionTime   = acquisitionTime;

                        upw.ShowDialog();
                    }));
                });
            }
        }