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
9dc65c09
Commit
9dc65c09
authored
Mar 23, 2022
by
tsuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
コンソールを非表示化し、作業進捗をメニューへ表示するように修正
parent
2c78b201
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
147 additions
and
23 deletions
+147
-23
CompareTIFF.cs
Code/CSRender/CSRender/CompareTIFF.cs
+46
-6
MainWindow.xaml
Code/CSRender/CSRender/MainWindow.xaml
+4
-1
MainWindow.xaml.cs
Code/CSRender/CSRender/MainWindow.xaml.cs
+97
-16
No files found.
Code/CSRender/CSRender/CompareTIFF.cs
View file @
9dc65c09
...
...
@@ -21,7 +21,7 @@ namespace CSRender
{
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
reportName
,
string
inDiffPath
,
string
inTargetFileName
,
DateTime
inDateTime
,
string
inReportInfo
)
{
...
...
@@ -91,7 +91,7 @@ namespace CSRender
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
);
processStartInfo
.
Arguments
+=
"/inspReport \""
;
processStartInfo
.
Arguments
+=
TargetName
;
...
...
@@ -120,15 +120,23 @@ namespace CSRender
//processStartInfo.Arguments += System.IO.Path.Combine(appDirectory, textPath);
processStartInfo
.
Arguments
+=
reportInfoPath
;
//コンソールへの出力を制御
processStartInfo
.
Arguments
+=
" /consoleOut "
;
processStartInfo
.
Arguments
+=
"2"
;
//0:新規のコンソールに出力、1:親コンソールに出力(無い場合は新規に)、2:NULLコンソールに出力
//CSRender.exeを実行
Process
process
=
Process
.
Start
(
processStartInfo
);
process
.
BeginOutputReadLine
();
process
.
WaitForExit
();
process
.
Close
();
//NGの含まれる場合レポート名の頭に【NG】を付与
//NGの数を取得
int
[]
NGOfThisFile
=
getNgOfPDF
(
logFileName
);
//NGの含まれる場合レポート名の頭に【NG_】を付与
NGReportName
(
TargetName
,
reportName
);
return
NGOfThisFile
.
ToArray
();
}
//指定先にレポートを移動
...
...
@@ -171,8 +179,10 @@ namespace CSRender
{
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
);
File
.
Copy
(
oldPathName
,
System
.
IO
.
Path
.
Combine
(
inReportPath
,
"
【NG】"
+
oldFil
e
),
true
);
File
.
Copy
(
oldPathName
,
System
.
IO
.
Path
.
Combine
(
inReportPath
,
"
NG_"
+
oldNGNam
e
),
true
);
File
.
Delete
(
oldPathName
);
}
}
...
...
@@ -181,11 +191,41 @@ namespace CSRender
foreach
(
var
beforePathName
in
OKreportFileName
)
{
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
);
}
}
}
//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
();
}
}
}
Code/CSRender/CSRender/MainWindow.xaml
View file @
9dc65c09
...
...
@@ -77,7 +77,7 @@
<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"
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="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"/>
...
...
@@ -115,5 +115,8 @@
</WindowsFormsHost>
</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>
</Window>
Code/CSRender/CSRender/MainWindow.xaml.cs
View file @
9dc65c09
...
...
@@ -103,7 +103,7 @@ namespace CSRender
/// <param name="reportFlag">PureVerify実行の際にレポート名の引数を加えるかどうかを示すフラグ</param>
/// <param name="pdfReportPath">検版レポートの出力先パス</param>
private
void
CompareButtonClick
(
object
sender
,
RoutedEventArgs
e
)
private
async
void
CompareButtonClick
(
object
sender
,
RoutedEventArgs
e
)
{
killButton
();
...
...
@@ -240,9 +240,12 @@ namespace CSRender
//CSRenderの実行
try
{
await
Task
.
Run
(()
=>
{
string
targetTIFFResult
=
OutputTIFF
.
runCSRender
(
ResolutionBox
.
Text
,
"TIFF"
,
pageFlag
,
selectedPage
,
targetBoxText
,
targetTIFFPath
);
});
}
catch
(
Exception
ex
)
{
...
...
@@ -270,9 +273,12 @@ namespace CSRender
//CSRenderの実行
try
{
await
Task
.
Run
(()
=>
{
string
referenceTIFFResult
=
OutputTIFF
.
runCSRender
(
ResolutionBox
.
Text
,
"TIFF"
,
pageFlag
,
selectedPage
,
referenceBoxText
,
referenceTIFFPath
);
});
}
catch
(
Exception
ex
)
{
...
...
@@ -316,17 +322,32 @@ namespace CSRender
string
workDir
=
""
;
int
allPDFNum
=
0
;
int
NGPDFNum
=
0
;
//この時点での出力文字列を取得
string
tiffString
=
ResultConsole
.
Text
;
try
{
// 日付取得
DateTime
NowTime
=
DateTime
.
Now
;
//検版対象ファイル名の取得
string
[]
inspectionTargets
=
GetTargetList
(
targetBoxText
,
referenceBoxText
);
allPDFNum
=
inspectionTargets
.
Length
;
allPDFNum
=
getNumOfTiff
(
inspectionTargets
,
targetTIFFPath
);
//検版する画像ファイルの総数
string
appPath
=
System
.
Reflection
.
Assembly
.
GetExecutingAssembly
().
Location
;
//モジュールのパスを取得
string
appDirectory
=
appPath
.
Substring
(
0
,
appPath
.
LastIndexOf
(
@"\"
)
+
1
);
//モジュールの存在するディレクトリを取得
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
.
MaxDegreeOfParallelism
=
4
;
// 並行数(プロセス数)
...
...
@@ -336,12 +357,19 @@ namespace CSRender
parallelOptions
.
MaxDegreeOfParallelism
=
logicalProcessNum
-
4
;
}
await
Task
.
Factory
.
StartNew
(()
=>
{
Parallel
.
ForEach
(
inspectionTargets
,
parallelOptions
,
targetPDFName
=>
{
//PureVerifyの実行
CompareTIFF
.
runPureVerify
(
targetTIFFPath
,
referenceTIFFPath
,
workBoxText
int
[]
NGTiffNum
=
CompareTIFF
.
runPureVerify
(
targetTIFFPath
,
referenceTIFFPath
,
workBoxText
,
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
//レポートを出力
//outputLog(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
)
{
...
...
@@ -526,6 +555,7 @@ namespace CSRender
string
[]
reportFiles
=
System
.
IO
.
Directory
.
GetFiles
(
workDir
,
"*.pdf.log"
,
System
.
IO
.
SearchOption
.
TopDirectoryOnly
);
foreach
(
var
logfileName
in
reportFiles
)
{
/*
string tranceString = File.ReadLines(logfileName, Encoding.GetEncoding("Shift-JIS")).Skip(16).First();//16行目を抽出
tranceString = tranceString.Replace("NG", "");//不要な部分をカット
tranceString = tranceString.Replace(":", "");
...
...
@@ -540,16 +570,52 @@ namespace CSRender
{
NumOfThisFile = 0;
}
NGFileNum
+=
NumOfThisFile
;
*/
int
[]
NumOfThisFile
=
CompareTIFF
.
getNgOfPDF
(
logfileName
);
int
NumOfThisNG
=
NumOfThisFile
[
0
];
NGFileNum
+=
NumOfThisNG
;
}
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>
/// UIに検版結果を出力する
/// </summary>
private
void
outResul
e
tToUI
(
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
);
//画像数
...
...
@@ -557,7 +623,7 @@ namespace CSRender
int
OKPDFNum
=
inAllPDFNum
-
inNGPDFNum
;
//OKの数
//検版結果を出力
ResultConsole
.
Text
+=
"< 検版結果 >\r\n"
;
ResultConsole
.
Text
+=
"
\r\n
< 検版結果 >\r\n"
;
ResultConsole
.
Text
+=
" リファレンスPDFパス:"
;
ResultConsole
.
Text
+=
referenceBox
.
Text
;
ResultConsole
.
Text
+=
"\r\n リファレンス画像ファイル数:"
;
...
...
@@ -899,6 +965,21 @@ namespace CSRender
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>
...
...
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