diff --git a/Code/CSRender/CSRender/CompareTIFF.cs b/Code/CSRender/CSRender/CompareTIFF.cs index c2ef8e7d88e228df5cfa4c6e8cce506bc42e4b30..f425008b497cd976e737458dcb135e0ecc35e07d 100644 --- a/Code/CSRender/CSRender/CompareTIFF.cs +++ b/Code/CSRender/CSRender/CompareTIFF.cs @@ -75,13 +75,17 @@ namespace CSRender processStartInfo.Arguments += removePoint; processStartInfo.Arguments += "\" /shadingoff \""; processStartInfo.Arguments += shadingOff; - processStartInfo.Arguments += "\""; + processStartInfo.Arguments += "\" "; if (reportFlag == true) { - processStartInfo.Arguments += " /inspReport \""; + processStartInfo.Arguments += "/inspReport \""; processStartInfo.Arguments += reportName; - processStartInfo.Arguments += "\""; + processStartInfo.Arguments += "\" "; } + //レポート記述内容の参照先 + processStartInfo.Arguments += "/topPageInfo "; + string textPath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "work", "OUT_INFO", "CSReportInf.txt"); + processStartInfo.Arguments += System.IO.Path.Combine(appDirectory, textPath); //CSRender.exeを実行 Process process = Process.Start(processStartInfo); diff --git a/Code/CSRender/CSRender/MainWindow.xaml.cs b/Code/CSRender/CSRender/MainWindow.xaml.cs index f35c66751e024915c88751f675bf66e2ff8e919f..0cddac7ce9ff30a65c99da7b970107f9b2755a1c 100644 --- a/Code/CSRender/CSRender/MainWindow.xaml.cs +++ b/Code/CSRender/CSRender/MainWindow.xaml.cs @@ -254,6 +254,22 @@ namespace CSRender ResultConsole.ScrollToEnd(); DoEvents(); + try + { + //レポートへの出力内容を編集 + editReport(allRipTime, workBox.Text); + } + catch (Exception ex) + { + CustomMsgBox.Show(mainWindow, ex.Message, "例外が発生しました", MessageBoxButton.OK, MessageBoxImage.Warning); + //ログ記述 + DateTime faileTIme = DateTime.Now; + string logText = "[" + faileTIme + "]" + Environment.NewLine; + logText += "例外の生じた処理:検版レポートの編集" + Environment.NewLine; + logText += ex.Message + "\n" + ex.StackTrace + Environment.NewLine; + File.AppendAllText(System.IO.Path.Combine(workLogPath, "CSRender.log"), logText); + } + string workDir = ""; try { @@ -377,6 +393,128 @@ namespace CSRender } + /// + /// 指定ディレクトリ内のPDFファイル名を取得する + /// + private string[] getPDFName(string targetDir) + { + string[] targetFiles = System.IO.Directory.GetFiles(targetDir, "*.pdf", System.IO.SearchOption.TopDirectoryOnly); + return targetFiles; + } + + /// + /// 指定ディレクトリ内のPDFファイルのページ数を取得する + /// + private string getPDFPage(string[] targetFiles, string tiffDir) + { + int[] PDFPages = new int[targetFiles.Length]; + for (int i = 0; i < targetFiles.Length; i++) + { + string targetName = System.IO.Path.GetFileName(targetFiles[i]) + "*.tiff"; + string[] targetPDF = System.IO.Directory.GetFiles(tiffDir, targetName, System.IO.SearchOption.TopDirectoryOnly); + PDFPages[i] = targetPDF.Length; + } + //文字列化 + string allPage = ""; + for (int i = 0; i < PDFPages.Length; i++) + { + if (i > 0) + { + allPage += ","; + } + allPage += PDFPages[i]; + } + return allPage; + } + + /// + /// レポートの出力内容を編集する + /// + private void editReport(string allRipTime, string workBox) + { + // .txtのパス + string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得 + string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得 + string outInfoPath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "work", "OUT_INFO"); + outInfoPath = System.IO.Path.Combine(appDirectory, outInfoPath); + if (!Directory.Exists(outInfoPath)) + { + Directory.CreateDirectory(outInfoPath); + } + string reportInfoPath = System.IO.Path.Combine(outInfoPath, "CSReportInf.txt"); + if (!File.Exists(reportInfoPath)) + { + File.CreateText(reportInfoPath); + } + + //対象フォルダの内容 + string tarTiffDir = System.IO.Path.Combine(workBox, "work", "targetTIFF"); + //PDFの数 + string[] targetPDFs = getPDFName(targetBox.Text); + string targetNum = targetPDFs.Length.ToString(); + //PDFの名前一覧 + string allTargetName = ""; + for (int i = 0; i < targetPDFs.Length; i++) + { + if (i > 0) + { + allTargetName += ","; + } + allTargetName += System.IO.Path.GetFileName(targetPDFs[i]); + } + //PDFのページ数 + string targetAllPage = getPDFPage(targetPDFs, tarTiffDir); + + //リファレンスフォルダの内容 + string refTiffDir = System.IO.Path.Combine(workBox, "work", "referenceTIFF"); + //PDFの数 + string[] referencePDFs = getPDFName(referenceBox.Text); + string referenceNum = referencePDFs.Length.ToString(); + //PDFの名前一覧 + string allReferenceName = ""; + for (int i = 0; i < referencePDFs.Length; i++) + { + if (i > 0) + { + allReferenceName += ","; + } + allReferenceName += System.IO.Path.GetFileName(referencePDFs[i]); + } + //PDFのページ数 + string referenceAllPage = getPDFPage(referencePDFs, refTiffDir); + + //.txtファイルに記述する内容 + string writeText = "**RESULT_RIP_TIME: \"" + allRipTime + "\"\r\n"; + writeText += "**ENV_VERSION: \"CSRender Ver 1.1.0\"\r\n"; + writeText += "**ENV_RIPVERIFY_PATH: \"" + appPath + "\"\r\n"; + writeText += "**ENV_RIP_PROCESSING: \"PDFium\"\r\n"; + writeText += "**ENV_IMAGE_RESO: \"" + ResolutionBox.Text + "\"\r\n"; + if (PageRange.Text == "指定") + { + writeText += "**ENV_INSPECTION_AREA_SPECIFY: \"" + pageBox.Text + "\"\r\n"; + } + else + { + writeText += "**ENV_INSPECTION_AREA_SPECIFY: \"ALL\"\r\n"; + } + writeText += "**PDF_REF_FOLDER: \"" + referenceBox.Text + "\"\r\n"; + writeText += "**PDF_REF_FILE_NUM: \"" + referenceNum + "\"\r\n"; + writeText += "**PDF_REF_NAME: \"" + allReferenceName + "\"\r\n"; + writeText += "**PDF_REF_PAGE_NUM: \"" + referenceAllPage + "\"\r\n"; + writeText += "**PDF_TAR_FOLDER: \"" + targetBox.Text + "\"\r\n"; + writeText += "**PDF_TAR_FILE_NUM: \"" + targetNum + "\"\r\n"; + writeText += "**PDF_TAR_NAME: \"" + allTargetName + "\"\r\n"; + writeText += "**PDF_TAR_PAGE_NUM: \"" + targetAllPage + "\"\r\n"; + + // StreamWriterオブジェクトのインスタンスを生成 + StreamWriter streamWriter = new StreamWriter(reportInfoPath, false, Encoding.GetEncoding("Shift_JIS")); + // Writeメソッドで文字列データを書き込む + streamWriter.Write(writeText); + // StreamWriterオブジェクトを閉じる + streamWriter.Close(); + } + + /// /// TIFF画像化を実行する ///