Exemplo n.º 1
0
        public void ConvertThread()
        {
            if (String.IsNullOrEmpty(SourcePath))
            {
                return;
            }

            //準備資料
            string JsonSourcePath = this.SourcePath;
            string BackupPath     = System.IO.Path.Combine(JsonSourcePath, "BackUp");

            Func.CheckDirExist(BackupPath);
            string        SourceFilePatten = "*.json";
            List <string> JsonFilePathSet  = Func.GetFilesFromDir(JsonSourcePath, SourceFilePatten, true);

            ProcessBarPage.SetMaxAndMin(0, JsonFilePathSet.Count);
            ProcessBarPage.SetProgressValue(0);
            DcmNotExistPath = new List <string>();


            #region 開始轉換

            #endregion
            for (int i = 0; i < JsonFilePathSet.Count; i++)
            {
                ProcessBarPage.SetProgressValue(i);
                string  JsonFilePath            = JsonFilePathSet[i];
                string  ImageFileNameWithOutExt = System.IO.Path.GetFileNameWithoutExtension(JsonFilePath);
                string  DcmFilePath             = JsonFilePath.Substring(0, JsonFilePath.Length - 5) + ".dcm";
                DcmInfo TempDcmInfo;
                if (Func.CheckFileExist(DcmFilePath))
                {
                    TempDcmInfo = Image_Func.DcmDetailData(DcmFilePath);
                }
                else
                {
                    //如果Json路徑下沒有dcm檔案則跳過此次轉換
                    DcmNotExistPath.Add(JsonFilePath);
                    continue;
                }
                #region 備份檔案到備份路徑
                string V1LogStr   = Func.ReadText(JsonFilePath);
                string BackUpPath = System.IO.Path.Combine(BackupPath, ImageFileNameWithOutExt + ".json");
                Func.WriteText(BackUpPath, V1LogStr);
                #endregion
                //讀取V1檔案
                if (SaveResultV2.IsVersion2(V1LogStr))
                {
                    //如果是V2版本則免轉換跳過
                    continue;
                }
                SaveResultV1 V1Log = SaveResultV1.ReadFile(JsonFilePath);
                //轉V2
                SaveResultV2 V2Log = SaveResultV2.Convert(V1Log, TempDcmInfo);
                //複寫V1版本
                SaveResultV2.SaveFile(V2Log, JsonFilePath);
            }
            ProcessBarPage.CloseWindows();
            OK();
        }
Exemplo n.º 2
0
        private void ProcessFile()
        {
            List <string>       Files = Func.GetFilesFromDir(DirPath, "*.json");
            List <SaveResultV2> Saves = SaveResultV2.ReadFile(Files);

            ProcessBarPage.SetMaxAndMin(0, Saves.Count);
            for (int i = 0; i < Saves.Count; i++)
            {
                ProcessBarPage.SetProgressValue(i);
                Saves[i].CheckKeyPoints();
                SaveResultV2.SaveFile(Saves[i], Files[i]);
            }
            ProcessBarPage.CloseWindows();
            OK();
        }