Commit 9dc65c09 authored by tsuji's avatar tsuji

コンソールを非表示化し、作業進捗をメニューへ表示するように修正

parent 2c78b201
...@@ -21,7 +21,7 @@ namespace CSRender ...@@ -21,7 +21,7 @@ namespace CSRender
{ {
class CompareTIFF 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 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)
{ {
...@@ -91,7 +91,7 @@ namespace CSRender ...@@ -91,7 +91,7 @@ namespace CSRender
processStartInfo.Arguments += "\" "; 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); string TargetName = System.IO.Path.Combine(reportName, inTargetFileName + ".pdf" + timeForReport);
processStartInfo.Arguments += "/inspReport \""; processStartInfo.Arguments += "/inspReport \"";
processStartInfo.Arguments += TargetName; processStartInfo.Arguments += TargetName;
...@@ -120,15 +120,23 @@ namespace CSRender ...@@ -120,15 +120,23 @@ namespace CSRender
//processStartInfo.Arguments += System.IO.Path.Combine(appDirectory, textPath); //processStartInfo.Arguments += System.IO.Path.Combine(appDirectory, textPath);
processStartInfo.Arguments += reportInfoPath; processStartInfo.Arguments += reportInfoPath;
//コンソールへの出力を制御
processStartInfo.Arguments += " /consoleOut ";
processStartInfo.Arguments += "2";//0:新規のコンソールに出力、1:親コンソールに出力(無い場合は新規に)、2:NULLコンソールに出力
//CSRender.exeを実行 //CSRender.exeを実行
Process process = Process.Start(processStartInfo); Process process = Process.Start(processStartInfo);
process.BeginOutputReadLine(); process.BeginOutputReadLine();
process.WaitForExit(); process.WaitForExit();
process.Close(); process.Close();
//NGの含まれる場合レポート名の頭に【NG】を付与 //NGの数を取得
int[] NGOfThisFile = getNgOfPDF(logFileName);
//NGの含まれる場合レポート名の頭に【NG_】を付与
NGReportName(TargetName, reportName); NGReportName(TargetName, reportName);
return NGOfThisFile.ToArray();
} }
//指定先にレポートを移動 //指定先にレポートを移動
...@@ -171,8 +179,10 @@ namespace CSRender ...@@ -171,8 +179,10 @@ namespace CSRender
{ {
foreach (var oldPathName in NGreportFileName) 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); 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); File.Delete(oldPathName);
} }
} }
...@@ -181,11 +191,41 @@ namespace CSRender ...@@ -181,11 +191,41 @@ namespace CSRender
foreach (var beforePathName in OKreportFileName) foreach (var beforePathName in OKreportFileName)
{ {
string oldFile = System.IO.Path.GetFileName(beforePathName); 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); 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();
}
} }
} }
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<TextBox x:Name="pageBox" Grid.Column="1" Height="23" Margin="80,3.667,44.333,0" Grid.Row="6" <TextBox x:Name="pageBox" Grid.Column="1" Height="23" Margin="80,3.667,44.333,0" Grid.Row="6"
TextWrapping="Wrap" Text="1,2,4-6" VerticalAlignment="Top" FontSize="14" IsEnabled="{Binding PageRange_SelectionChanged}" Grid.ColumnSpan="3" TextWrapping="Wrap" Text="1,2,4-6" VerticalAlignment="Top" FontSize="14" IsEnabled="{Binding PageRange_SelectionChanged}" Grid.ColumnSpan="3"
InputMethod.IsInputMethodSuspended="True" PreviewKeyDown="PageBox_PreviewKeyDown" PreviewTextInput="PageBox_PreviewTextInput" LostFocus="PageBox_LostFocus" CommandManager.PreviewExecuted="PageBox_PreviewExecuted" BorderBrush="#FF595959"/> InputMethod.IsInputMethodSuspended="True" PreviewKeyDown="PageBox_PreviewKeyDown" PreviewTextInput="PageBox_PreviewTextInput" LostFocus="PageBox_LostFocus" CommandManager.PreviewExecuted="PageBox_PreviewExecuted" BorderBrush="#FF595959"/>
<TextBox x:Name="ResultConsole" Margin="44,6.667,44.333,8.667" Grid.Row="9" Grid.ColumnSpan="4" VerticalScrollBarVisibility="Auto" FontSize="14" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" BorderBrush="#FF595959"/> <TextBox x:Name="ResultConsole" Margin="44,6.667,44.333,8.667" Grid.Row="9" Grid.ColumnSpan="4" VerticalScrollBarVisibility="Auto" FontSize="14" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" BorderBrush="#FF595959" Panel.ZIndex="1"/>
<Button x:Name="TIFFButton" Content="画像出力" HorizontalAlignment="Left" Height="22" Margin="52,2.333,0,0" Grid.Row="10" VerticalAlignment="Top" Width="82" Click="TIFFButtonClick" Grid.Column="1"/> <Button x:Name="TIFFButton" Content="画像出力" HorizontalAlignment="Left" Height="22" Margin="52,2.333,0,0" Grid.Row="10" VerticalAlignment="Top" Width="82" Click="TIFFButtonClick" Grid.Column="1"/>
<Button x:Name="CompareButton" Content="比較" HorizontalAlignment="Left" Height="22" Margin="143,2.333,0,0" Grid.Row="10" VerticalAlignment="Top" Width="82" Grid.Column="1" Click="CompareButtonClick" Grid.ColumnSpan="2"/> <Button x:Name="CompareButton" Content="比較" HorizontalAlignment="Left" Height="22" Margin="143,2.333,0,0" Grid.Row="10" VerticalAlignment="Top" Width="82" Grid.Column="1" Click="CompareButtonClick" Grid.ColumnSpan="2"/>
<Button x:Name="closeButton" Content="Close" Height="22" Margin="0,2.333,45.333,0" Grid.Row="10" VerticalAlignment="Top" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="77" Click="CloseButton_Click"/> <Button x:Name="closeButton" Content="Close" Height="22" Margin="0,2.333,45.333,0" Grid.Row="10" VerticalAlignment="Top" Grid.Column="2" Grid.ColumnSpan="2" HorizontalAlignment="Right" Width="77" Click="CloseButton_Click"/>
...@@ -115,5 +115,8 @@ ...@@ -115,5 +115,8 @@
</WindowsFormsHost> </WindowsFormsHost>
</StackPanel> </StackPanel>
<TextBox x:Name="allNumBox" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="45,52.667,0,0" Grid.Row="9" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="27"/>
<TextBox x:Name="NGNumBox" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="45,80.667,0,0" Grid.Row="9" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="27"/>
<TextBox x:Name="OKNumBox" Grid.Column="1" HorizontalAlignment="Left" Height="23" Margin="45,108.667,0,0" Grid.Row="9" TextWrapping="Wrap" Text="" VerticalAlignment="Top" Width="27" RenderTransformOrigin="0.535,1.739" Panel.ZIndex="0"/>
</Grid> </Grid>
</Window> </Window>
...@@ -103,7 +103,7 @@ namespace CSRender ...@@ -103,7 +103,7 @@ namespace CSRender
/// <param name="reportFlag">PureVerify実行の際にレポート名の引数を加えるかどうかを示すフラグ</param> /// <param name="reportFlag">PureVerify実行の際にレポート名の引数を加えるかどうかを示すフラグ</param>
/// <param name="pdfReportPath">検版レポートの出力先パス</param> /// <param name="pdfReportPath">検版レポートの出力先パス</param>
private void CompareButtonClick(object sender, RoutedEventArgs e) private async void CompareButtonClick(object sender, RoutedEventArgs e)
{ {
killButton(); killButton();
...@@ -241,8 +241,11 @@ namespace CSRender ...@@ -241,8 +241,11 @@ namespace CSRender
//CSRenderの実行 //CSRenderの実行
try try
{ {
string targetTIFFResult = await Task.Run(() =>
OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, targetBoxText, targetTIFFPath); {
string targetTIFFResult =
OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, targetBoxText, targetTIFFPath);
});
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -271,8 +274,11 @@ namespace CSRender ...@@ -271,8 +274,11 @@ namespace CSRender
//CSRenderの実行 //CSRenderの実行
try try
{ {
string referenceTIFFResult = await Task.Run(() =>
OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, referenceBoxText, referenceTIFFPath); {
string referenceTIFFResult =
OutputTIFF.runCSRender(ResolutionBox.Text, "TIFF", pageFlag, selectedPage, referenceBoxText, referenceTIFFPath);
});
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -316,17 +322,32 @@ namespace CSRender ...@@ -316,17 +322,32 @@ namespace CSRender
string workDir = ""; string workDir = "";
int allPDFNum = 0; int allPDFNum = 0;
int NGPDFNum = 0; int NGPDFNum = 0;
//この時点での出力文字列を取得
string tiffString = ResultConsole.Text;
try try
{ {
// 日付取得 // 日付取得
DateTime NowTime = DateTime.Now; DateTime NowTime = DateTime.Now;
//検版対象ファイル名の取得 //検版対象ファイル名の取得
string[] inspectionTargets = GetTargetList(targetBoxText, referenceBoxText); string[] inspectionTargets = GetTargetList(targetBoxText, referenceBoxText);
allPDFNum = inspectionTargets.Length; allPDFNum = getNumOfTiff(inspectionTargets, targetTIFFPath);//検版する画像ファイルの総数
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得 string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得
string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得 string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得
workDir = System.IO.Path.Combine(appDirectory, "PureVerify.Data", "RipVerify"); 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 parallelOptions = new ParallelOptions();
parallelOptions.MaxDegreeOfParallelism = 4;// 並行数(プロセス数) parallelOptions.MaxDegreeOfParallelism = 4;// 並行数(プロセス数)
...@@ -336,12 +357,19 @@ namespace CSRender ...@@ -336,12 +357,19 @@ namespace CSRender
parallelOptions.MaxDegreeOfParallelism = logicalProcessNum - 4; parallelOptions.MaxDegreeOfParallelism = logicalProcessNum - 4;
} }
Parallel.ForEach(inspectionTargets, parallelOptions, targetPDFName => await Task.Factory.StartNew(() => {
{ Parallel.ForEach(inspectionTargets, parallelOptions, targetPDFName =>
//PureVerifyの実行 {
CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBoxText //PureVerifyの実行
, shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBoxText, int[] NGTiffNum = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBoxText
outDiffPath, targetPDFName, NowTime, reportContentsInfo); , 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 ...@@ -362,7 +390,8 @@ namespace CSRender
//レポートを出力 //レポートを出力
//outputLog(System.IO.Path.Combine(workDir, "report")); //outputLog(System.IO.Path.Combine(workDir, "report"));
NGPDFNum = getNGNum(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) catch (Exception ex)
{ {
...@@ -526,6 +555,7 @@ namespace CSRender ...@@ -526,6 +555,7 @@ namespace CSRender
string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.pdf.log", System.IO.SearchOption.TopDirectoryOnly); string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.pdf.log", System.IO.SearchOption.TopDirectoryOnly);
foreach (var logfileName in reportFiles) foreach (var logfileName in reportFiles)
{ {
/*
string tranceString = File.ReadLines(logfileName, Encoding.GetEncoding("Shift-JIS")).Skip(16).First();//16行目を抽出 string tranceString = File.ReadLines(logfileName, Encoding.GetEncoding("Shift-JIS")).Skip(16).First();//16行目を抽出
tranceString = tranceString.Replace("NG", "");//不要な部分をカット tranceString = tranceString.Replace("NG", "");//不要な部分をカット
tranceString = tranceString.Replace(":", ""); tranceString = tranceString.Replace(":", "");
...@@ -540,16 +570,52 @@ namespace CSRender ...@@ -540,16 +570,52 @@ namespace CSRender
{ {
NumOfThisFile = 0; NumOfThisFile = 0;
} }
NGFileNum += NumOfThisFile; */
int[] NumOfThisFile = CompareTIFF.getNgOfPDF(logfileName);
int NumOfThisNG = NumOfThisFile[0];
NGFileNum += NumOfThisNG;
} }
return NGFileNum; return NGFileNum;
} }
/// <summary>
/// UIに途中経過を出力する
/// </summary>
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();
}
/// <summary> /// <summary>
/// UIに検版結果を出力する /// UIに検版結果を出力する
/// </summary> /// </summary>
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);//画像数 string[] tarTiffNum = System.IO.Directory.GetFiles(tarTiffPath, "*.tiff", System.IO.SearchOption.TopDirectoryOnly);//画像数
...@@ -557,7 +623,7 @@ namespace CSRender ...@@ -557,7 +623,7 @@ namespace CSRender
int OKPDFNum = inAllPDFNum - inNGPDFNum;//OKの数 int OKPDFNum = inAllPDFNum - inNGPDFNum;//OKの数
//検版結果を出力 //検版結果を出力
ResultConsole.Text += "< 検版結果 >\r\n"; ResultConsole.Text += "\r\n< 検版結果 >\r\n";
ResultConsole.Text += " リファレンスPDFパス:"; ResultConsole.Text += " リファレンスPDFパス:";
ResultConsole.Text += referenceBox.Text; ResultConsole.Text += referenceBox.Text;
ResultConsole.Text += "\r\n リファレンス画像ファイル数:"; ResultConsole.Text += "\r\n リファレンス画像ファイル数:";
...@@ -899,6 +965,21 @@ namespace CSRender ...@@ -899,6 +965,21 @@ namespace CSRender
return InspectionPDFs.ToArray(); return InspectionPDFs.ToArray();
} }
/// <summary>
/// 対象となる画像数を取得する
/// </summary>
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;
}
/// <summary> /// <summary>
/// ダミーのPDFファイルを作成する /// ダミーのPDFファイルを作成する
/// </summary> /// </summary>
......
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