Commit 1bf2445a authored by tsuji's avatar tsuji

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

parent c687b6cc
......@@ -37,6 +37,9 @@
<setting name="targetSetting" serializeAs="String">
<value />
</setting>
<setting name="reportPathSetting" serializeAs="String">
<value />
</setting>
</CSRender.Properties.Settings>
</userSettings>
<!--runtime-->
......
......@@ -23,7 +23,7 @@ namespace CSRender
{
public static string runPureVerify(string targetDir, string referenceDir, string workPath,
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();
......@@ -77,17 +77,31 @@ namespace CSRender
processStartInfo.Arguments += "\" /shadingoff \"";
processStartInfo.Arguments += shadingOff;
processStartInfo.Arguments += "\" ";
if (reportFlag == true)
{
//対象ファイル名を設定
inTargetFileName = System.IO.Path.GetFileNameWithoutExtension(inTargetFileName);
processStartInfo.Arguments += "/inspTiff \"";
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 += reportName;
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 += " ";
processStartInfo.Arguments += "\" ";
//レポート記述内容の参照先
processStartInfo.Arguments += "/topPageInfo ";
......@@ -100,13 +114,16 @@ namespace CSRender
process.WaitForExit();
process.Close();
//NGの含まれる場合レポート名の頭に【NG】を付与
NGReportName(TargetName, reportName);
return workDir;
}
//指定先にレポートを移動
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フォルダがあるか
{
Directory.CreateDirectory(reportPath);//なければ新規でreportフォルダを作成
......@@ -130,5 +147,23 @@ namespace CSRender
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
var dropFiles = e.Data.GetData(System.Windows.DataFormats.FileDrop) as string[];
if (dropFiles == null) return;
//カーソルを終端に置く
reportBox.Text = dropFiles[0] + @"\";
reportBox.Text = dropFiles[0];
reportBox.Focus();
reportBox.Select(this.reportBox.Text.Length, 0);
}
......@@ -159,7 +159,7 @@ namespace CSRender
{
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でフォルダ選択のダイアログを表示(検版レポートパス)
......@@ -172,7 +172,7 @@ namespace CSRender
selectFile.Title = "フォルダを選択してください";
if (Directory.Exists(workBox.Text))//前回値が存在する場合はそのフォルダを初期値として表示
{
selectFile.InitialDirectory = workBox.Text.Substring(0, workBox.Text.LastIndexOf(@"\"));
selectFile.InitialDirectory = workBox.Text.Substring(0, reportBox.Text.LastIndexOf(@"\"));
}
else
{
......@@ -183,7 +183,7 @@ namespace CSRender
return;
}
//共通部分
reportBox.Text = selectFile.FileName + @"\";
reportBox.Text = selectFile.FileName;
reportBox.Focus();
reportBox.Select(this.reportBox.Text.Length, 0);
}
......@@ -221,12 +221,17 @@ namespace CSRender
//レポート出力パスの確認
private bool checkReportPath()
{
bool reportFlag = false;
string pdfReportPath = "";
string pdfReportName = "";
int directoryCount = 0;
bool reportFlag = true;
//string pdfReportPath = "";
//string pdfReportName = "";
//int directoryCount = 0;
if (reportBox.Text != "")//入力があるか
{
if (!Directory.Exists(reportBox.Text))
{
Directory.CreateDirectory(reportBox.Text);
}
/*
directoryCount = reportBox.Text.Split(char.Parse(@"\")).Length - 1;//入力文字列がファイル名のみかディレクトリも含むか
if (directoryCount == 0)//ファイル名のみならば作業ディレクトリのreportフォルダに出力
{
......@@ -254,8 +259,15 @@ namespace CSRender
}
reportBox.Text = pdfReportPath + pdfReportName;
reportBox.Focus();
reportBox.Select(this.reportBox.Text.Length, 0);
reportFlag = true;
reportBox.Select(this.reportBox.Text.Length, 0);*/
}
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;
}
......
......@@ -63,6 +63,7 @@ namespace CSRender
workBox.Text = Properties.Settings.Default.workSpaceSetting;
targetBox.Text = Properties.Settings.Default.targetSetting;
referenceBox.Text = Properties.Settings.Default.referenceSetting;
reportBox.Text = Properties.Settings.Default.reportPathSetting;
//ドラッグ&ドロップイベントの追加
targetBox.AddHandler(TextBox.DragOverEvent, new DragEventHandler(textBox_PreviewDragOver), true);
......@@ -166,6 +167,7 @@ namespace CSRender
logText += ex.Message + "\n" + ex.StackTrace + Environment.NewLine;
File.AppendAllText(System.IO.Path.Combine(workLogPath, "CSRender.log"), logText);
reportBox.Text = "";
checkReportPath();
//referenceErrorFlag = true;
}
......@@ -255,7 +257,7 @@ namespace CSRender
var allRipTime = $"{timeResult}".Substring(0,8);
ResultConsole.Text += " [RIP処理時間 " + allRipTime + "]\r\n";
ResultConsole.Text += "<TIFF変換完了>\r\n\r\n";
ResultConsole.Text += "<TIFF変換完了>\r\n";
ResultConsole.ScrollToEnd();
DoEvents();
......@@ -277,10 +279,23 @@ namespace CSRender
string workDir = "";
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);
, shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBox.Text,
outDiffPath, targetPDFName, NowTime);
}
//string targetPDFName = "";
//PureVerifyの実行
//workDir = CompareTIFF.runPureVerify(targetTIFFPath, referenceTIFFPath, workBox.Text
//, shiftPixel, colorMargin, removePoint, shadingOff, reportFlag, reportBox.Text, outDiffPath, targetPDFName);
}
catch (Exception ex)
{
......@@ -358,6 +373,7 @@ namespace CSRender
Properties.Settings.Default.workSpaceSetting = workBox.Text;
Properties.Settings.Default.targetSetting = targetBox.Text;
Properties.Settings.Default.referenceSetting = referenceBox.Text;
Properties.Settings.Default.reportPathSetting = reportBox.Text;
Properties.Settings.Default.Save();
}
......@@ -372,30 +388,44 @@ namespace CSRender
private void outputLog(string workDir)
{
//logファイルを読み取り(1行ずつ)
string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.log", System.IO.SearchOption.TopDirectoryOnly);
string logfileName = reportFiles[0];
string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.pdf.log", System.IO.SearchOption.TopDirectoryOnly);
foreach (var logfileName in reportFiles)
{
string cutLogPath = System.IO.Path.GetFileName(logfileName);
string outputFileName = "\r\n【" + cutLogPath.Remove(cutLogPath.IndexOf(".log")) + "】";
ResultConsole.Text += outputFileName + "\r\n";
StreamReader logString = new StreamReader(logfileName, Encoding.GetEncoding("Shift-JIS"));//Shift-JISでエンコーディング
string tranceString = "";
int lineCount = 0;
//int lineCount = 0;
//ファイルから読み取った結果をUIに出力
while (logString.EndOfStream == false)
{
tranceString = logString.ReadLine();
/*
lineCount++;
//logファイルにある処理日時表示を除去
if (lineCount == 14 || lineCount == 19 || lineCount == 36 || lineCount == 37 || lineCount == 38 || lineCount == 39)
if (lineCount == 14 || lineCount == 20 || lineCount == 37 || lineCount == 38 || lineCount == 39 || lineCount == 40)
{
tranceString = tranceString.Substring(0,66);
tranceString = tranceString.Substring(0, 66);
}
if (lineCount > 13 && lineCount < 40)//必要なところだけをUIに記述
if (lineCount > 13 && lineCount < 41)//必要なところだけをUIに記述
{
ResultConsole.Text += tranceString + "\r\n";
ResultConsole.ScrollToEnd();
DoEvents();
}
*/
ResultConsole.Text += tranceString + "\r\n";
ResultConsole.ScrollToEnd();
DoEvents();
}
logString.Close();
}
//string logfileName = reportFiles[0];
}
/// <summary>
......@@ -519,6 +549,32 @@ namespace CSRender
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>
/// TIFF画像化を実行する
......
......@@ -130,5 +130,17 @@ namespace CSRender.Properties {
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 @@
<Setting Name="targetSetting" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
<Setting Name="reportPathSetting" Type="System.String" Scope="User">
<Value Profile="(Default)" />
</Setting>
</Settings>
</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