using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; using System.Windows.Controls.Primitives; using System.Text.RegularExpressions; using System.Diagnostics; using System.IO; namespace CSRender { class CompareTIFF { public static string runPureVerify(string targetDir, string referenceDir, string workPath, string shiftPixel, string colorMargin, string removePoint, string shadingOff, bool reportFlag, string reportName) { //実行用コンソールの呼び出し ProcessStartInfo processStartInfo = new ProcessStartInfo(); string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得 string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得 string exePath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "bin", "x64"); processStartInfo.FileName = System.IO.Path.Combine(appDirectory, exePath, "PureVerify.exe"); processStartInfo.CreateNoWindow = true; // コマンドプロンプトを非表示 processStartInfo.UseShellExecute = false; // シェル機能オフ processStartInfo.RedirectStandardOutput = true;//標準出力をリダイレクト //引数設定 //指定ファイル processStartInfo.Arguments = "/tar "; processStartInfo.Arguments += targetDir; //リファレンスファイル processStartInfo.Arguments += " /ref "; processStartInfo.Arguments += referenceDir; //EquiosCenterの場所 string EquiosCenter = System.IO.Path.Combine(appDirectory, "PureVerify.Data", "EquiosCenter"); processStartInfo.Arguments += " /equios "; processStartInfo.Arguments += EquiosCenter; //出力ファイル形式の引数 processStartInfo.Arguments += " /work "; //processStartInfo.Arguments += workPath; string workDir = System.IO.Path.Combine(appDirectory, "PureVerify.Data", "RipVerify"); processStartInfo.Arguments += workDir; //検版の指定(2だとNGログ検版(LOG-Diff)になる) processStartInfo.Arguments += " /operation \"1\""; //差異箇所マークのサイズを指定 processStartInfo.Arguments += " /markdis \"50\""; //PDFReportの画像の圧縮形式(0:ZLIB、1:LZW、2:JPEG、3:JPEG2000、4:RUN_LENGTH) processStartInfo.Arguments += " /encode \"1\""; //検版結果OKとなったファイルリストをPDFレポートの最後に記載(0:記載しない、1:記載する) processStartInfo.Arguments += " /show \"1\""; //検版品質ファイルの選択(0:弱、1:中、2:強、3:カスタム) processStartInfo.Arguments += " /quality \"3\""; //検版パラメータの設定 processStartInfo.Arguments += " /shiftpixel \""; processStartInfo.Arguments += shiftPixel; processStartInfo.Arguments += "\" /colormargin \""; processStartInfo.Arguments += colorMargin; processStartInfo.Arguments += "\" /removepoint \""; processStartInfo.Arguments += removePoint; processStartInfo.Arguments += "\" /shadingoff \""; processStartInfo.Arguments += shadingOff; processStartInfo.Arguments += "\""; if (reportFlag == true) { processStartInfo.Arguments += " /inspReport \""; processStartInfo.Arguments += reportName; processStartInfo.Arguments += "\""; } //CSRender.exeを実行 Process process = Process.Start(processStartInfo); process.BeginOutputReadLine(); process.WaitForExit(); process.Close(); return workDir; } //指定先にレポートを移動 public static void moveReport(string resultPath, string workPath) { string reportPath = System.IO.Path.Combine(resultPath, "report"); if (!Directory.Exists(reportPath))//指定先にreportフォルダがあるか { Directory.CreateDirectory(reportPath);//なければ新規でreportフォルダを作成 } var allReport = Directory.EnumerateFiles(System.IO.Path.Combine(workPath, "report") , "*", SearchOption.TopDirectoryOnly);//reportフォルダ内の全てのファイルを取得 foreach (string file in allReport) { string fileTarget = System.IO.Path.Combine(reportPath, System.IO.Path.GetFileName(file));//旧パスからファイル名を取得して新しいパスを作成 File.Copy(file, fileTarget, true);//指定先にコピー File.Delete(file);//コピー元のファイルを削除 } } //検版レポートのファイル名を取得 public static string getReportName(string workPath) { string[] reportFilePath = System.IO.Directory.GetFiles(System.IO.Path.Combine(workPath, "report") , "*.pdf", System.IO.SearchOption.TopDirectoryOnly);//レポートファイルのパスを取得 string ReportName = System.IO.Path.GetFileName(reportFilePath[0]);//file名を抽出 return ReportName; } } }