Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KenPanCS
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QCD
Tools
KenPanCS
Commits
a52bae97
Commit
a52bae97
authored
Apr 06, 2022
by
tsuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UI部分のコードと処理部分のコードを分離
parent
7d7ee434
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
274 additions
and
380 deletions
+274
-380
CompareTIFF.cs
Code/CSRender/CSRender/CompareTIFF.cs
+249
-8
FilePathSelect.cs
Code/CSRender/CSRender/FilePathSelect.cs
+2
-2
MainWindow.xaml.cs
Code/CSRender/CSRender/MainWindow.xaml.cs
+23
-370
No files found.
Code/CSRender/CSRender/CompareTIFF.cs
View file @
a52bae97
...
@@ -21,7 +21,7 @@ namespace CSRender
...
@@ -21,7 +21,7 @@ namespace CSRender
{
{
class
CompareTIFF
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
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
,
string
inAppDir
,
string
inExePath
,
string
inVerifyArg
)
string
inAppDir
,
string
inExePath
,
string
inVerifyArg
)
...
@@ -34,7 +34,7 @@ namespace CSRender
...
@@ -34,7 +34,7 @@ namespace CSRender
//レポートに書き込む情報を編集
//レポートに書き込む情報を編集
inTargetFileName
=
System
.
IO
.
Path
.
GetFileNameWithoutExtension
(
inTargetFileName
);
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
;
processStartInfo
.
Arguments
=
inVerifyArg
;
...
@@ -95,7 +95,7 @@ namespace CSRender
...
@@ -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
)
string
colorMargin
,
string
removePoint
,
string
shadingOff
,
string
inAppDir
)
{
{
//指定ファイル
//指定ファイル
...
@@ -144,7 +144,7 @@ namespace CSRender
...
@@ -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"
);
string
reportPath
=
System
.
IO
.
Path
.
Combine
(
resultPath
,
"report"
,
"Log"
);
if
(!
Directory
.
Exists
(
reportPath
))
//指定先にreportフォルダがあるか
if
(!
Directory
.
Exists
(
reportPath
))
//指定先にreportフォルダがあるか
...
@@ -162,7 +162,7 @@ namespace CSRender
...
@@ -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"
)
string
[]
reportFilePath
=
System
.
IO
.
Directory
.
GetFiles
(
System
.
IO
.
Path
.
Combine
(
workPath
,
"report"
)
,
"*.pdf"
,
System
.
IO
.
SearchOption
.
TopDirectoryOnly
);
//レポートファイルのパスを取得
,
"*.pdf"
,
System
.
IO
.
SearchOption
.
TopDirectoryOnly
);
//レポートファイルのパスを取得
...
@@ -172,7 +172,7 @@ namespace CSRender
...
@@ -172,7 +172,7 @@ namespace CSRender
}
}
//NGの含まれる検版レポート名を編集
//NGの含まれる検版レポート名を編集
public
static
void
NGReportName
(
string
inTargetName
,
string
inReportPath
)
internal
static
void
NGReportName
(
string
inTargetName
,
string
inReportPath
)
{
{
//string searchName = "report_" + inTargetName;
//string searchName = "report_" + inTargetName;
string
searchfile
=
System
.
IO
.
Path
.
GetFileNameWithoutExtension
(
inTargetName
)
+
"&*"
;
string
searchfile
=
System
.
IO
.
Path
.
GetFileNameWithoutExtension
(
inTargetName
)
+
"&*"
;
...
@@ -202,7 +202,7 @@ namespace CSRender
...
@@ -202,7 +202,7 @@ namespace CSRender
}
}
//NG画像の数を取得
//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行目を抽出
string
tranceNGString
=
File
.
ReadLines
(
inLogPath
,
Encoding
.
GetEncoding
(
"Shift-JIS"
)).
Skip
(
16
).
First
();
//17行目を抽出
tranceNGString
=
tranceNGString
.
Replace
(
"NG"
,
""
);
//不要な部分をカット
tranceNGString
=
tranceNGString
.
Replace
(
"NG"
,
""
);
//不要な部分をカット
...
@@ -232,7 +232,7 @@ namespace CSRender
...
@@ -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
())
if
(
System
.
IO
.
Directory
.
EnumerateFileSystemEntries
(
inLogPath
).
Any
())
{
{
...
@@ -244,5 +244,246 @@ namespace CSRender
...
@@ -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
));
}
}
}
}
}
Code/CSRender/CSRender/FilePathSelect.cs
View file @
a52bae97
...
@@ -307,8 +307,8 @@ namespace CSRender
...
@@ -307,8 +307,8 @@ namespace CSRender
string
dummyRefDir
=
System
.
IO
.
Path
.
Combine
(
dummyDir
,
"Reference"
);
string
dummyRefDir
=
System
.
IO
.
Path
.
Combine
(
dummyDir
,
"Reference"
);
if
(!
Directory
.
Exists
(
dummyRefDir
))
{
Directory
.
CreateDirectory
(
dummyRefDir
);
}
if
(!
Directory
.
Exists
(
dummyRefDir
))
{
Directory
.
CreateDirectory
(
dummyRefDir
);
}
//ダミーファイルを作成
//ダミーファイルを作成
dummyFileName
=
createDummyFile
(
targetBoxText
,
dummyTarDir
,
dummyFileName
);
dummyFileName
=
CompareTIFF
.
createDummyFile
(
targetBoxText
,
dummyTarDir
,
dummyFileName
);
dummyFileName
=
createDummyFile
(
referenceBoxText
,
dummyRefDir
,
dummyFileName
);
dummyFileName
=
CompareTIFF
.
createDummyFile
(
referenceBoxText
,
dummyRefDir
,
dummyFileName
);
dummyFlag
=
true
;
dummyFlag
=
true
;
//検版対象をダミーに指定
//検版対象をダミーに指定
targetBoxText
=
dummyTarDir
;
targetBoxText
=
dummyTarDir
;
...
...
Code/CSRender/CSRender/MainWindow.xaml.cs
View file @
a52bae97
...
@@ -274,7 +274,8 @@ namespace CSRender
...
@@ -274,7 +274,8 @@ namespace CSRender
{
{
//レポートへの出力内容を編集
//レポートへの出力内容を編集
//editReport(allRipTime, workBoxText);
//editReport(allRipTime, workBoxText);
reportContentsInfo
=
getReportInfo
(
allRipTime
,
workBoxText
);
reportContentsInfo
=
CompareTIFF
.
getReportInfo
(
allRipTime
,
workBoxText
,
targetBoxText
,
referenceBoxText
,
ResolutionBox
.
Text
,
PageRange
.
Text
,
pageBox
.
Text
);
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
...
@@ -289,22 +290,12 @@ namespace CSRender
...
@@ -289,22 +290,12 @@ namespace CSRender
// 日付取得
// 日付取得
DateTime
NowTime
=
DateTime
.
Now
;
DateTime
NowTime
=
DateTime
.
Now
;
//検版対象ファイル名の取得
//検版対象ファイル名の取得
string
[]
inspectionTargets
=
GetTargetList
(
targetBoxText
,
referenceBoxText
);
string
[]
inspectionTargets
=
CompareTIFF
.
GetTargetList
(
targetBoxText
,
referenceBoxText
);
allPDFNum
=
getNumOfTiff
(
inspectionTargets
,
targetTIFFPath
);
//検版する画像ファイルの総数
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
();
ParallelOptions
parallelOptions
=
new
ParallelOptions
();
parallelOptions
.
MaxDegreeOfParallelism
=
4
;
// 並行数(プロセス数)
parallelOptions
.
MaxDegreeOfParallelism
=
4
;
// 並行数(プロセス数)
...
@@ -344,7 +335,7 @@ namespace CSRender
...
@@ -344,7 +335,7 @@ 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
=
CompareTIFF
.
getNGNum
(
System
.
IO
.
Path
.
Combine
(
workDir
,
"report"
));
ResultConsole
.
Text
=
tiffString
;
ResultConsole
.
Text
=
tiffString
;
outResultToUI
(
allPDFNum
,
NGPDFNum
,
referenceTIFFPath
,
targetTIFFPath
);
outResultToUI
(
allPDFNum
,
NGPDFNum
,
referenceTIFFPath
,
targetTIFFPath
);
}
}
...
@@ -401,13 +392,13 @@ namespace CSRender
...
@@ -401,13 +392,13 @@ namespace CSRender
}
}
//生成したレポートinf.txtを全削除
//生成したレポートinf.txtを全削除
deleteReportTexts
();
CompareTIFF
.
deleteReportTexts
();
//生成したダミーファイルを削除
//生成したダミーファイルを削除
if
(
dummyFlag
)
if
(
dummyFlag
)
{
{
deleteDummyFile
(
System
.
IO
.
Path
.
Combine
(
workBoxText
,
"Dummy"
,
"Target"
),
dummyFileName
);
CompareTIFF
.
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"
,
"Reference"
),
dummyFileName
);
}
}
//パラメータを次回初期値用に保存
//パラメータを次回初期値用に保存
...
@@ -482,26 +473,6 @@ namespace CSRender
...
@@ -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>
/// <summary>
/// UIに途中経過を出力する
/// UIに途中経過を出力する
/// </summary>
/// </summary>
...
@@ -584,345 +555,27 @@ namespace CSRender
...
@@ -584,345 +555,27 @@ namespace CSRender
ResultConsole
.
Text
+=
"\r\n NG-完全一致検版:0"
;
ResultConsole
.
Text
+=
"\r\n NG-完全一致検版:0"
;
ResultConsole
.
Text
+=
"\r\n NG-ゆすらせ検版:"
;
ResultConsole
.
Text
+=
"\r\n NG-ゆすらせ検版:"
;
ResultConsole
.
Text
+=
inNGPDFNum
.
ToString
();
ResultConsole
.
Text
+=
inNGPDFNum
.
ToString
();
ResultConsole
.
Text
+=
"\r\n< 検版終了 >\r\n"
;
ResultConsole
.
Text
+=
"\r\n< 検版終了 >\r\n"
;
ResultConsole
.
ScrollToEnd
();
ResultConsole
.
ScrollToEnd
();
DoEvents
();
DoEvents
();
//string logfileName = reportFiles[0];
//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>
private
void
resetProgressText
(
int
allPDFNum
)
/// 検版する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"
);
allNumBox
.
Text
=
allPDFNum
.
ToString
();
outInfoPath
=
System
.
IO
.
Path
.
Combine
(
inAppDir
,
outInfoPath
);
NGNumBox
.
Text
=
"0"
;
if
(!
Directory
.
Exists
(
outInfoPath
))
OKNumBox
.
Text
=
"0"
;
{
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ファイルを全削除(次回に残さない)
ResultConsole
.
Text
+=
"< 検版処理状況 >"
;
/// </summary>
ResultConsole
.
Text
+=
"\r\n 処理待ち数:"
;
private
void
deleteReportTexts
()
ResultConsole
.
Text
+=
allPDFNum
.
ToString
()
+
"/"
+
allPDFNum
.
ToString
();
{
ResultConsole
.
Text
+=
"\r\n OKファイル数:0"
;
// .txtのパス
ResultConsole
.
Text
+=
"\r\n NGファイル数:0\r\n"
;
string
appPath
=
System
.
Reflection
.
Assembly
.
GetExecutingAssembly
().
Location
;
//モジュールのパスを取得
ResultConsole
.
ScrollToEnd
();
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
==
""
)
//名前が空ならパスから取得した名前を代入
{
inFileName
=
TargetFile
;
}
File
.
Copy
(
inTargetPath
,
System
.
IO
.
Path
.
Combine
(
inDummyDir
,
inFileName
),
true
);
return
inFileName
;
}
/// <summary>
/// ダミーのPDFファイルを削除する
/// </summary>
private
void
deleteDummyFile
(
string
inDummyPath
,
string
inDummyName
)
{
File
.
Delete
(
System
.
IO
.
Path
.
Combine
(
inDummyPath
,
inDummyName
));
}
}
/// <summary>
/// <summary>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment