diff --git a/Code/CSRender/CSRender/CompareTIFF.cs b/Code/CSRender/CSRender/CompareTIFF.cs
index 97bb072ac28a037b27ef6b0a7e82fc66874acae1..af25128d43dce99b9b88b59f4bc042edd8c18d27 100644
--- a/Code/CSRender/CSRender/CompareTIFF.cs
+++ b/Code/CSRender/CSRender/CompareTIFF.cs
@@ -21,7 +21,7 @@ namespace CSRender
{
class CompareTIFF
{
- public static void runPureVerify(string targetDir, string referenceDir, string workPath,
+ public static int[] runPureVerify(string targetDir, string referenceDir, string workPath,
string shiftPixel, string colorMargin, string removePoint, string shadingOff, bool reportFlag,
string reportName, string inDiffPath, string inTargetFileName, DateTime inDateTime, string inReportInfo)
{
@@ -91,7 +91,7 @@ namespace CSRender
processStartInfo.Arguments += "\" ";
//レポートファイル名を設定
- string timeForReport = "【" + inDateTime.ToString("yyMMdd_HHmm") + "】" + ".pdf";
+ string timeForReport = "[" + inDateTime.ToString("yyMMdd_HHmm") + "]" + ".pdf";
string TargetName = System.IO.Path.Combine(reportName, inTargetFileName + ".pdf" + timeForReport);
processStartInfo.Arguments += "/inspReport \"";
processStartInfo.Arguments += TargetName;
@@ -120,15 +120,23 @@ namespace CSRender
//processStartInfo.Arguments += System.IO.Path.Combine(appDirectory, textPath);
processStartInfo.Arguments += reportInfoPath;
+ //コンソールへの出力を制御
+ processStartInfo.Arguments += " /consoleOut ";
+ processStartInfo.Arguments += "2";//0:新規のコンソールに出力、1:親コンソールに出力(無い場合は新規に)、2:NULLコンソールに出力
+
//CSRender.exeを実行
Process process = Process.Start(processStartInfo);
process.BeginOutputReadLine();
process.WaitForExit();
process.Close();
- //NGの含まれる場合レポート名の頭に【NG】を付与
+ //NGの数を取得
+ int[] NGOfThisFile = getNgOfPDF(logFileName);
+
+ //NGの含まれる場合レポート名の頭に【NG_】を付与
NGReportName(TargetName, reportName);
-
+
+ return NGOfThisFile.ToArray();
}
//指定先にレポートを移動
@@ -171,8 +179,10 @@ namespace CSRender
{
foreach (var oldPathName in NGreportFileName)
{
+ string oldNGName = System.IO.Path.GetFileNameWithoutExtension(oldPathName);
+ oldNGName = oldNGName.Substring(0, oldNGName.Length - 4) + ".pdf";
string oldFile = System.IO.Path.GetFileName(oldPathName);
- File.Copy(oldPathName, System.IO.Path.Combine(inReportPath, "【NG】" + oldFile), true);
+ File.Copy(oldPathName, System.IO.Path.Combine(inReportPath, "NG_" + oldNGName), true);
File.Delete(oldPathName);
}
}
@@ -181,11 +191,41 @@ namespace CSRender
foreach (var beforePathName in OKreportFileName)
{
string oldFile = System.IO.Path.GetFileName(beforePathName);
- File.Copy(beforePathName, System.IO.Path.Combine(inReportPath, "【OK】" + oldFile), true);
+ File.Copy(beforePathName, System.IO.Path.Combine(inReportPath, "OK_" + oldFile), true);
File.Delete(beforePathName);
}
}
}
+ //NG画像の数を取得
+ public static int[] getNgOfPDF(string inLogPath)
+ {
+ string tranceNGString = File.ReadLines(inLogPath, Encoding.GetEncoding("Shift-JIS")).Skip(16).First();//17行目を抽出
+ tranceNGString = tranceNGString.Replace("NG", "");//不要な部分をカット
+ tranceNGString = tranceNGString.Replace(":", "");
+ tranceNGString = tranceNGString.Replace(" ", "");
+
+ string tranceAllString = File.ReadLines(inLogPath, Encoding.GetEncoding("Shift-JIS")).Skip(14).First();//15行目を抽出
+ tranceAllString = tranceAllString.Replace("ALL", "");//不要な部分をカット
+ tranceAllString = tranceAllString.Replace(":", "");
+ tranceAllString = tranceAllString.Replace(" ", "");
+
+ int NGDataNum = 0;
+ int AllDataNum = 0;
+ try
+ {
+ NGDataNum = Int32.Parse(tranceNGString);
+ AllDataNum = Int32.Parse(tranceAllString);
+ }
+ catch (FormatException e)
+ {
+ NGDataNum = 0;
+ AllDataNum = 0;
+ }
+ int[] DataNumSet = { NGDataNum, AllDataNum };
+
+ return DataNumSet.ToArray();
+ }
+
}
}
diff --git a/Code/CSRender/CSRender/MainWindow.xaml b/Code/CSRender/CSRender/MainWindow.xaml
index dc93b0f5c2c311a1ca90b66b2c7e30b564cbf50c..bd9ae722cff5ac64d5fd4d97ff57b693209424ba 100644
--- a/Code/CSRender/CSRender/MainWindow.xaml
+++ b/Code/CSRender/CSRender/MainWindow.xaml
@@ -77,7 +77,7 @@
-
+
@@ -115,5 +115,8 @@
+
+
+
diff --git a/Code/CSRender/CSRender/MainWindow.xaml.cs b/Code/CSRender/CSRender/MainWindow.xaml.cs
index d0c354e58c8a5292f355fcf1559e09760c040d49..6bf5ec6cc25e3e3598c6ef76d7772d5a57ca1954 100644
--- a/Code/CSRender/CSRender/MainWindow.xaml.cs
+++ b/Code/CSRender/CSRender/MainWindow.xaml.cs
@@ -103,7 +103,7 @@ namespace CSRender
/// PureVerify実行の際にレポート名の引数を加えるかどうかを示すフラグ
/// 検版レポートの出力先パス
- private void CompareButtonClick(object sender, RoutedEventArgs e)
+ private async void CompareButtonClick(object sender, RoutedEventArgs e)
{
killButton();
@@ -241,8 +241,11 @@ namespace CSRender
//CSRenderの実行
try
{
- string targetTIFFResult =
- OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, targetBoxText, targetTIFFPath);
+ await Task.Run(() =>
+ {
+ string targetTIFFResult =
+ OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, targetBoxText, targetTIFFPath);
+ });
}
catch (Exception ex)
{
@@ -271,8 +274,11 @@ namespace CSRender
//CSRenderの実行
try
{
- string referenceTIFFResult =
- OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, referenceBoxText, referenceTIFFPath);
+ await Task.Run(() =>
+ {
+ string referenceTIFFResult =
+ OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, referenceBoxText, referenceTIFFPath);
+ });
}
catch (Exception ex)
{
@@ -316,17 +322,32 @@ namespace CSRender
string workDir = "";
int allPDFNum = 0;
int NGPDFNum = 0;
+ //この時点での出力文字列を取得
+ string tiffString = ResultConsole.Text;
try
{
// 日付取得
DateTime NowTime = DateTime.Now;
//検版対象ファイル名の取得
string[] inspectionTargets = GetTargetList(targetBoxText, referenceBoxText);
- allPDFNum = inspectionTargets.Length;
+ allPDFNum = getNumOfTiff(inspectionTargets, targetTIFFPath);//検版する画像ファイルの総数
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得
string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得
workDir = System.IO.Path.Combine(appDirectory, "PureVerify.Data", "RipVerify");
+ //隠しメニューの数値を初期化
+ allNumBox.Text = allPDFNum.ToString();
+ NGNumBox.Text = "0";
+ OKNumBox.Text = "0";
+
+ //出力メニューの表示を更新
+ 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.ScrollToEnd();
+
// 並列処理オプションの設定
ParallelOptions parallelOptions = new ParallelOptions();
parallelOptions.MaxDegreeOfParallelism = 4;// 並行数(プロセス数)
@@ -336,12 +357,19 @@ namespace CSRender
parallelOptions.MaxDegreeOfParallelism = logicalProcessNum - 4;
}
- Parallel.ForEach(inspectionTargets, parallelOptions, targetPDFName =>
- {
- //PureVerifyの実行
- CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBoxText
- , shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBoxText,
- outDiffPath, targetPDFName, NowTime, reportContentsInfo);
+ 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);
+ ResultConsole.Dispatcher.Invoke(new Action(() =>
+ {
+ outProgressToUI(tiffString, NGTiffNum, allPDFNum);
+ }));
+
+ });
});
}
@@ -362,7 +390,8 @@ namespace CSRender
//レポートを出力
//outputLog(System.IO.Path.Combine(workDir, "report"));
NGPDFNum = getNGNum(System.IO.Path.Combine(workDir, "report"));
- outResuletToUI(allPDFNum, NGPDFNum, referenceTIFFPath, targetTIFFPath);
+ ResultConsole.Text = tiffString;
+ outResultToUI(allPDFNum, NGPDFNum, referenceTIFFPath, targetTIFFPath);
}
catch (Exception ex)
{
@@ -526,6 +555,7 @@ namespace CSRender
string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.pdf.log", System.IO.SearchOption.TopDirectoryOnly);
foreach (var logfileName in reportFiles)
{
+ /*
string tranceString = File.ReadLines(logfileName, Encoding.GetEncoding("Shift-JIS")).Skip(16).First();//16行目を抽出
tranceString = tranceString.Replace("NG", "");//不要な部分をカット
tranceString = tranceString.Replace(":", "");
@@ -540,16 +570,52 @@ namespace CSRender
{
NumOfThisFile = 0;
}
- NGFileNum += NumOfThisFile;
+ */
+ int[] NumOfThisFile = CompareTIFF.getNgOfPDF(logfileName);
+ int NumOfThisNG = NumOfThisFile[0];
+
+ NGFileNum += NumOfThisNG;
}
return NGFileNum;
}
+ ///
+ /// UIに途中経過を出力する
+ ///
+ private void outProgressToUI(string inTiffResult, int[] inNGNum,int inAllNum)
+ {
+ int NowNum = int.Parse(allNumBox.Text);//現在の残り画像数を隠しメニューから取得
+ int NowNG = int.Parse(NGNumBox.Text); //現在の残りNG数を同上
+ int NowOK = int.Parse(OKNumBox.Text); //現在の残りOK数を同上
+
+ int NGNumOfPDF = inNGNum[0];
+ int AllNumOfPDF = inNGNum[1];
+ int OKNumOfPDF = AllNumOfPDF - NGNumOfPDF;
+
+ NowNG += NGNumOfPDF;
+ NowOK += OKNumOfPDF;
+ NowNum -= AllNumOfPDF;
+
+ //隠しメニューの数値を更新
+ allNumBox.Text = NowNum.ToString();
+ NGNumBox.Text = NowNG.ToString();
+ OKNumBox.Text = NowOK.ToString();
+
+ //出力メニューの表示を更新
+ inTiffResult += "<検版処理状況>";
+ inTiffResult += "\r\n処理待ち数:";
+ inTiffResult += NowNum.ToString() + "/" + inAllNum;
+ inTiffResult += "\r\nOKファイル数:" + NowOK.ToString();
+ inTiffResult += "\r\nNGファイル数:" + NowNG.ToString();
+ ResultConsole.Text = inTiffResult + "\r\n";
+ ResultConsole.ScrollToEnd();
+ }
+
///
/// UIに検版結果を出力する
///
- private void outResuletToUI(int inAllPDFNum, int inNGPDFNum, string refTiffPath, string tarTiffPath)
+ private void outResultToUI(int inAllPDFNum, int inNGPDFNum, string refTiffPath, string tarTiffPath)
{
//記述用の情報を取得
string[] tarTiffNum = System.IO.Directory.GetFiles(tarTiffPath, "*.tiff", System.IO.SearchOption.TopDirectoryOnly);//画像数
@@ -557,7 +623,7 @@ namespace CSRender
int OKPDFNum = inAllPDFNum - inNGPDFNum;//OKの数
//検版結果を出力
- ResultConsole.Text += "< 検版結果 >\r\n";
+ ResultConsole.Text += "\r\n< 検版結果 >\r\n";
ResultConsole.Text += " リファレンスPDFパス:";
ResultConsole.Text += referenceBox.Text;
ResultConsole.Text += "\r\n リファレンス画像ファイル数:";
@@ -899,6 +965,21 @@ namespace CSRender
return InspectionPDFs.ToArray();
}
+ ///
+ /// 対象となる画像数を取得する
+ ///
+ private int getNumOfTiff(string[] inPDFList, string iniffPath)
+ {
+ int NumOfTiff = 0;
+ foreach (var tarPDF in inPDFList)
+ {
+ string tarFileName = System.IO.Path.GetFileName(tarPDF);
+ string[] targetFiles = System.IO.Directory.GetFiles(iniffPath, tarFileName + "*.tiff", System.IO.SearchOption.TopDirectoryOnly);
+ NumOfTiff += targetFiles.Length;
+ }
+ return NumOfTiff;
+ }
+
///
/// ダミーのPDFファイルを作成する
///