Commit f72b1d0b authored by tsuji's avatar tsuji

並列処理の中で余分に繰り返していた処理(主に引数の生成)を外に出し、1度で済むように修正

(parallelの外で処理するように修正)
parent 9dc65c09
......@@ -21,69 +21,30 @@ namespace CSRender
{
class CompareTIFF
{
public static int[] runPureVerify(string targetDir, string referenceDir, string workPath,
public static int[] runPureVerify(string targetDir, string referenceDir,
string shiftPixel, string colorMargin, string removePoint, string shadingOff, bool reportFlag,
string reportName, string inDiffPath, string inTargetFileName, DateTime inDateTime, string inReportInfo)
string reportName, string inDiffPath, string inTargetFileName, DateTime inDateTime, string inReportInfo,
string inAppDir, string inExePath, string inVerifyArg)
{
//exeのpathを取得
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 processStartInfo = new ProcessStartInfo();
processStartInfo.FileName = System.IO.Path.Combine(appDirectory, exePath, "PureVerify.exe");
processStartInfo.WindowStyle = ProcessWindowStyle.Minimized;
//processStartInfo.FileName = System.IO.Path.Combine(inExePath, "PureVerify.exe");
processStartInfo.FileName = "cmd.exe";
//processStartInfo.WindowStyle = ProcessWindowStyle.Maximized;
processStartInfo.CreateNoWindow = true; // コマンドプロンプトを非表示
processStartInfo.UseShellExecute = false; // シェル機能オフ
processStartInfo.RedirectStandardOutput = true;//標準出力をリダイレクト
//processStartInfo.RedirectStandardOutput = true;//標準出力をリダイレクト
//レポートに書き込む情報を編集
inTargetFileName = System.IO.Path.GetFileNameWithoutExtension(inTargetFileName);
string reportInfoPath = MainWindow.editEachReport(appDirectory,inTargetFileName, inReportInfo, targetDir, referenceDir);
string reportInfoPath = MainWindow.editEachReport(inAppDir,inTargetFileName, inReportInfo, targetDir, referenceDir);
//引数設定
//指定ファイル
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 += "\" ";
//processStartInfo.Arguments = inVerifyArg;
processStartInfo.Arguments = "/C ";
processStartInfo.Arguments += System.IO.Path.Combine(inExePath, "PureVerify.exe");
processStartInfo.Arguments += " ";
processStartInfo.Arguments += inVerifyArg;
//対象ファイル名を設定
processStartInfo.Arguments += "/inspTiff \"";
......@@ -99,7 +60,7 @@ namespace CSRender
//Logファイル名を設定
string logFileName = System.IO.Path.Combine(workDir, "report", inTargetFileName + ".pdf.log");
string logFileName = System.IO.Path.Combine(inAppDir, "PureVerify.Data", "RipVerify", "report", inTargetFileName + ".pdf.log");
processStartInfo.Arguments += "/pureVLog \"";
processStartInfo.Arguments += logFileName;
processStartInfo.Arguments += "\" ";
......@@ -122,11 +83,11 @@ namespace CSRender
//コンソールへの出力を制御
processStartInfo.Arguments += " /consoleOut ";
processStartInfo.Arguments += "2";//0:新規のコンソールに出力、1:親コンソールに出力(無い場合は新規に)、2:NULLコンソールに出力
processStartInfo.Arguments += "1";//0:新規のコンソールに出力、1:親コンソールに出力(無い場合は新規に)、2:NULLコンソールに出力
//processStartInfo.Arguments += " > nul";
//CSRender.exeを実行
Process process = Process.Start(processStartInfo);
process.BeginOutputReadLine();
process.WaitForExit();
process.Close();
......@@ -139,6 +100,55 @@ namespace CSRender
return NGOfThisFile.ToArray();
}
//固定の引数を事前に読み込み
public static string makeFixityArg(string targetDir, string referenceDir, string shiftPixel,
string colorMargin, string removePoint, string shadingOff, string inAppDir)
{
//指定ファイル
string pureArguments = "/tar ";
pureArguments += targetDir;
//リファレンスファイル
pureArguments += " /ref ";
pureArguments += referenceDir;
//EquiosCenterの場所
string EquiosCenter = System.IO.Path.Combine(inAppDir, "PureVerify.Data", "EquiosCenter");
pureArguments += " /equios ";
pureArguments += EquiosCenter;
//出力ファイル形式の引数
pureArguments += " /work ";
//processStartInfo.Arguments += workPath;
string workDir = System.IO.Path.Combine(inAppDir, "PureVerify.Data", "RipVerify");
pureArguments += workDir;
//検版の指定(2だとNGログ検版(LOG-Diff)になる)
pureArguments += " /operation \"1\"";
//差異箇所マークのサイズを指定
pureArguments += " /markdis \"50\"";
//PDFReportの画像の圧縮形式(0:ZLIB、1:LZW、2:JPEG、3:JPEG2000、4:RUN_LENGTH)
pureArguments += " /encode \"1\"";
//検版結果OKとなったファイルリストをPDFレポートの最後に記載(0:記載しない、1:記載する)
pureArguments += " /show \"1\"";
//検版品質ファイルの選択(0:弱、1:中、2:強、3:カスタム)
pureArguments += " /quality \"3\"";
//検版パラメータの設定
pureArguments += " /shiftpixel \"";
pureArguments += shiftPixel;
pureArguments += "\" /colormargin \"";
pureArguments += colorMargin;
pureArguments += "\" /removepoint \"";
pureArguments += removePoint;
pureArguments += "\" /shadingoff \"";
pureArguments += shadingOff;
pureArguments += "\" ";
return pureArguments;
}
//指定先にレポートを移動
public static void moveReport(string resultPath, string workPath)
{
......
......@@ -334,6 +334,18 @@ namespace CSRender
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得
string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得
workDir = System.IO.Path.Combine(appDirectory, "PureVerify.Data", "RipVerify");
//前回のログが内部に残っていれば削除(エラー防止)
if(System.IO.Directory.EnumerateFileSystemEntries(System.IO.Path.Combine(workDir, "report")).Any())
{
DirectoryInfo logDirctory = new DirectoryInfo(System.IO.Path.Combine(workDir, "report"));
FileInfo[] logFiles = logDirctory.GetFiles();
foreach (FileInfo delFile in logFiles)
{
delFile.Delete();
}
}
//exeのpathを取得
string exePath = System.IO.Path.Combine(workDir, "bin", "x64");
//隠しメニューの数値を初期化
allNumBox.Text = allPDFNum.ToString();
......@@ -341,11 +353,11 @@ namespace CSRender
OKNumBox.Text = "0";
//出力メニューの表示を更新
ResultConsole.Text += "<検版処理状況>";
ResultConsole.Text += "\r\n処理待ち数:";
ResultConsole.Text += "< 検版処理状況 >";
ResultConsole.Text += "\r\n 処理待ち数:";
ResultConsole.Text += allPDFNum.ToString() + "/" + allPDFNum.ToString();
ResultConsole.Text += "\r\nOKファイル数:0";
ResultConsole.Text += "\r\nNGファイル数:0\r\n";
ResultConsole.Text += "\r\n OKファイル数:0";
ResultConsole.Text += "\r\n NGファイル数:0\r\n";
ResultConsole.ScrollToEnd();
// 並列処理オプションの設定
......@@ -357,13 +369,17 @@ namespace CSRender
parallelOptions.MaxDegreeOfParallelism = logicalProcessNum - 4;
}
//並列処理内で固定の引数を事前に処理
string verifyArgs = CompareTIFF.makeFixityArg(targetTIFFPath, referenceTIFFPath,
shiftPixel, colorMargin, removePoint, shadingOff, appDirectory);
await Task.Factory.StartNew(() => {
Parallel.ForEach(inspectionTargets, parallelOptions, targetPDFName =>
{
//PureVerifyの実行
int[] NGTiffNum = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBoxText
, shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBoxText,
outDiffPath, targetPDFName, NowTime, reportContentsInfo);
int[] NGTiffNum = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath,
shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBoxText,
outDiffPath, targetPDFName, NowTime, reportContentsInfo, appDirectory, exePath, verifyArgs);
ResultConsole.Dispatcher.Invoke(new Action(() =>
{
outProgressToUI(tiffString, NGTiffNum, allPDFNum);
......@@ -603,11 +619,11 @@ namespace CSRender
OKNumBox.Text = NowOK.ToString();
//出力メニューの表示を更新
inTiffResult += "<検版処理状況>";
inTiffResult += "\r\n処理待ち数:";
inTiffResult += "< 検版処理状況 >";
inTiffResult += "\r\n 処理待ち数:";
inTiffResult += NowNum.ToString() + "/" + inAllNum;
inTiffResult += "\r\nOKファイル数:" + NowOK.ToString();
inTiffResult += "\r\nNGファイル数:" + NowNG.ToString();
inTiffResult += "\r\n OKファイル数:" + NowOK.ToString();
inTiffResult += "\r\n NGファイル数:" + NowNG.ToString();
ResultConsole.Text = inTiffResult + "\r\n";
ResultConsole.ScrollToEnd();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment