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
c6d00bcc
Commit
c6d00bcc
authored
Dec 17, 2021
by
tsuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
・例外処理を追加
・例外処理の検証で発見した不具合を修正
parent
0a6b9a61
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
150 additions
and
20 deletions
+150
-20
FilePathSelect.cs
Code/CSRender/CSRender/FilePathSelect.cs
+35
-3
MainWindow.xaml.cs
Code/CSRender/CSRender/MainWindow.xaml.cs
+108
-16
PageComboBox.cs
Code/CSRender/CSRender/PageComboBox.cs
+7
-1
No files found.
Code/CSRender/CSRender/FilePathSelect.cs
View file @
c6d00bcc
...
@@ -63,7 +63,10 @@ namespace CSRender
...
@@ -63,7 +63,10 @@ namespace CSRender
workBox
.
Text
=
dropFiles
[
0
];
workBox
.
Text
=
dropFiles
[
0
];
workBox
.
Focus
();
workBox
.
Focus
();
workBox
.
Select
(
this
.
workBox
.
Text
.
Length
,
0
);
workBox
.
Select
(
this
.
workBox
.
Text
.
Length
,
0
);
if
(!
Directory
.
Exists
(
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
)))
{
Directory
.
CreateDirectory
(
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
));
}
}
}
private
void
ReportBox_Drop
(
object
sender
,
System
.
Windows
.
DragEventArgs
e
)
private
void
ReportBox_Drop
(
object
sender
,
System
.
Windows
.
DragEventArgs
e
)
...
@@ -125,6 +128,10 @@ namespace CSRender
...
@@ -125,6 +128,10 @@ namespace CSRender
}
}
//共通部分
//共通部分
workBox
.
Text
=
selectFile
.
FileName
;
workBox
.
Text
=
selectFile
.
FileName
;
if
(!
Directory
.
Exists
(
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") + @"\";
}
}
...
@@ -187,10 +194,11 @@ namespace CSRender
...
@@ -187,10 +194,11 @@ namespace CSRender
directoryCount
=
reportBox
.
Text
.
Split
(
char
.
Parse
(
@"\"
)).
Length
-
1
;
//入力文字列がファイル名のみかディレクトリも含むか
directoryCount
=
reportBox
.
Text
.
Split
(
char
.
Parse
(
@"\"
)).
Length
-
1
;
//入力文字列がファイル名のみかディレクトリも含むか
if
(
directoryCount
==
0
)
//ファイル名のみならば作業ディレクトリのreportフォルダに出力
if
(
directoryCount
==
0
)
//ファイル名のみならば作業ディレクトリのreportフォルダに出力
{
{
reportBox
.
Text
=
NameCalibration
(
reportBox
.
Text
);
reportBox
.
Text
=
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
,
reportBox
.
Text
);
reportBox
.
Text
=
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
,
reportBox
.
Text
);
}
}
pdfReportPath
=
reportBox
.
Text
.
Substring
(
0
,
reportBox
.
Text
.
LastIndexOf
(
@"\"
));
//メニュー入力から出力パスを取得
pdfReportPath
=
reportBox
.
Text
.
Substring
(
0
,
reportBox
.
Text
.
LastIndexOf
(
@"\"
));
//メニュー入力から出力パスを取得
pdfReportName
=
reportBox
.
Text
.
Substring
(
reportBox
.
Text
.
LastIndexOf
(
@"\"
));
//メニュー入力から
出力パス
を取得
pdfReportName
=
reportBox
.
Text
.
Substring
(
reportBox
.
Text
.
LastIndexOf
(
@"\"
));
//メニュー入力から
レポートファイル名
を取得
if
(!
System
.
IO
.
Path
.
IsPathRooted
(
pdfReportPath
))
//指定したパス文字列にルートが含まれているかどうか
if
(!
System
.
IO
.
Path
.
IsPathRooted
(
pdfReportPath
))
//指定したパス文字列にルートが含まれているかどうか
{
{
pdfReportPath
=
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
,
pdfReportPath
);
//含まれていなければ作業フォルダのreportフォルダに出力
pdfReportPath
=
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
,
pdfReportPath
);
//含まれていなければ作業フォルダのreportフォルダに出力
...
@@ -200,6 +208,10 @@ namespace CSRender
...
@@ -200,6 +208,10 @@ namespace CSRender
Directory
.
CreateDirectory
(
pdfReportPath
);
//なければ作成
Directory
.
CreateDirectory
(
pdfReportPath
);
//なければ作成
}
}
pdfReportPath
=
System
.
IO
.
Path
.
GetFullPath
(
pdfReportPath
);
//フルパスを取得
pdfReportPath
=
System
.
IO
.
Path
.
GetFullPath
(
pdfReportPath
);
//フルパスを取得
//レポートファイル名に不正文字が使用されいないかチェック
pdfReportName
=
NameCalibration
(
pdfReportName
);
if
(
pdfReportName
.
Length
<
4
||
pdfReportName
.
Substring
(
pdfReportName
.
Length
-
4
)
!=
".pdf"
)
//入力に拡張子がついているか
if
(
pdfReportName
.
Length
<
4
||
pdfReportName
.
Substring
(
pdfReportName
.
Length
-
4
)
!=
".pdf"
)
//入力に拡張子がついているか
{
{
pdfReportName
+=
".pdf"
;
pdfReportName
+=
".pdf"
;
...
@@ -209,5 +221,25 @@ namespace CSRender
...
@@ -209,5 +221,25 @@ namespace CSRender
}
}
return
reportFlag
;
return
reportFlag
;
}
}
//レポート名に使用不可の文字が含まれている場合の処理
private
string
NameCalibration
(
string
inFileName
)
{
string
[]
charsToRemove
=
new
string
[]
{
"/"
,
":"
,
"*"
,
"?"
,
"<"
,
">"
,
"|"
};
char
[]
charsTocheck
=
new
char
[]
{
'/'
,
':'
,
'*'
,
'?'
,
'<'
,
'>'
,
'|'
};
if
(
inFileName
.
IndexOfAny
(
charsTocheck
)
>=
0
)
{
foreach
(
var
allNg
in
charsToRemove
)
{
inFileName
=
inFileName
.
Replace
(
allNg
,
string
.
Empty
);
}
ResultConsole
.
Text
+=
" 検版レポート名に使用できない文字が含まれていたため、自動修正しました。"
;
ResultConsole
.
Text
+=
"\r\n\r\n"
;
DoEvents
();
}
return
inFileName
;
}
}
}
}
}
Code/CSRender/CSRender/MainWindow.xaml.cs
View file @
c6d00bcc
...
@@ -132,7 +132,7 @@ namespace CSRender
...
@@ -132,7 +132,7 @@ namespace CSRender
if
(!
Directory
.
Exists
(
workBox
.
Text
)
&&
!
File
.
Exists
(
workBox
.
Text
))
if
(!
Directory
.
Exists
(
workBox
.
Text
)
&&
!
File
.
Exists
(
workBox
.
Text
))
{
{
CustomMsgBox
.
Show
(
mainWindow
,
"指定された作業フォルダが存在しません。"
+
CustomMsgBox
.
Show
(
mainWindow
,
"指定された作業フォルダが存在しません。"
+
"\nもう一度設定してください。"
,
"The
specified reference file or
folder does not exist"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Information
);
"\nもう一度設定してください。"
,
"The
work space
folder does not exist"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Information
);
ResultConsole
.
Text
+=
" 指定された作業フォルダを発見できませんでした\r\n"
;
ResultConsole
.
Text
+=
" 指定された作業フォルダを発見できませんでした\r\n"
;
ResultConsole
.
Text
+=
"<TIFF変換中止>\r\n"
;
ResultConsole
.
Text
+=
"<TIFF変換中止>\r\n"
;
workBox
.
Text
=
""
;
workBox
.
Text
=
""
;
...
@@ -140,6 +140,26 @@ namespace CSRender
...
@@ -140,6 +140,26 @@ namespace CSRender
Properties
.
Settings
.
Default
.
Save
();
Properties
.
Settings
.
Default
.
Save
();
return
;
return
;
}
}
string
workLogPath
=
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
);
bool
reportFlag
=
false
;
try
{
//検版レポートの入力チェック
reportFlag
=
checkReportPath
();
}
catch
(
Exception
ex
)
{
CustomMsgBox
.
Show
(
mainWindow
,
ex
.
Message
+
"\r\nレポート名を初期化しました。"
,
"例外が発生しました"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Warning
);
//ログ記述
DateTime
faileTIme
=
DateTime
.
Now
;
string
logText
=
"["
+
faileTIme
+
"]"
+
Environment
.
NewLine
;
logText
+=
"例外の生じた処理:レポート名の確認"
+
Environment
.
NewLine
;
logText
+=
ex
.
Message
+
"\n"
+
ex
.
StackTrace
+
Environment
.
NewLine
;
File
.
AppendAllText
(
System
.
IO
.
Path
.
Combine
(
workLogPath
,
"CSRender.log"
),
logText
);
reportBox
.
Text
=
""
;
//referenceErrorFlag = true;
}
//検版パラメータの取得
//検版パラメータの取得
string
shiftPixel
=
PositionBox
.
Text
;
string
shiftPixel
=
PositionBox
.
Text
;
...
@@ -170,8 +190,22 @@ namespace CSRender
...
@@ -170,8 +190,22 @@ namespace CSRender
Directory
.
CreateDirectory
(
targetTIFFPath
);
//新規でTIFF用フォルダを作成
Directory
.
CreateDirectory
(
targetTIFFPath
);
//新規でTIFF用フォルダを作成
//CSRenderの実行
//CSRenderの実行
try
{
string
targetTIFFResult
=
string
targetTIFFResult
=
OutputTIFF
.
runCSRender
(
ResolutionBox
.
Text
,
"TIFF"
,
pageFlag
,
selectedPage
,
targetBox
.
Text
,
targetTIFFPath
);
OutputTIFF
.
runCSRender
(
ResolutionBox
.
Text
,
"TIFF"
,
pageFlag
,
selectedPage
,
targetBox
.
Text
,
targetTIFFPath
);
}
catch
(
Exception
ex
)
{
CustomMsgBox
.
Show
(
mainWindow
,
ex
.
Message
,
"例外が発生しました"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Warning
);
//ログ記述
DateTime
faileTIme
=
DateTime
.
Now
;
string
logText
=
"["
+
faileTIme
+
"]"
+
Environment
.
NewLine
;
logText
+=
"例外の生じた処理:対象PDFのTIFF画像生成"
+
Environment
.
NewLine
;
logText
+=
ex
.
Message
+
"\n"
+
ex
.
StackTrace
+
Environment
.
NewLine
;
File
.
AppendAllText
(
System
.
IO
.
Path
.
Combine
(
workLogPath
,
"CSRender.log"
),
logText
);
//referenceErrorFlag = true;
}
ResultConsole
.
Text
+=
" リファレンスファイルをTIFF画像に変換中\r\n"
;
ResultConsole
.
Text
+=
" リファレンスファイルをTIFF画像に変換中\r\n"
;
DoEvents
();
DoEvents
();
...
@@ -185,24 +219,66 @@ namespace CSRender
...
@@ -185,24 +219,66 @@ namespace CSRender
Directory
.
CreateDirectory
(
referenceTIFFPath
);
//新規でTIFF用フォルダを作成
Directory
.
CreateDirectory
(
referenceTIFFPath
);
//新規でTIFF用フォルダを作成
//CSRenderの実行
//CSRenderの実行
try
{
string
referenceTIFFResult
=
string
referenceTIFFResult
=
OutputTIFF
.
runCSRender
(
ResolutionBox
.
Text
,
"TIFF"
,
pageFlag
,
selectedPage
,
referenceBox
.
Text
,
referenceTIFFPath
);
OutputTIFF
.
runCSRender
(
ResolutionBox
.
Text
,
"TIFF"
,
pageFlag
,
selectedPage
,
referenceBox
.
Text
,
referenceTIFFPath
);
}
catch
(
Exception
ex
)
{
CustomMsgBox
.
Show
(
mainWindow
,
ex
.
Message
,
"例外が発生しました"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Warning
);
//ログ記述
DateTime
faileTIme
=
DateTime
.
Now
;
string
logText
=
"["
+
faileTIme
+
"]"
+
Environment
.
NewLine
;
logText
+=
"例外の生じた処理:リファレンスPDFのTIFF画像生成"
+
Environment
.
NewLine
;
logText
+=
ex
.
Message
+
"\n"
+
ex
.
StackTrace
+
Environment
.
NewLine
;
File
.
AppendAllText
(
System
.
IO
.
Path
.
Combine
(
workLogPath
,
"CSRender.log"
),
logText
);
//referenceErrorFlag = true;
}
ResultConsole
.
Text
+=
"<TIFF変換完了>\r\n\r\n"
;
ResultConsole
.
Text
+=
"<TIFF変換完了>\r\n\r\n"
;
DoEvents
();
DoEvents
();
//検版レポートの入力チェック
string
workDir
=
""
;
bool
reportFlag
=
checkReportPath
();
try
{
//PureVerifyの実行
//PureVerifyの実行
string
workDir
=
CompareTIFF
.
runPureVerify
(
targetTIFFPath
,
referenceTIFFPath
,
workBox
.
Text
workDir
=
CompareTIFF
.
runPureVerify
(
targetTIFFPath
,
referenceTIFFPath
,
workBox
.
Text
,
shiftPixel
,
colorMargin
,
removePoint
,
shadingOff
,
reportFlag
,
reportBox
.
Text
);
,
shiftPixel
,
colorMargin
,
removePoint
,
shadingOff
,
reportFlag
,
reportBox
.
Text
);
}
catch
(
Exception
ex
)
{
CustomMsgBox
.
Show
(
mainWindow
,
ex
.
Message
,
"例外が発生しました"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Warning
);
//ログ記述
DateTime
faileTIme
=
DateTime
.
Now
;
string
logText
=
"["
+
faileTIme
+
"]"
+
Environment
.
NewLine
;
logText
+=
"例外の生じた処理:検版処理"
+
Environment
.
NewLine
;
logText
+=
ex
.
Message
+
"\n"
+
ex
.
StackTrace
+
Environment
.
NewLine
;
File
.
AppendAllText
(
System
.
IO
.
Path
.
Combine
(
workLogPath
,
"CSRender.log"
),
logText
);
//referenceErrorFlag = true;
}
try
{
//レポートを出力
//レポートを出力
outputLog
(
System
.
IO
.
Path
.
Combine
(
workDir
,
"report"
));
outputLog
(
System
.
IO
.
Path
.
Combine
(
workDir
,
"report"
));
}
catch
(
Exception
ex
)
{
CustomMsgBox
.
Show
(
mainWindow
,
ex
.
Message
,
"例外が発生しました"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Warning
);
//ログ記述
DateTime
faileTIme
=
DateTime
.
Now
;
string
logText
=
"["
+
faileTIme
+
"]"
+
Environment
.
NewLine
;
logText
+=
"例外の生じた処理:検版ログの出力"
+
Environment
.
NewLine
;
logText
+=
ex
.
Message
+
"\n"
+
ex
.
StackTrace
+
Environment
.
NewLine
;
File
.
AppendAllText
(
System
.
IO
.
Path
.
Combine
(
workLogPath
,
"CSRender.log"
),
logText
);
//referenceErrorFlag = true;
}
//レポート名を取得
string
PDFName
=
""
;
string
PDFName
=
""
;
try
{
//レポート名を取得
if
(
reportBox
.
Text
!=
""
)
if
(
reportBox
.
Text
!=
""
)
{
{
PDFName
=
reportBox
.
Text
;
PDFName
=
reportBox
.
Text
;
...
@@ -211,6 +287,18 @@ namespace CSRender
...
@@ -211,6 +287,18 @@ namespace CSRender
{
{
PDFName
=
CompareTIFF
.
getReportName
(
workDir
);
PDFName
=
CompareTIFF
.
getReportName
(
workDir
);
}
}
}
catch
(
Exception
ex
)
{
CustomMsgBox
.
Show
(
mainWindow
,
ex
.
Message
,
"例外が発生しました"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Warning
);
//ログ記述
DateTime
faileTIme
=
DateTime
.
Now
;
string
logText
=
"["
+
faileTIme
+
"]"
+
Environment
.
NewLine
;
logText
+=
"例外の生じた処理:レポート名の取得"
+
Environment
.
NewLine
;
logText
+=
ex
.
Message
+
"\n"
+
ex
.
StackTrace
+
Environment
.
NewLine
;
File
.
AppendAllText
(
System
.
IO
.
Path
.
Combine
(
workLogPath
,
"CSRender.log"
),
logText
);
//referenceErrorFlag = true;
}
//指定先にレポートを移動
//指定先にレポートを移動
CompareTIFF
.
moveReport
(
workBox
.
Text
,
workDir
);
CompareTIFF
.
moveReport
(
workBox
.
Text
,
workDir
);
...
@@ -219,6 +307,10 @@ namespace CSRender
...
@@ -219,6 +307,10 @@ namespace CSRender
ResultConsole
.
Text
+=
" 検版レポートのパス:"
;
ResultConsole
.
Text
+=
" 検版レポートのパス:"
;
ResultConsole
.
Text
+=
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
,
PDFName
);
ResultConsole
.
Text
+=
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
,
PDFName
);
ResultConsole
.
Text
+=
"\r\n"
;
ResultConsole
.
Text
+=
"\r\n"
;
if
(
reportBox
.
Text
==
""
)
{
reportBox
.
Text
=
System
.
IO
.
Path
.
Combine
(
workBox
.
Text
,
"report"
,
PDFName
);
}
//パラメータを次回初期値用に保存
//パラメータを次回初期値用に保存
Properties
.
Settings
.
Default
.
resolutionSetting
=
ResolutionBox
.
Value
;
Properties
.
Settings
.
Default
.
resolutionSetting
=
ResolutionBox
.
Value
;
...
...
Code/CSRender/CSRender/PageComboBox.cs
View file @
c6d00bcc
...
@@ -75,7 +75,7 @@ namespace CSRender
...
@@ -75,7 +75,7 @@ namespace CSRender
if
(
Pagebox
.
CaretIndex
==
0
&&
inputPage
==
","
)
{
e
.
Handled
=
true
;
return
;
}
if
(
Pagebox
.
CaretIndex
==
0
&&
inputPage
==
","
)
{
e
.
Handled
=
true
;
return
;
}
}
}
//誤ったハイフン・カンマの入力を修正
//誤ったハイフン・カンマ
、数字
の入力を修正
private
void
PageBox_LostFocus
(
object
sender
,
RoutedEventArgs
e
)
private
void
PageBox_LostFocus
(
object
sender
,
RoutedEventArgs
e
)
{
{
//ハイフン、カンマの削除
//ハイフン、カンマの削除
...
@@ -98,6 +98,12 @@ namespace CSRender
...
@@ -98,6 +98,12 @@ namespace CSRender
inputText
=
inputText
.
TrimStart
(
'-'
);
inputText
=
inputText
.
TrimStart
(
'-'
);
inputText
=
inputText
.
TrimEnd
(
'-'
);
inputText
=
inputText
.
TrimEnd
(
'-'
);
}
}
//先頭が0の場合は1に修正
if
(
inputText
.
StartsWith
(
"0"
))
{
inputText
=
inputText
.
TrimStart
(
'0'
);
inputText
=
"1"
+
inputText
;
}
PageBox
.
Text
=
inputText
;
PageBox
.
Text
=
inputText
;
}
}
...
...
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