Commit a52bae97 authored by tsuji's avatar tsuji

UI部分のコードと処理部分のコードを分離

parent 7d7ee434
......@@ -21,7 +21,7 @@ namespace CSRender
{
class CompareTIFF
{
public static int[] runPureVerify(string targetDir, string referenceDir,
internal 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 inAppDir, string inExePath, string inVerifyArg)
......@@ -34,7 +34,7 @@ namespace CSRender
//レポートに書き込む情報を編集
inTargetFileName = System.IO.Path.GetFileNameWithoutExtension(inTargetFileName);
string reportInfoPath = MainWindow.editEachReport(inAppDir,inTargetFileName, inReportInfo, targetDir, referenceDir);
string reportInfoPath = editEachReport(inAppDir,inTargetFileName, inReportInfo, targetDir, referenceDir);
//引数設定
processStartInfo.Arguments = inVerifyArg;
......@@ -95,7 +95,7 @@ namespace CSRender
}
//固定の引数を事前に読み込み
public static string makeFixityArg(string targetDir, string referenceDir, string shiftPixel,
internal static string makeFixityArg(string targetDir, string referenceDir, string shiftPixel,
string colorMargin, string removePoint, string shadingOff, string inAppDir)
{
//指定ファイル
......@@ -144,7 +144,7 @@ namespace CSRender
}
//指定先にレポートを移動
public static void moveReport(string resultPath, string workPath)
internal static void moveReport(string resultPath, string workPath)
{
string reportPath = System.IO.Path.Combine(resultPath, "report", "Log");
if (!Directory.Exists(reportPath))//指定先にreportフォルダがあるか
......@@ -162,7 +162,7 @@ namespace CSRender
}
//検版レポートのファイル名を取得
public static string getReportName(string workPath)
internal static string getReportName(string workPath)
{
string[] reportFilePath = System.IO.Directory.GetFiles(System.IO.Path.Combine(workPath, "report")
, "*.pdf", System.IO.SearchOption.TopDirectoryOnly);//レポートファイルのパスを取得
......@@ -172,7 +172,7 @@ namespace CSRender
}
//NGの含まれる検版レポート名を編集
public static void NGReportName(string inTargetName, string inReportPath)
internal static void NGReportName(string inTargetName, string inReportPath)
{
//string searchName = "report_" + inTargetName;
string searchfile = System.IO.Path.GetFileNameWithoutExtension(inTargetName) + "&*";
......@@ -202,7 +202,7 @@ namespace CSRender
}
//NG画像の数を取得
public static int[] getNgOfPDF(string inLogPath)
internal static int[] getNgOfPDF(string inLogPath)
{
string tranceNGString = File.ReadLines(inLogPath, Encoding.GetEncoding("Shift-JIS")).Skip(16).First();//17行目を抽出
tranceNGString = tranceNGString.Replace("NG", "");//不要な部分をカット
......@@ -232,7 +232,7 @@ namespace CSRender
}
//前回のログが内部に残っていれば削除(エラー防止)
public static void deleteOldLog(string inLogPath)
internal static void deleteOldLog(string inLogPath)
{
if (System.IO.Directory.EnumerateFileSystemEntries(inLogPath).Any())
{
......@@ -244,5 +244,246 @@ namespace CSRender
}
}
}
/// <summary>
/// NGな画像の総数を取得
/// </summary>
internal static int getNGNum(string workDir)
{
int NGFileNum = 0;
//logファイルを読み取り(NG数の記述されている行を抽出)
string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.pdf.log", System.IO.SearchOption.TopDirectoryOnly);
foreach (var logfileName in reportFiles)
{
int[] NumOfThisFile = CompareTIFF.getNgOfPDF(logfileName);
int NumOfThisNG = NumOfThisFile[0];
NGFileNum += NumOfThisNG;
}
return NGFileNum;
}
/// <summary>
/// 指定ディレクトリ内のPDFファイル名を取得する
/// </summary>
internal static string[] getPDFName(string targetDir)
{
if (File.Exists(targetDir))//対象がファイルの場合
{
string[] targetFiles = { targetDir };
return targetFiles;
}
else//対象がディレクトリの場合はGetFilesメソッドで読み取る
{
string[] targetFiles = System.IO.Directory.GetFiles(targetDir, "*.pdf", System.IO.SearchOption.TopDirectoryOnly);
return targetFiles;
}
}
/// <summary>
/// 指定ディレクトリ内のPDFファイルのページ数を取得する
/// </summary>
internal static string getPDFPage(string[] targetFiles, string tiffDir)
{
int[] PDFPages = new int[targetFiles.Length];
for (int i = 0; i < targetFiles.Length; i++)
{
string targetName = System.IO.Path.GetFileName(targetFiles[i]) + "*.tiff";
string[] targetPDF = System.IO.Directory.GetFiles(tiffDir, targetName, System.IO.SearchOption.TopDirectoryOnly);
PDFPages[i] = targetPDF.Length;
}
//文字列化
string allPage = "";
for (int i = 0; i < PDFPages.Length; i++)
{
if (i > 0)
{
allPage += ",";
}
allPage += PDFPages[i];
}
return allPage;
}
/// <summary>
/// 検版するPDFに応じたレポートの出力内容を編集する
/// </summary>
internal static string editEachReport(string inAppDir, string targetPDF, string textContent, string TarTiffPath, string RefTiffpath)
{
// .txtのパス
string outInfoPath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "work", "OUT_INFO", "ReportInf");
outInfoPath = System.IO.Path.Combine(inAppDir, outInfoPath);
if (!Directory.Exists(outInfoPath))
{
Directory.CreateDirectory(outInfoPath);
}
//ユニークなファイル名(検版するファイル名)でテキストファイルを生成
string replaceTarName = targetPDF.Replace(" ", "_");
string reportInfoPath = System.IO.Path.Combine(outInfoPath, replaceTarName + "Inf.txt");
//if (!File.Exists(reportInfoPath))
//{
//File.CreateText(reportInfoPath);
//}
//.txtファイルに記述する内容(ターゲットファイルとリファレンスファイル名)
textContent += "**PDF_REF_NAME: \"" + targetPDF + ".pdf\"\r\n";
textContent += "**PDF_TAR_NAME: \"" + targetPDF + ".pdf\"\r\n";
//ページ数を取得
string[] referenceTiff = System.IO.Directory.GetFiles(RefTiffpath, targetPDF + ".pdf*.tiff", System.IO.SearchOption.TopDirectoryOnly);
string referenceAllPage = referenceTiff.Length.ToString();
textContent += "**PDF_REF_PAGE_NUM: \"" + referenceAllPage + "\"\r\n";
string[] targetTiff = System.IO.Directory.GetFiles(TarTiffPath, targetPDF + ".pdf*.tiff", System.IO.SearchOption.TopDirectoryOnly);
string targetAllPage = targetTiff.Length.ToString();
textContent += "**PDF_TAR_PAGE_NUM: \"" + targetAllPage + "\"\r\n";
// StreamWriterオブジェクトのインスタンスを生成
using (StreamWriter streamWriter = new StreamWriter(reportInfoPath, false, Encoding.GetEncoding("Shift_JIS")))
{
// Writeメソッドで文字列データを書き込む
streamWriter.Write(textContent);
// StreamWriterオブジェクトを閉じる
streamWriter.Close();
}
return reportInfoPath;
}
/// <summary>
/// 生成したレポート内容参照先txtファイルを全削除(次回に残さない)
/// </summary>
internal static void deleteReportTexts()
{
// .txtのパス
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得
string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得
string outInfoPath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "work", "OUT_INFO", "ReportInf");
//ディレクトリ内のファイルを全て取得して全て削除
DirectoryInfo reportTextDir = new DirectoryInfo(outInfoPath);
FileInfo[] deleteTextFles = reportTextDir.GetFiles();
foreach (FileInfo deleteTxt in deleteTextFles)
{
deleteTxt.Delete();
}
}
/// <summary>
/// レポートの出力内容を編集する
/// </summary>
internal static string getReportInfo(string allRipTime, string workBox,
string targetBoxText, string referenceBoxText, string ResolutionBoxText, string PageRangeText, string pageBoxText)
{
// exeのパス
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得
//対象フォルダの内容
string tarTiffDir = System.IO.Path.Combine(workBox, "work", "targetTIFF");
//PDFの数
string[] targetPDFs = CompareTIFF.getPDFName(targetBoxText);
string targetNum = targetPDFs.Length.ToString();
//PDFのページ数
string targetAllPage = CompareTIFF.getPDFPage(targetPDFs, tarTiffDir);
//リファレンスフォルダの内容
string refTiffDir = System.IO.Path.Combine(workBox, "work", "referenceTIFF");
//PDFの数
string[] referencePDFs = CompareTIFF.getPDFName(referenceBoxText);
string referenceNum = referencePDFs.Length.ToString();
//PDFのページ数
string referenceAllPage = CompareTIFF.getPDFPage(referencePDFs, refTiffDir);
//.txtファイルに記述する内容
string writeText = "**RESULT_RIP_TIME: \"" + allRipTime + "\"\r\n";
writeText += "**ENV_VERSION: \"CSRender Ver 0.3.0\"\r\n";
writeText += "**ENV_RIPVERIFY_PATH: \"" + appPath + "\"\r\n";
writeText += "**ENV_RIP_PROCESSING: \"PDFium\"\r\n";
writeText += "**ENV_IMAGE_RESO: \"" + ResolutionBoxText + "\"\r\n";
if (PageRangeText == "指定")
{
writeText += "**ENV_INSPECTION_AREA_SPECIFY: \"" + pageBoxText + "\"\r\n";
}
else
{
writeText += "**ENV_INSPECTION_AREA_SPECIFY: \"ALL\"\r\n";
}
writeText += "**PDF_REF_FOLDER: \"" + referenceBoxText + "\"\r\n";
writeText += "**PDF_REF_FILE_NUM: \"" + referenceNum + "\"\r\n";
//writeText += "**PDF_REF_NAME: \"" + allReferenceName + "\"\r\n";
//writeText += "**PDF_REF_PAGE_NUM: \"" + referenceAllPage + "\"\r\n";
writeText += "**PDF_TAR_FOLDER: \"" + targetBoxText + "\"\r\n";
writeText += "**PDF_TAR_FILE_NUM: \"" + targetNum + "\"\r\n";
//writeText += "**PDF_TAR_NAME: \"" + allTargetName + "\"\r\n";
//writeText += "**PDF_TAR_PAGE_NUM: \"" + targetAllPage + "\"\r\n";
//string eachWriteTxet = writeText;
return writeText;
}
/// <summary>
/// 検版対象のPDFリストを作成する
/// </summary>
internal static string[] GetTargetList(string inTargetDir, string inRefarenceDir)
{
string[] targetPDFList = CompareTIFF.getPDFName(inTargetDir);
string[] refPDFList = CompareTIFF.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>
internal static 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>
/// ダミーのPDFファイルを作成する
/// </summary>
internal static string createDummyFile(string inTargetPath, string inDummyDir, string inFileName)
{
string TargetDir = System.IO.Path.GetDirectoryName(inTargetPath);//ファイルパスを取得
string TargetFile = System.IO.Path.GetFileName(inTargetPath);//ファイル名を取得
if (inFileName == "")//名前が空ならパスから取得した名前を代入
{
inFileName = TargetFile;
}
File.Copy(inTargetPath, System.IO.Path.Combine(inDummyDir, inFileName), true);
return inFileName;
}
/// <summary>
/// ダミーのPDFファイルを削除する
/// </summary>
internal static void deleteDummyFile(string inDummyPath, string inDummyName)
{
File.Delete(System.IO.Path.Combine(inDummyPath, inDummyName));
}
}
}
......@@ -307,8 +307,8 @@ namespace CSRender
string dummyRefDir = System.IO.Path.Combine(dummyDir, "Reference");
if (!Directory.Exists(dummyRefDir)) { Directory.CreateDirectory(dummyRefDir); }
//ダミーファイルを作成
dummyFileName = createDummyFile(targetBoxText, dummyTarDir, dummyFileName);
dummyFileName = createDummyFile(referenceBoxText, dummyRefDir, dummyFileName);
dummyFileName = CompareTIFF.createDummyFile(targetBoxText, dummyTarDir, dummyFileName);
dummyFileName = CompareTIFF.createDummyFile(referenceBoxText, dummyRefDir, dummyFileName);
dummyFlag = true;
//検版対象をダミーに指定
targetBoxText = dummyTarDir;
......
......@@ -274,7 +274,8 @@ namespace CSRender
{
//レポートへの出力内容を編集
//editReport(allRipTime, workBoxText);
reportContentsInfo = getReportInfo(allRipTime, workBoxText);
reportContentsInfo = CompareTIFF.getReportInfo(allRipTime, workBoxText,
targetBoxText, referenceBoxText, ResolutionBox.Text, PageRange.Text, pageBox.Text);
}
catch (Exception ex)
{
......@@ -289,21 +290,11 @@ namespace CSRender
// 日付取得
DateTime NowTime = DateTime.Now;
//検版対象ファイル名の取得
string[] inspectionTargets = GetTargetList(targetBoxText, referenceBoxText);
allPDFNum = getNumOfTiff(inspectionTargets, targetTIFFPath);//検版する画像ファイルの総数
string[] inspectionTargets = CompareTIFF.GetTargetList(targetBoxText, referenceBoxText);
allPDFNum = CompareTIFF.getNumOfTiff(inspectionTargets, targetTIFFPath);//検版する画像ファイルの総数
//隠しメニューの数値を初期化
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\n OKファイル数:0";
ResultConsole.Text += "\r\n NGファイル数:0\r\n";
ResultConsole.ScrollToEnd();
//出力メニューの進捗表示を初期化
resetProgressText(allPDFNum);
// 並列処理オプションの設定
ParallelOptions parallelOptions = new ParallelOptions();
......@@ -344,7 +335,7 @@ namespace CSRender
{
//レポートを出力
//outputLog(System.IO.Path.Combine(workDir, "report"));
NGPDFNum = getNGNum(System.IO.Path.Combine(workDir, "report"));
NGPDFNum = CompareTIFF.getNGNum(System.IO.Path.Combine(workDir, "report"));
ResultConsole.Text = tiffString;
outResultToUI(allPDFNum, NGPDFNum, referenceTIFFPath, targetTIFFPath);
}
......@@ -401,13 +392,13 @@ namespace CSRender
}
//生成したレポートinf.txtを全削除
deleteReportTexts();
CompareTIFF.deleteReportTexts();
//生成したダミーファイルを削除
if (dummyFlag)
{
deleteDummyFile(System.IO.Path.Combine(workBoxText, "Dummy", "Target"), dummyFileName);
deleteDummyFile(System.IO.Path.Combine(workBoxText, "Dummy", "Reference"), dummyFileName);
CompareTIFF.deleteDummyFile(System.IO.Path.Combine(workBoxText, "Dummy", "Target"), dummyFileName);
CompareTIFF.deleteDummyFile(System.IO.Path.Combine(workBoxText, "Dummy", "Reference"), dummyFileName);
}
//パラメータを次回初期値用に保存
......@@ -482,26 +473,6 @@ namespace CSRender
}
/// <summary>
/// NGな画像の総数を取得
/// </summary>
private int getNGNum(string workDir)
{
int NGFileNum = 0;
//logファイルを読み取り(NG数の記述されている行を抽出)
string[] reportFiles = System.IO.Directory.GetFiles(workDir, "*.pdf.log", System.IO.SearchOption.TopDirectoryOnly);
foreach (var logfileName in reportFiles)
{
int[] NumOfThisFile = CompareTIFF.getNgOfPDF(logfileName);
int NumOfThisNG = NumOfThisFile[0];
NGFileNum += NumOfThisNG;
}
return NGFileNum;
}
/// <summary>
/// UIに途中経過を出力する
/// </summary>
......@@ -585,344 +556,26 @@ namespace CSRender
ResultConsole.Text += "\r\n  NG-ゆすらせ検版:";
ResultConsole.Text += inNGPDFNum.ToString();
ResultConsole.Text += "\r\n< 検版終了 >\r\n";
ResultConsole.ScrollToEnd();
DoEvents();
//string logfileName = reportFiles[0];
}
/// <summary>
/// 指定ディレクトリ内のPDFファイル名を取得する
/// </summary>
private string[] getPDFName(string targetDir)
{
if (File.Exists(targetDir))
{
string[] targetFiles = { targetDir };
return targetFiles;
}
else
{
string[] targetFiles = System.IO.Directory.GetFiles(targetDir, "*.pdf", System.IO.SearchOption.TopDirectoryOnly);
return targetFiles;
}
}
/// <summary>
/// 指定ディレクトリ内のPDFファイルのページ数を取得する
/// </summary>
private string getPDFPage(string[] targetFiles, string tiffDir)
{
int[] PDFPages = new int[targetFiles.Length];
for (int i = 0; i < targetFiles.Length; i++)
{
string targetName = System.IO.Path.GetFileName(targetFiles[i]) + "*.tiff";
string[] targetPDF = System.IO.Directory.GetFiles(tiffDir, targetName, System.IO.SearchOption.TopDirectoryOnly);
PDFPages[i] = targetPDF.Length;
}
//文字列化
string allPage = "";
for (int i = 0; i < PDFPages.Length; i++)
{
if (i > 0)
{
allPage += ",";
}
allPage += PDFPages[i];
}
return allPage;
}
/// <summary>
/// 検版するPDFに応じたレポートの出力内容を編集する
/// </summary>
internal static string editEachReport(string inAppDir, string targetPDF, string textContent, string TarTiffPath, string RefTiffpath)
{
// .txtのパス
string outInfoPath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "work", "OUT_INFO", "ReportInf");
outInfoPath = System.IO.Path.Combine(inAppDir, outInfoPath);
if (!Directory.Exists(outInfoPath))
{
Directory.CreateDirectory(outInfoPath);
}
//ユニークなファイル名(検版するファイル名)でテキストファイルを生成
string replaceTarName = targetPDF.Replace(" ", "_");
string reportInfoPath = System.IO.Path.Combine(outInfoPath, replaceTarName + "Inf.txt");
//if (!File.Exists(reportInfoPath))
//{
//File.CreateText(reportInfoPath);
//}
//.txtファイルに記述する内容(ターゲットファイルとリファレンスファイル名)
textContent += "**PDF_REF_NAME: \"" + targetPDF + ".pdf\"\r\n";
textContent += "**PDF_TAR_NAME: \"" + targetPDF + ".pdf\"\r\n";
//ページ数を取得
string[] referenceTiff = System.IO.Directory.GetFiles(RefTiffpath, targetPDF + ".pdf*.tiff", System.IO.SearchOption.TopDirectoryOnly);
string referenceAllPage = referenceTiff.Length.ToString();
textContent += "**PDF_REF_PAGE_NUM: \"" + referenceAllPage + "\"\r\n";
string[] targetTiff = System.IO.Directory.GetFiles(TarTiffPath, targetPDF + ".pdf*.tiff", System.IO.SearchOption.TopDirectoryOnly);
string targetAllPage = targetTiff.Length.ToString();
textContent += "**PDF_TAR_PAGE_NUM: \"" + targetAllPage + "\"\r\n";
// StreamWriterオブジェクトのインスタンスを生成
using (StreamWriter streamWriter = new StreamWriter(reportInfoPath, false, Encoding.GetEncoding("Shift_JIS")))
{
// Writeメソッドで文字列データを書き込む
streamWriter.Write(textContent);
// StreamWriterオブジェクトを閉じる
streamWriter.Close();
}
return reportInfoPath;
}
/// <summary>
/// 生成したレポート内容参照先txtファイルを全削除(次回に残さない)
/// </summary>
private void deleteReportTexts()
{
// .txtのパス
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得
string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得
string outInfoPath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "work", "OUT_INFO", "ReportInf");
//ディレクトリ内のファイルを全て取得して全て削除
DirectoryInfo reportTextDir = new DirectoryInfo(outInfoPath);
FileInfo[] deleteTextFles = reportTextDir.GetFiles();
foreach (FileInfo deleteTxt in deleteTextFles)
{
deleteTxt.Delete();
}
}
/// <summary>
/// レポートの出力内容を編集する
/// </summary>
private string getReportInfo(string allRipTime, string workBox)
{
// exeのパス
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得
//対象フォルダの内容
string tarTiffDir = System.IO.Path.Combine(workBox, "work", "targetTIFF");
//PDFの数
string[] targetPDFs = getPDFName(targetBox.Text);
string targetNum = targetPDFs.Length.ToString();
//PDFの名前一覧
/*
string allTargetName = "";
for (int i = 0; i < targetPDFs.Length; i++)
{
if (i > 0)
{
allTargetName += ",";
}
allTargetName += System.IO.Path.GetFileName(targetPDFs[i]);
}
*/
//PDFのページ数
string targetAllPage = getPDFPage(targetPDFs, tarTiffDir);
//リファレンスフォルダの内容
string refTiffDir = System.IO.Path.Combine(workBox, "work", "referenceTIFF");
//PDFの数
string[] referencePDFs = getPDFName(referenceBox.Text);
string referenceNum = referencePDFs.Length.ToString();
//PDFの名前一覧
/*
string allReferenceName = "";
for (int i = 0; i < referencePDFs.Length; i++)
{
if (i > 0)
{
allReferenceName += ",";
}
allReferenceName += System.IO.Path.GetFileName(referencePDFs[i]);
}
*/
//PDFのページ数
string referenceAllPage = getPDFPage(referencePDFs, refTiffDir);
//.txtファイルに記述する内容
string writeText = "**RESULT_RIP_TIME: \"" + allRipTime + "\"\r\n";
writeText += "**ENV_VERSION: \"CSRender Ver 0.3.0\"\r\n";
writeText += "**ENV_RIPVERIFY_PATH: \"" + appPath + "\"\r\n";
writeText += "**ENV_RIP_PROCESSING: \"PDFium\"\r\n";
writeText += "**ENV_IMAGE_RESO: \"" + ResolutionBox.Text + "\"\r\n";
if (PageRange.Text == "指定")
{
writeText += "**ENV_INSPECTION_AREA_SPECIFY: \"" + pageBox.Text + "\"\r\n";
}
else
{
writeText += "**ENV_INSPECTION_AREA_SPECIFY: \"ALL\"\r\n";
}
writeText += "**PDF_REF_FOLDER: \"" + referenceBox.Text + "\"\r\n";
writeText += "**PDF_REF_FILE_NUM: \"" + referenceNum + "\"\r\n";
//writeText += "**PDF_REF_NAME: \"" + allReferenceName + "\"\r\n";
//writeText += "**PDF_REF_PAGE_NUM: \"" + referenceAllPage + "\"\r\n";
writeText += "**PDF_TAR_FOLDER: \"" + targetBox.Text + "\"\r\n";
writeText += "**PDF_TAR_FILE_NUM: \"" + targetNum + "\"\r\n";
//writeText += "**PDF_TAR_NAME: \"" + allTargetName + "\"\r\n";
//writeText += "**PDF_TAR_PAGE_NUM: \"" + targetAllPage + "\"\r\n";
//string eachWriteTxet = writeText;
return writeText;
}
/// <summary>
/// レポートの出力内容を編集する
/// </summary>
private void editReport(string allRipTime, string workBox)
{
// .txtのパス
string appPath = System.Reflection.Assembly.GetExecutingAssembly().Location; //モジュールのパスを取得
string appDirectory = appPath.Substring(0, appPath.LastIndexOf(@"\") + 1); //モジュールの存在するディレクトリを取得
string outInfoPath = System.IO.Path.Combine("PureVerify.Data", "RipVerify", "work", "OUT_INFO");
outInfoPath = System.IO.Path.Combine(appDirectory, outInfoPath);
if (!Directory.Exists(outInfoPath))
{
Directory.CreateDirectory(outInfoPath);
}
string reportInfoPath = System.IO.Path.Combine(outInfoPath, "CSReportInf.txt");
if (!File.Exists(reportInfoPath))
{
File.CreateText(reportInfoPath);
}
//対象フォルダの内容
string tarTiffDir = System.IO.Path.Combine(workBox, "work", "targetTIFF");
//PDFの数
string[] targetPDFs = getPDFName(targetBox.Text);
string targetNum = targetPDFs.Length.ToString();
//PDFの名前一覧
string allTargetName = "";
for (int i = 0; i < targetPDFs.Length; i++)
{
if (i > 0)
{
allTargetName += ",";
}
allTargetName += System.IO.Path.GetFileName(targetPDFs[i]);
}
//PDFのページ数
string targetAllPage = getPDFPage(targetPDFs, tarTiffDir);
//リファレンスフォルダの内容
string refTiffDir = System.IO.Path.Combine(workBox, "work", "referenceTIFF");
//PDFの数
string[] referencePDFs = getPDFName(referenceBox.Text);
string referenceNum = referencePDFs.Length.ToString();
//PDFの名前一覧
string allReferenceName = "";
for (int i = 0; i < referencePDFs.Length; i++)
{
if (i > 0)
{
allReferenceName += ",";
}
allReferenceName += System.IO.Path.GetFileName(referencePDFs[i]);
}
//PDFのページ数
string referenceAllPage = getPDFPage(referencePDFs, refTiffDir);
//.txtファイルに記述する内容
string writeText = "**RESULT_RIP_TIME: \"" + allRipTime + "\"\r\n";
writeText += "**ENV_VERSION: \"CSRender Ver 0.3.0\"\r\n";
writeText += "**ENV_RIPVERIFY_PATH: \"" + appPath + "\"\r\n";
writeText += "**ENV_RIP_PROCESSING: \"PDFium\"\r\n";
writeText += "**ENV_IMAGE_RESO: \"" + ResolutionBox.Text + "\"\r\n";
if (PageRange.Text == "指定")
{
writeText += "**ENV_INSPECTION_AREA_SPECIFY: \"" + pageBox.Text + "\"\r\n";
}
else
{
writeText += "**ENV_INSPECTION_AREA_SPECIFY: \"ALL\"\r\n";
}
writeText += "**PDF_REF_FOLDER: \"" + referenceBox.Text + "\"\r\n";
writeText += "**PDF_REF_FILE_NUM: \"" + referenceNum + "\"\r\n";
//writeText += "**PDF_REF_NAME: \"" + allReferenceName + "\"\r\n";
writeText += "**PDF_REF_PAGE_NUM: \"" + referenceAllPage + "\"\r\n";
writeText += "**PDF_TAR_FOLDER: \"" + targetBox.Text + "\"\r\n";
writeText += "**PDF_TAR_FILE_NUM: \"" + targetNum + "\"\r\n";
//writeText += "**PDF_TAR_NAME: \"" + allTargetName + "\"\r\n";
writeText += "**PDF_TAR_PAGE_NUM: \"" + targetAllPage + "\"\r\n";
string eachWriteTxet = writeText;
writeText += "**PDF_REF_NAME: \"" + allReferenceName + "\"\r\n";
writeText += "**PDF_TAR_NAME: \"" + allTargetName + "\"\r\n";
// StreamWriterオブジェクトのインスタンスを生成
StreamWriter streamWriter = new StreamWriter(reportInfoPath, false, Encoding.GetEncoding("Shift_JIS"));
// Writeメソッドで文字列データを書き込む
streamWriter.Write(writeText);
// StreamWriterオブジェクトを閉じる
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>
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>
/// ダミーのPDFファイルを作成する
/// </summary>
private string createDummyFile(string inTargetPath, string inDummyDir, string inFileName)
{
string TargetDir = System.IO.Path.GetDirectoryName(inTargetPath);//ファイルパスを取得
string TargetFile = System.IO.Path.GetFileName(inTargetPath);//ファイル名を取得
if(inFileName == "")//名前が空ならパスから取得した名前を代入
private void resetProgressText(int allPDFNum)
{
inFileName = TargetFile;
}
File.Copy(inTargetPath, System.IO.Path.Combine(inDummyDir, inFileName), true);
return inFileName;
}
//隠しメニューの数値を初期化
allNumBox.Text = allPDFNum.ToString();
NGNumBox.Text = "0";
OKNumBox.Text = "0";
/// <summary>
/// ダミーのPDFファイルを削除する
/// </summary>
private void deleteDummyFile(string inDummyPath, string inDummyName)
{
File.Delete(System.IO.Path.Combine(inDummyPath, inDummyName));
//出力メニューの表示を更新
ResultConsole.Text += "< 検版処理状況 >";
ResultConsole.Text += "\r\n 処理待ち数:";
ResultConsole.Text += allPDFNum.ToString() + "/" + allPDFNum.ToString();
ResultConsole.Text += "\r\n OKファイル数:0";
ResultConsole.Text += "\r\n NGファイル数:0\r\n";
ResultConsole.ScrollToEnd();
}
/// <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