Commit 1bf2445a authored by tsuji's avatar tsuji

ファイルごとでのレポート出力に修正

parent c687b6cc
...@@ -37,6 +37,9 @@ ...@@ -37,6 +37,9 @@
<setting name="targetSetting" serializeAs="String"> <setting name="targetSetting" serializeAs="String">
<value /> <value />
</setting> </setting>
<setting name="reportPathSetting" serializeAs="String">
<value />
</setting>
</CSRender.Properties.Settings> </CSRender.Properties.Settings>
</userSettings> </userSettings>
<!--runtime--> <!--runtime-->
......
...@@ -23,7 +23,7 @@ namespace CSRender ...@@ -23,7 +23,7 @@ namespace CSRender
{ {
public static string runPureVerify(string targetDir, string referenceDir, string workPath, public static string runPureVerify(string targetDir, string referenceDir, string workPath,
string shiftPixel, string colorMargin, string removePoint, string shadingOff, string shiftPixel, string colorMargin, string removePoint, string shadingOff,
bool reportFlag, string reportName, string inDiffPath) bool reportFlag, string reportName, string inDiffPath, string inTargetFileName, DateTime inDateTime)
{ {
//実行用コンソールの呼び出し //実行用コンソールの呼び出し
ProcessStartInfo processStartInfo = new ProcessStartInfo(); ProcessStartInfo processStartInfo = new ProcessStartInfo();
...@@ -77,17 +77,31 @@ namespace CSRender ...@@ -77,17 +77,31 @@ namespace CSRender
processStartInfo.Arguments += "\" /shadingoff \""; processStartInfo.Arguments += "\" /shadingoff \"";
processStartInfo.Arguments += shadingOff; processStartInfo.Arguments += shadingOff;
processStartInfo.Arguments += "\" "; processStartInfo.Arguments += "\" ";
if (reportFlag == true)
{ //対象ファイル名を設定
processStartInfo.Arguments += "/inspReport \""; inTargetFileName = System.IO.Path.GetFileNameWithoutExtension(inTargetFileName);
processStartInfo.Arguments += reportName; processStartInfo.Arguments += "/inspTiff \"";
processStartInfo.Arguments += "\" "; processStartInfo.Arguments += inTargetFileName + ".pdf";
} processStartInfo.Arguments += "\" ";
//レポートファイル名を設定
string timeForReport = "【" + inDateTime.ToString("yyMMdd_HHmm") + "】" + ".pdf";
string TargetName = System.IO.Path.Combine(reportName, "report_" + inTargetFileName + ".pdf" + timeForReport);
processStartInfo.Arguments += "/inspReport \"";
processStartInfo.Arguments += TargetName;
processStartInfo.Arguments += "\" ";
//Logファイル名を設定
string logFileName = System.IO.Path.Combine(workDir, "report", inTargetFileName + ".pdf.log");
processStartInfo.Arguments += "/pureVLog \"";
processStartInfo.Arguments += logFileName;
processStartInfo.Arguments += "\" ";
//差異画像の出力 //差異画像の出力
processStartInfo.Arguments += "/topPageInfo "; processStartInfo.Arguments += "/outDiff \"";
processStartInfo.Arguments += inDiffPath; processStartInfo.Arguments += inDiffPath;
processStartInfo.Arguments += " "; processStartInfo.Arguments += "\" ";
//レポート記述内容の参照先 //レポート記述内容の参照先
processStartInfo.Arguments += "/topPageInfo "; processStartInfo.Arguments += "/topPageInfo ";
...@@ -100,13 +114,16 @@ namespace CSRender ...@@ -100,13 +114,16 @@ namespace CSRender
process.WaitForExit(); process.WaitForExit();
process.Close(); process.Close();
//NGの含まれる場合レポート名の頭に【NG】を付与
NGReportName(TargetName, reportName);
return workDir; return workDir;
} }
//指定先にレポートを移動 //指定先にレポートを移動
public static void moveReport(string resultPath, string workPath) public static void moveReport(string resultPath, string workPath)
{ {
string reportPath = System.IO.Path.Combine(resultPath, "report"); string reportPath = System.IO.Path.Combine(resultPath, "report", "Log");
if (!Directory.Exists(reportPath))//指定先にreportフォルダがあるか if (!Directory.Exists(reportPath))//指定先にreportフォルダがあるか
{ {
Directory.CreateDirectory(reportPath);//なければ新規でreportフォルダを作成 Directory.CreateDirectory(reportPath);//なければ新規でreportフォルダを作成
...@@ -130,5 +147,23 @@ namespace CSRender ...@@ -130,5 +147,23 @@ namespace CSRender
return ReportName; return ReportName;
} }
//NGの含まれる検版レポート名を編集
public static void NGReportName(string inTargetName, string inReportPath)
{
//string searchName = "report_" + inTargetName;
string searchfile = System.IO.Path.GetFileNameWithoutExtension(inTargetName) + "&*";
var reportFileName = Directory.GetFiles(inReportPath, searchfile);
if (reportFileName.Length > 0)
{
foreach (var oldPathName in reportFileName)
{
string oldFile = System.IO.Path.GetFileName(oldPathName);
File.Copy(oldPathName, System.IO.Path.Combine(inReportPath, "【NG】" + oldFile), true);
File.Delete(oldPathName);
}
}
}
} }
} }
...@@ -74,7 +74,7 @@ namespace CSRender ...@@ -74,7 +74,7 @@ namespace CSRender
var dropFiles = e.Data.GetData(System.Windows.DataFormats.FileDrop) as string[]; var dropFiles = e.Data.GetData(System.Windows.DataFormats.FileDrop) as string[];
if (dropFiles == null) return; if (dropFiles == null) return;
//カーソルを終端に置く //カーソルを終端に置く
reportBox.Text = dropFiles[0] + @"\"; reportBox.Text = dropFiles[0];
reportBox.Focus(); reportBox.Focus();
reportBox.Select(this.reportBox.Text.Length, 0); reportBox.Select(this.reportBox.Text.Length, 0);
} }
...@@ -159,7 +159,7 @@ namespace CSRender ...@@ -159,7 +159,7 @@ namespace CSRender
{ {
Directory.CreateDirectory(System.IO.Path.Combine(selectFile.FileName, "report")); Directory.CreateDirectory(System.IO.Path.Combine(selectFile.FileName, "report"));
} }
//reportBox.Text = System.IO.Path.Combine(selectFile.FileName, "report") + @"\"; //reportBox.Text = System.IO.Path.Combine(selectFile.FileName, "report");
} }
//参照ボタンClickでフォルダ選択のダイアログを表示(検版レポートパス) //参照ボタンClickでフォルダ選択のダイアログを表示(検版レポートパス)
...@@ -172,7 +172,7 @@ namespace CSRender ...@@ -172,7 +172,7 @@ namespace CSRender
selectFile.Title = "フォルダを選択してください"; selectFile.Title = "フォルダを選択してください";
if (Directory.Exists(workBox.Text))//前回値が存在する場合はそのフォルダを初期値として表示 if (Directory.Exists(workBox.Text))//前回値が存在する場合はそのフォルダを初期値として表示
{ {
selectFile.InitialDirectory = workBox.Text.Substring(0, workBox.Text.LastIndexOf(@"\")); selectFile.InitialDirectory = workBox.Text.Substring(0, reportBox.Text.LastIndexOf(@"\"));
} }
else else
{ {
...@@ -183,7 +183,7 @@ namespace CSRender ...@@ -183,7 +183,7 @@ namespace CSRender
return; return;
} }
//共通部分 //共通部分
reportBox.Text = selectFile.FileName + @"\"; reportBox.Text = selectFile.FileName;
reportBox.Focus(); reportBox.Focus();
reportBox.Select(this.reportBox.Text.Length, 0); reportBox.Select(this.reportBox.Text.Length, 0);
} }
...@@ -221,12 +221,17 @@ namespace CSRender ...@@ -221,12 +221,17 @@ namespace CSRender
//レポート出力パスの確認 //レポート出力パスの確認
private bool checkReportPath() private bool checkReportPath()
{ {
bool reportFlag = false; bool reportFlag = true;
string pdfReportPath = ""; //string pdfReportPath = "";
string pdfReportName = ""; //string pdfReportName = "";
int directoryCount = 0; //int directoryCount = 0;
if (reportBox.Text != "")//入力があるか if (reportBox.Text != "")//入力があるか
{ {
if (!Directory.Exists(reportBox.Text))
{
Directory.CreateDirectory(reportBox.Text);
}
/*
directoryCount = reportBox.Text.Split(char.Parse(@"\")).Length - 1;//入力文字列がファイル名のみかディレクトリも含むか directoryCount = reportBox.Text.Split(char.Parse(@"\")).Length - 1;//入力文字列がファイル名のみかディレクトリも含むか
if (directoryCount == 0)//ファイル名のみならば作業ディレクトリのreportフォルダに出力 if (directoryCount == 0)//ファイル名のみならば作業ディレクトリのreportフォルダに出力
{ {
...@@ -254,8 +259,15 @@ namespace CSRender ...@@ -254,8 +259,15 @@ namespace CSRender
} }
reportBox.Text = pdfReportPath + pdfReportName; reportBox.Text = pdfReportPath + pdfReportName;
reportBox.Focus(); reportBox.Focus();
reportBox.Select(this.reportBox.Text.Length, 0); reportBox.Select(this.reportBox.Text.Length, 0);*/
reportFlag = true; }
else
{
reportBox.Text = System.IO.Path.Combine(workBox.Text, "report");
if(!Directory.Exists(System.IO.Path.Combine(workBox.Text, "report")))
{
Directory.CreateDirectory(System.IO.Path.Combine(workBox.Text, "report"));
}
} }
return reportFlag; return reportFlag;
} }
......
...@@ -63,6 +63,7 @@ namespace CSRender ...@@ -63,6 +63,7 @@ namespace CSRender
workBox.Text = Properties.Settings.Default.workSpaceSetting; workBox.Text = Properties.Settings.Default.workSpaceSetting;
targetBox.Text = Properties.Settings.Default.targetSetting; targetBox.Text = Properties.Settings.Default.targetSetting;
referenceBox.Text = Properties.Settings.Default.referenceSetting; referenceBox.Text = Properties.Settings.Default.referenceSetting;
reportBox.Text = Properties.Settings.Default.reportPathSetting;
//ドラッグ&ドロップイベントの追加 //ドラッグ&ドロップイベントの追加
targetBox.AddHandler(TextBox.DragOverEvent, new DragEventHandler(textBox_PreviewDragOver), true); targetBox.AddHandler(TextBox.DragOverEvent, new DragEventHandler(textBox_PreviewDragOver), true);
...@@ -166,6 +167,7 @@ namespace CSRender ...@@ -166,6 +167,7 @@ namespace CSRender
logText += ex.Message + "\n" + ex.StackTrace + Environment.NewLine; logText += ex.Message + "\n" + ex.StackTrace + Environment.NewLine;
File.AppendAllText(System.IO.Path.Combine(workLogPath, "CSRender.log"), logText); File.AppendAllText(System.IO.Path.Combine(workLogPath, "CSRender.log"), logText);
reportBox.Text = ""; reportBox.Text = "";
checkReportPath();
//referenceErrorFlag = true; //referenceErrorFlag = true;
} }
...@@ -255,10 +257,10 @@ namespace CSRender ...@@ -255,10 +257,10 @@ namespace CSRender
var allRipTime = $"{timeResult}".Substring(0,8); var allRipTime = $"{timeResult}".Substring(0,8);
ResultConsole.Text += " [RIP処理時間 " + allRipTime + "]\r\n"; ResultConsole.Text += " [RIP処理時間 " + allRipTime + "]\r\n";
ResultConsole.Text += "<TIFF変換完了>\r\n\r\n"; ResultConsole.Text += "<TIFF変換完了>\r\n";
ResultConsole.ScrollToEnd(); ResultConsole.ScrollToEnd();
DoEvents(); DoEvents();
try try
{ {
//レポートへの出力内容を編集 //レポートへの出力内容を編集
...@@ -278,9 +280,22 @@ namespace CSRender ...@@ -278,9 +280,22 @@ namespace CSRender
string workDir = ""; string workDir = "";
try try
{ {
// 日付取得
DateTime NowTime = DateTime.Now;
//検版対象ファイル名の取得
string[] inspectionTargets = GetTargetList(targetBox.Text, referenceBox.Text);
foreach (var targetPDFName in inspectionTargets)
{
//PureVerifyの実行
workDir = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBox.Text
, shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBox.Text,
outDiffPath, targetPDFName, NowTime);
}
//string targetPDFName = "";
//PureVerifyの実行 //PureVerifyの実行
workDir = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBox.Text //workDir = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBox.Text
, shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBox.Text, outDiffPath); //, shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBox.Text, outDiffPath, targetPDFName);
} }
catch (Exception ex) catch (Exception ex)
{ {
...@@ -358,6 +373,7 @@ namespace CSRender ...@@ -358,6 +373,7 @@ namespace CSRender
Properties.Settings.Default.workSpaceSetting = workBox.Text; Properties.Settings.Default.workSpaceSetting = workBox.Text;
Properties.Settings.Default.targetSetting = targetBox.Text; Properties.Settings.Default.targetSetting = targetBox.Text;
Properties.Settings.Default.referenceSetting = referenceBox.Text; Properties.Settings.Default.referenceSetting = referenceBox.Text;
Properties.Settings.Default.reportPathSetting = reportBox.Text;
Properties.Settings.Default.Save(); Properties.Settings.Default.Save();
} }
...@@ -372,29 +388,43 @@ namespace CSRender ...@@ -372,29 +388,43 @@ namespace CSRender
private void outputLog(string workDir) private void outputLog(string workDir)
{ {
//logファイルを読み取り(1行ずつ) //logファイルを読み取り(1行ずつ)
string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.log", System.IO.SearchOption.TopDirectoryOnly); string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.pdf.log", System.IO.SearchOption.TopDirectoryOnly);
string logfileName = reportFiles[0]; foreach (var logfileName in reportFiles)
StreamReader logString = new StreamReader(logfileName, Encoding.GetEncoding("Shift-JIS"));//Shift-JISでエンコーディング {
string tranceString = ""; string cutLogPath = System.IO.Path.GetFileName(logfileName);
int lineCount = 0; string outputFileName = "\r\n【" + cutLogPath.Remove(cutLogPath.IndexOf(".log")) + "】";
//ファイルから読み取った結果をUIに出力 ResultConsole.Text += outputFileName + "\r\n";
while (logString.EndOfStream == false) StreamReader logString = new StreamReader(logfileName, Encoding.GetEncoding("Shift-JIS"));//Shift-JISでエンコーディング
{ string tranceString = "";
tranceString = logString.ReadLine(); //int lineCount = 0;
lineCount++;
//logファイルにある処理日時表示を除去 //ファイルから読み取った結果をUIに出力
if (lineCount == 14 || lineCount == 19 || lineCount == 36 || lineCount == 37 || lineCount == 38 || lineCount == 39) while (logString.EndOfStream == false)
{
tranceString = tranceString.Substring(0,66);
}
if (lineCount > 13 && lineCount < 40)//必要なところだけをUIに記述
{ {
tranceString = logString.ReadLine();
/*
lineCount++;
//logファイルにある処理日時表示を除去
if (lineCount == 14 || lineCount == 20 || lineCount == 37 || lineCount == 38 || lineCount == 39 || lineCount == 40)
{
tranceString = tranceString.Substring(0, 66);
}
if (lineCount > 13 && lineCount < 41)//必要なところだけをUIに記述
{
ResultConsole.Text += tranceString + "\r\n";
ResultConsole.ScrollToEnd();
DoEvents();
}
*/
ResultConsole.Text += tranceString + "\r\n"; ResultConsole.Text += tranceString + "\r\n";
ResultConsole.ScrollToEnd(); ResultConsole.ScrollToEnd();
DoEvents(); DoEvents();
} }
logString.Close();
} }
logString.Close(); //string logfileName = reportFiles[0];
} }
...@@ -518,7 +548,33 @@ namespace CSRender ...@@ -518,7 +548,33 @@ namespace CSRender
// StreamWriterオブジェクトを閉じる // StreamWriterオブジェクトを閉じる
streamWriter.Close(); streamWriter.Close();
} }
/// <summary>
/// 検版対象のPDFリストを作成する
/// </summary>
private string[] GetTargetList(string inTargetDir, string inRefarenceDir)
{
string[] targetPDFList = getPDFName(inTargetDir);
string[] refPDFList = getPDFName(inRefarenceDir);
List<string> InspectionPDFs = new List<string>(); ;
int i = 0;
foreach (var refPDF in refPDFList)
{
refPDFList[i] = System.IO.Path.GetFileName(refPDF);
i++;
}
foreach (var tarPDF in targetPDFList)
{
if (refPDFList.Contains(System.IO.Path.GetFileName(tarPDF)))
{
InspectionPDFs.Add(tarPDF);
}
}
return InspectionPDFs.ToArray();
}
/// <summary> /// <summary>
/// TIFF画像化を実行する /// TIFF画像化を実行する
......
...@@ -130,5 +130,17 @@ namespace CSRender.Properties { ...@@ -130,5 +130,17 @@ namespace CSRender.Properties {
this["targetSetting"] = value; this["targetSetting"] = value;
} }
} }
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string reportPathSetting {
get {
return ((string)(this["reportPathSetting"]));
}
set {
this["reportPathSetting"] = value;
}
}
} }
} }
...@@ -29,5 +29,8 @@ ...@@ -29,5 +29,8 @@
<Setting Name="targetSetting" Type="System.String" Scope="User"> <Setting Name="targetSetting" Type="System.String" Scope="User">
<Value Profile="(Default)" /> <Value Profile="(Default)" />
</Setting> </Setting>
<Setting Name="reportPathSetting" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings> </Settings>
</SettingsFile> </SettingsFile>
\ No newline at end of file
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