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();
        }
Esempio n. 2
0
        private void btnProcess_Click(object sender, EventArgs e)
        {
            StringBuilder       sb           = new StringBuilder();
            string              SourcePath   = txtFilePath.Text;
            string              SourcePatten = "*.json";
            string              TargetPath   = txtTargetPath.Text;
            List <string>       paths        = Func.GetFilesFromDir(SourcePath, SourcePatten);
            List <SaveResultV2> Results      = new List <SaveResultV2>();
            StringBuilder       ErrorBuilder = new StringBuilder();

            for (int i = 0; i < paths.Count; i++)
            {
                string       jsonpath = paths[i];
                string       dcmPath  = jsonpath.Replace(".json", ".dcm");
                string       FileName = Path.GetFileName(dcmPath);
                SaveResultV2 item     = SaveResultV2.ReadFile(jsonpath);
                //判斷是否是V2版本存檔跟是否有滿足13個點
                if (item.ResultVersion == "2" && item.KeyPoints.Count == 13)
                {
                    string Message = String.Format("Check:{0}/{1}", i, paths.Count);
                    lblMessage.Text = Message;
                    bool HaveNullNode = true;
                    foreach (Nullable <Point> point in item.KeyPoints)
                    {
                        if (point == null)
                        {
                            HaveNullNode = false;
                            break;
                        }
                    }
                    if (HaveNullNode)
                    {
                        Func.CopyFile(jsonpath, TargetPath + @"\" + FileName.Replace(".dcm", ".json"));
                        Func.CopyFile(dcmPath, TargetPath + @"\" + FileName);
                        Results.Add(item);
                    }
                    else
                    {
                        ErrorBuilder.Append(String.Format("{0}{1}", jsonpath, Environment.NewLine));
                    }
                }
            }

            for (int i = 0; i < Results.Count; i++)
            {
                string Message = String.Format("Proc:{0}/{1}", i, Results.Count);
                lblMessage.Text = Message;
                if (i == Results.Count - 1)
                {
                    ProcessFile(ref sb, Results[i], false);
                }
                else
                {
                    ProcessFile(ref sb, Results[i], true);
                }
            }

            Func.WriteText(TargetPath + @"\" + "Total.txt", sb.ToString());
            Func.WriteText(TargetPath + @"\" + "Error.txt", ErrorBuilder.ToString());
            MessageBox.Show("OK", "OK");
        }