diff --git a/Code/CSRender/CSRender/App.config b/Code/CSRender/CSRender/App.config index 5dfaba200e30dc9f550489dd3ac5ff3b71e6be73..82479fa66f72d06615e55584f8ff5a170cbfd563 100644 --- a/Code/CSRender/CSRender/App.config +++ b/Code/CSRender/CSRender/App.config @@ -37,6 +37,9 @@ + + + diff --git a/Code/CSRender/CSRender/CompareTIFF.cs b/Code/CSRender/CSRender/CompareTIFF.cs index 644dc4761b0052c2420042a3440570cd45c52956..a9d4ea5bae86dd7309891fa3efe0bfa04eed19e4 100644 --- a/Code/CSRender/CSRender/CompareTIFF.cs +++ b/Code/CSRender/CSRender/CompareTIFF.cs @@ -23,7 +23,7 @@ namespace CSRender { public static string runPureVerify(string targetDir, string referenceDir, string workPath, string shiftPixel, string colorMargin, string removePoint, string shadingOff, - bool reportFlag, string reportName, string inDiffPath) + bool reportFlag, string reportName, string inDiffPath, string inTargetFileName, DateTime inDateTime) { //実行用コンソールの呼び出し ProcessStartInfo processStartInfo = new ProcessStartInfo(); @@ -77,17 +77,31 @@ namespace CSRender processStartInfo.Arguments += "\" /shadingoff \""; processStartInfo.Arguments += shadingOff; processStartInfo.Arguments += "\" "; - if (reportFlag == true) - { - processStartInfo.Arguments += "/inspReport \""; - processStartInfo.Arguments += reportName; - processStartInfo.Arguments += "\" "; - } + + //対象ファイル名を設定 + inTargetFileName = System.IO.Path.GetFileNameWithoutExtension(inTargetFileName); + processStartInfo.Arguments += "/inspTiff \""; + processStartInfo.Arguments += inTargetFileName + ".pdf"; + processStartInfo.Arguments += "\" "; + + //レポートファイル名を設定 + string timeForReport = "【" + inDateTime.ToString("yyMMdd_HHmm") + "】" + ".pdf"; + string TargetName = System.IO.Path.Combine(reportName, "report_" + inTargetFileName + ".pdf" + timeForReport); + processStartInfo.Arguments += "/inspReport \""; + processStartInfo.Arguments += TargetName; + processStartInfo.Arguments += "\" "; + + + //Logファイル名を設定 + string logFileName = System.IO.Path.Combine(workDir, "report", inTargetFileName + ".pdf.log"); + processStartInfo.Arguments += "/pureVLog \""; + processStartInfo.Arguments += logFileName; + processStartInfo.Arguments += "\" "; //差異画像の出力 - processStartInfo.Arguments += "/topPageInfo "; + processStartInfo.Arguments += "/outDiff \""; processStartInfo.Arguments += inDiffPath; - processStartInfo.Arguments += " "; + processStartInfo.Arguments += "\" "; //レポート記述内容の参照先 processStartInfo.Arguments += "/topPageInfo "; @@ -100,13 +114,16 @@ namespace CSRender process.WaitForExit(); process.Close(); + //NGの含まれる場合レポート名の頭に【NG】を付与 + NGReportName(TargetName, reportName); + return workDir; } //指定先にレポートを移動 public static void moveReport(string resultPath, string workPath) { - string reportPath = System.IO.Path.Combine(resultPath, "report"); + string reportPath = System.IO.Path.Combine(resultPath, "report", "Log"); if (!Directory.Exists(reportPath))//指定先にreportフォルダがあるか { Directory.CreateDirectory(reportPath);//なければ新規でreportフォルダを作成 @@ -130,5 +147,23 @@ namespace CSRender return ReportName; } + + //NGの含まれる検版レポート名を編集 + public static void NGReportName(string inTargetName, string inReportPath) + { + //string searchName = "report_" + inTargetName; + string searchfile = System.IO.Path.GetFileNameWithoutExtension(inTargetName) + "&*"; + var reportFileName = Directory.GetFiles(inReportPath, searchfile); + if (reportFileName.Length > 0) + { + foreach (var oldPathName in reportFileName) + { + string oldFile = System.IO.Path.GetFileName(oldPathName); + File.Copy(oldPathName, System.IO.Path.Combine(inReportPath, "【NG】" + oldFile), true); + File.Delete(oldPathName); + } + } + } + } } diff --git a/Code/CSRender/CSRender/FilePathSelect.cs b/Code/CSRender/CSRender/FilePathSelect.cs index 8f3c7b14af68a13eb275fee3c05771ff7cd49ef5..c625e48e392e32d102a1fe21664e26b89d3c9d09 100644 --- a/Code/CSRender/CSRender/FilePathSelect.cs +++ b/Code/CSRender/CSRender/FilePathSelect.cs @@ -74,7 +74,7 @@ namespace CSRender var dropFiles = e.Data.GetData(System.Windows.DataFormats.FileDrop) as string[]; if (dropFiles == null) return; //カーソルを終端に置く - reportBox.Text = dropFiles[0] + @"\"; + reportBox.Text = dropFiles[0]; reportBox.Focus(); reportBox.Select(this.reportBox.Text.Length, 0); } @@ -159,7 +159,7 @@ namespace CSRender { Directory.CreateDirectory(System.IO.Path.Combine(selectFile.FileName, "report")); } - //reportBox.Text = System.IO.Path.Combine(selectFile.FileName, "report") + @"\"; + //reportBox.Text = System.IO.Path.Combine(selectFile.FileName, "report"); } //参照ボタンClickでフォルダ選択のダイアログを表示(検版レポートパス) @@ -172,7 +172,7 @@ namespace CSRender selectFile.Title = "フォルダを選択してください"; if (Directory.Exists(workBox.Text))//前回値が存在する場合はそのフォルダを初期値として表示 { - selectFile.InitialDirectory = workBox.Text.Substring(0, workBox.Text.LastIndexOf(@"\")); + selectFile.InitialDirectory = workBox.Text.Substring(0, reportBox.Text.LastIndexOf(@"\")); } else { @@ -183,7 +183,7 @@ namespace CSRender return; } //共通部分 - reportBox.Text = selectFile.FileName + @"\"; + reportBox.Text = selectFile.FileName; reportBox.Focus(); reportBox.Select(this.reportBox.Text.Length, 0); } @@ -221,12 +221,17 @@ namespace CSRender //レポート出力パスの確認 private bool checkReportPath() { - bool reportFlag = false; - string pdfReportPath = ""; - string pdfReportName = ""; - int directoryCount = 0; + bool reportFlag = true; + //string pdfReportPath = ""; + //string pdfReportName = ""; + //int directoryCount = 0; if (reportBox.Text != "")//入力があるか { + if (!Directory.Exists(reportBox.Text)) + { + Directory.CreateDirectory(reportBox.Text); + } + /* directoryCount = reportBox.Text.Split(char.Parse(@"\")).Length - 1;//入力文字列がファイル名のみかディレクトリも含むか if (directoryCount == 0)//ファイル名のみならば作業ディレクトリのreportフォルダに出力 { @@ -254,8 +259,15 @@ namespace CSRender } reportBox.Text = pdfReportPath + pdfReportName; reportBox.Focus(); - reportBox.Select(this.reportBox.Text.Length, 0); - reportFlag = true; + reportBox.Select(this.reportBox.Text.Length, 0);*/ + } + else + { + reportBox.Text = System.IO.Path.Combine(workBox.Text, "report"); + if(!Directory.Exists(System.IO.Path.Combine(workBox.Text, "report"))) + { + Directory.CreateDirectory(System.IO.Path.Combine(workBox.Text, "report")); + } } return reportFlag; } diff --git a/Code/CSRender/CSRender/MainWindow.xaml.cs b/Code/CSRender/CSRender/MainWindow.xaml.cs index 87459517115a3e95fba157855dcff4a8ad50a104..159e8d6a04ff209c651d905ba0a103f99d1bba63 100644 --- a/Code/CSRender/CSRender/MainWindow.xaml.cs +++ b/Code/CSRender/CSRender/MainWindow.xaml.cs @@ -63,6 +63,7 @@ namespace CSRender workBox.Text = Properties.Settings.Default.workSpaceSetting; targetBox.Text = Properties.Settings.Default.targetSetting; referenceBox.Text = Properties.Settings.Default.referenceSetting; + reportBox.Text = Properties.Settings.Default.reportPathSetting; //ドラッグ&ドロップイベントの追加 targetBox.AddHandler(TextBox.DragOverEvent, new DragEventHandler(textBox_PreviewDragOver), true); @@ -166,6 +167,7 @@ namespace CSRender logText += ex.Message + "\n" + ex.StackTrace + Environment.NewLine; File.AppendAllText(System.IO.Path.Combine(workLogPath, "CSRender.log"), logText); reportBox.Text = ""; + checkReportPath(); //referenceErrorFlag = true; } @@ -255,10 +257,10 @@ namespace CSRender var allRipTime = $"{timeResult}".Substring(0,8); ResultConsole.Text += " [RIP処理時間 " + allRipTime + "]\r\n"; - ResultConsole.Text += "\r\n\r\n"; + ResultConsole.Text += "\r\n"; ResultConsole.ScrollToEnd(); DoEvents(); - + try { //レポートへの出力内容を編集 @@ -278,9 +280,22 @@ namespace CSRender string workDir = ""; try { + // 日付取得 + DateTime NowTime = DateTime.Now; + //検版対象ファイル名の取得 + string[] inspectionTargets = GetTargetList(targetBox.Text, referenceBox.Text); + foreach (var targetPDFName in inspectionTargets) + { + //PureVerifyの実行 + workDir = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBox.Text + , shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBox.Text, + outDiffPath, targetPDFName, NowTime); + } + //string targetPDFName = ""; + //PureVerifyの実行 - workDir = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBox.Text - , shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBox.Text, outDiffPath); + //workDir = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBox.Text + //, shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBox.Text, outDiffPath, targetPDFName); } catch (Exception ex) { @@ -358,6 +373,7 @@ namespace CSRender Properties.Settings.Default.workSpaceSetting = workBox.Text; Properties.Settings.Default.targetSetting = targetBox.Text; Properties.Settings.Default.referenceSetting = referenceBox.Text; + Properties.Settings.Default.reportPathSetting = reportBox.Text; Properties.Settings.Default.Save(); } @@ -372,29 +388,43 @@ namespace CSRender private void outputLog(string workDir) { //logファイルを読み取り(1行ずつ) - string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.log", System.IO.SearchOption.TopDirectoryOnly); - string logfileName = reportFiles[0]; - StreamReader logString = new StreamReader(logfileName, Encoding.GetEncoding("Shift-JIS"));//Shift-JISでエンコーディング - string tranceString = ""; - int lineCount = 0; - //ファイルから読み取った結果をUIに出力 - while (logString.EndOfStream == false) - { - tranceString = logString.ReadLine(); - lineCount++; - //logファイルにある処理日時表示を除去 - if (lineCount == 14 || lineCount == 19 || lineCount == 36 || lineCount == 37 || lineCount == 38 || lineCount == 39) - { - tranceString = tranceString.Substring(0,66); - } - if (lineCount > 13 && lineCount < 40)//必要なところだけをUIに記述 + string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.pdf.log", System.IO.SearchOption.TopDirectoryOnly); + foreach (var logfileName in reportFiles) + { + string cutLogPath = System.IO.Path.GetFileName(logfileName); + string outputFileName = "\r\n【" + cutLogPath.Remove(cutLogPath.IndexOf(".log")) + "】"; + ResultConsole.Text += outputFileName + "\r\n"; + StreamReader logString = new StreamReader(logfileName, Encoding.GetEncoding("Shift-JIS"));//Shift-JISでエンコーディング + string tranceString = ""; + //int lineCount = 0; + + //ファイルから読み取った結果をUIに出力 + while (logString.EndOfStream == false) { + tranceString = logString.ReadLine(); + /* + lineCount++; + //logファイルにある処理日時表示を除去 + if (lineCount == 14 || lineCount == 20 || lineCount == 37 || lineCount == 38 || lineCount == 39 || lineCount == 40) + { + tranceString = tranceString.Substring(0, 66); + } + if (lineCount > 13 && lineCount < 41)//必要なところだけをUIに記述 + { + ResultConsole.Text += tranceString + "\r\n"; + ResultConsole.ScrollToEnd(); + DoEvents(); + } + */ ResultConsole.Text += tranceString + "\r\n"; ResultConsole.ScrollToEnd(); DoEvents(); } + logString.Close(); + } - logString.Close(); + //string logfileName = reportFiles[0]; + } @@ -518,7 +548,33 @@ namespace CSRender // StreamWriterオブジェクトを閉じる streamWriter.Close(); } - + + /// + /// 検版対象のPDFリストを作成する + /// + private string[] GetTargetList(string inTargetDir, string inRefarenceDir) + { + string[] targetPDFList = getPDFName(inTargetDir); + string[] refPDFList = getPDFName(inRefarenceDir); + List InspectionPDFs = new List(); ; + int i = 0; + foreach (var refPDF in refPDFList) + { + refPDFList[i] = System.IO.Path.GetFileName(refPDF); + i++; + } + foreach (var tarPDF in targetPDFList) + { + if (refPDFList.Contains(System.IO.Path.GetFileName(tarPDF))) + { + InspectionPDFs.Add(tarPDF); + } + + } + + return InspectionPDFs.ToArray(); + } + /// /// TIFF画像化を実行する diff --git a/Code/CSRender/CSRender/Properties/Settings.Designer.cs b/Code/CSRender/CSRender/Properties/Settings.Designer.cs index ed7f4b54f4c732aaa5fbbc33685a151b268817a0..f6c3abc05f27f998b7f3620a124cbb270cf7d5ae 100644 --- a/Code/CSRender/CSRender/Properties/Settings.Designer.cs +++ b/Code/CSRender/CSRender/Properties/Settings.Designer.cs @@ -130,5 +130,17 @@ namespace CSRender.Properties { this["targetSetting"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("")] + public string reportPathSetting { + get { + return ((string)(this["reportPathSetting"])); + } + set { + this["reportPathSetting"] = value; + } + } } } diff --git a/Code/CSRender/CSRender/Properties/Settings.settings b/Code/CSRender/CSRender/Properties/Settings.settings index 5b2aa8e7b01cd6254d7477c057ed6c7a849f0b7d..e43eddd56857a2342a107fc663fb0aea26478e33 100644 --- a/Code/CSRender/CSRender/Properties/Settings.settings +++ b/Code/CSRender/CSRender/Properties/Settings.settings @@ -29,5 +29,8 @@ + + + \ No newline at end of file