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
d1e38770
Commit
d1e38770
authored
Apr 06, 2022
by
tsuji
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
・例外処理の部分を関数化
・ディレクトリの作成/削除を関数化
parent
f75dbee2
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
107 additions
and
110 deletions
+107
-110
FilePathSelect.cs
Code/CSRender/CSRender/FilePathSelect.cs
+48
-1
MainWindow.xaml.cs
Code/CSRender/CSRender/MainWindow.xaml.cs
+59
-109
No files found.
Code/CSRender/CSRender/FilePathSelect.cs
View file @
d1e38770
...
...
@@ -291,5 +291,52 @@ namespace CSRender
return
inFileName
;
}
private
string
SelectFileTarget
(
bool
dummyFlag
,
string
targetBoxText
,
string
referenceBoxText
,
string
workBoxText
)
{
string
dummyFileName
=
""
;
//対象とリファレンスが同名ファイルであるか確認
string
TarFileName
=
System
.
IO
.
Path
.
GetFileName
(
referenceBoxText
);
string
RefFileName
=
System
.
IO
.
Path
.
GetFileName
(
targetBoxText
);
if
(
TarFileName
!=
RefFileName
)
{
//指定した作業フォルダ内にダミー用フォルダを設定(無ければ生成)
string
dummyDir
=
System
.
IO
.
Path
.
Combine
(
workBoxText
,
"Dummy"
);
if
(!
Directory
.
Exists
(
dummyDir
))
{
Directory
.
CreateDirectory
(
dummyDir
);
}
string
dummyTarDir
=
System
.
IO
.
Path
.
Combine
(
dummyDir
,
"Target"
);
if
(!
Directory
.
Exists
(
dummyTarDir
))
{
Directory
.
CreateDirectory
(
dummyTarDir
);
}
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
);
dummyFlag
=
true
;
//検版対象をダミーに指定
targetBoxText
=
dummyTarDir
;
referenceBoxText
=
dummyRefDir
;
}
return
dummyFileName
;
}
//指定のパスにディレクトリが無ければ作成
private
void
checkDirPath
(
string
inDirPath
)
{
if
(!
Directory
.
Exists
(
inDirPath
))
{
Directory
.
CreateDirectory
(
inDirPath
);
//パスにディレクトリが無ければ作成
}
}
//指定のパスにディレクトリがあれば削除し、新たな同名ディレクトリを作成
private
void
DeleteOldDir
(
string
inDirPath
)
{
if
(
Directory
.
Exists
(
inDirPath
))
{
Directory
.
Delete
(
inDirPath
,
true
);
//パスにディレクトリがあれば削除
}
Directory
.
CreateDirectory
(
inDirPath
);
//同名のディレクトリを作成
}
}
}
Code/CSRender/CSRender/MainWindow.xaml.cs
View file @
d1e38770
...
...
@@ -105,12 +105,18 @@ namespace CSRender
private
async
void
CompareButtonClick
(
object
sender
,
RoutedEventArgs
e
)
{
killButton
();
killButton
();
//メニューを非活性化
//各種パスの指定先の取得
string
workBoxText
=
workBox
.
Text
;
string
reportBoxText
=
reportBox
.
Text
;
string
targetBoxText
=
targetBox
.
Text
;
string
referenceBoxText
=
referenceBox
.
Text
;
//検版パラメータの取得
string
shiftPixel
=
PositionBox
.
Text
;
string
colorMargin
=
GradationBox
.
Text
;
string
removePoint
=
SmallDiffBox
.
Text
;
string
shadingOff
=
VisualBox
.
Text
;
//対象フォルダのpathチェック
if
(!
Directory
.
Exists
(
targetBoxText
)
&&
!
File
.
Exists
(
targetBoxText
))
...
...
@@ -122,6 +128,8 @@ namespace CSRender
ResultConsole
.
ScrollToEnd
();
Properties
.
Settings
.
Default
.
targetSetting
=
""
;
Properties
.
Settings
.
Default
.
Save
();
reviveButton
();
//終了前にメニューを復帰
return
;
}
...
...
@@ -135,6 +143,8 @@ namespace CSRender
ResultConsole
.
ScrollToEnd
();
Properties
.
Settings
.
Default
.
referenceSetting
=
""
;
Properties
.
Settings
.
Default
.
Save
();
reviveButton
();
//終了前にメニューを復帰
return
;
}
...
...
@@ -143,28 +153,10 @@ namespace CSRender
string
dummyFileName
=
""
;
if
(
File
.
Exists
(
referenceBoxText
)
&&
File
.
Exists
(
targetBoxText
))
{
//対象とリファレンスが同名ファイルであるか確認
string
TarFileName
=
System
.
IO
.
Path
.
GetFileName
(
referenceBoxText
);
string
RefFileName
=
System
.
IO
.
Path
.
GetFileName
(
targetBoxText
);
if
(
TarFileName
!=
RefFileName
)
{
//指定した作業フォルダ内にダミー用フォルダを設定(無ければ生成)
string
dummyDir
=
System
.
IO
.
Path
.
Combine
(
workBoxText
,
"Dummy"
);
if
(!
Directory
.
Exists
(
dummyDir
))
{
Directory
.
CreateDirectory
(
dummyDir
);
}
string
dummyTarDir
=
System
.
IO
.
Path
.
Combine
(
dummyDir
,
"Target"
);
if
(!
Directory
.
Exists
(
dummyTarDir
))
{
Directory
.
CreateDirectory
(
dummyTarDir
);
}
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
);
dummyFlag
=
true
;
//検版対象をダミーに指定
targetBoxText
=
dummyTarDir
;
referenceBoxText
=
dummyRefDir
;
}
dummyFileName
=
SelectFileTarget
(
dummyFlag
,
targetBoxText
,
referenceBoxText
,
workBoxText
);
}
//出力ファイルpathのチェック
if
(!
Directory
.
Exists
(
workBoxText
)
&&
!
File
.
Exists
(
workBoxText
))
{
...
...
@@ -176,14 +168,15 @@ namespace CSRender
workBox
.
Text
=
""
;
Properties
.
Settings
.
Default
.
workSpaceSetting
=
workBoxText
;
Properties
.
Settings
.
Default
.
Save
();
reviveButton
();
//終了前にメニューを復帰
return
;
}
string
workLogPath
=
System
.
IO
.
Path
.
Combine
(
workBoxText
,
"report"
);
string
workLogPath
=
System
.
IO
.
Path
.
Combine
(
workBoxText
,
"report"
);
//reportフォルダのパス
checkDirPath
(
workLogPath
);
//なければ作成
string
outDiffPath
=
System
.
IO
.
Path
.
Combine
(
workBoxText
,
"OUT_DIFF"
);
//DIFF画像の出力先パス
if
(!
Directory
.
Exists
(
outDiffPath
))
{
Directory
.
CreateDirectory
(
outDiffPath
);
//DIFF画像の出力先パスが無ければ作成
}
checkDirPath
(
outDiffPath
);
//なければ作成
bool
reportFlag
=
false
;
try
...
...
@@ -193,24 +186,10 @@ namespace CSRender
}
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
=
""
;
checkReportPath
();
//referenceErrorFlag = true;
string
WorkCategory
=
"レポート名の確認"
;
ExceptionMessage
(
ex
,
workLogPath
,
WorkCategory
);
}
//検版パラメータの取得
string
shiftPixel
=
PositionBox
.
Text
;
string
colorMargin
=
GradationBox
.
Text
;
string
removePoint
=
SmallDiffBox
.
Text
;
string
shadingOff
=
VisualBox
.
Text
;
//RIP処理時間の計測
var
ripTime
=
new
System
.
Diagnostics
.
Stopwatch
();
ripTime
.
Start
();
//計測開始
...
...
@@ -232,11 +211,7 @@ namespace CSRender
//対象フォルダ
string
targetTIFFPath
=
System
.
IO
.
Path
.
Combine
(
workBoxText
,
"work"
,
"targetTIFF"
);
if
(
Directory
.
Exists
(
targetTIFFPath
))
//指定先にTIFF用フォルダがあるか
{
Directory
.
Delete
(
targetTIFFPath
,
true
);
//あれば古いTIFF用フォルダを削除(前回作業時の生成物との混同防止)
}
Directory
.
CreateDirectory
(
targetTIFFPath
);
//新規でTIFF用フォルダを作成
DeleteOldDir
(
targetTIFFPath
);
//指定先に古いTIFF用フォルダがあれば削除し、新たに作成(前回作業時の生成物との混同防止)
//CSRenderの実行
try
...
...
@@ -249,14 +224,8 @@ namespace CSRender
}
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;
string
WorkCategory
=
"対象PDFのTIFF画像生成"
;
ExceptionMessage
(
ex
,
workLogPath
,
WorkCategory
);
}
ResultConsole
.
Text
+=
" リファレンスファイルをTIFF画像に変換中\r\n"
;
...
...
@@ -265,11 +234,7 @@ namespace CSRender
//リファレンスフォルダ
string
referenceTIFFPath
=
System
.
IO
.
Path
.
Combine
(
workBoxText
,
"work"
,
"referenceTIFF"
);
if
(
Directory
.
Exists
(
referenceTIFFPath
))
//指定先にTIFF用フォルダがあるか
{
Directory
.
Delete
(
referenceTIFFPath
,
true
);
//あれば古いTIFF用フォルダを削除(前回作業時の生成物との混同防止)
}
Directory
.
CreateDirectory
(
referenceTIFFPath
);
//新規でTIFF用フォルダを作成
DeleteOldDir
(
referenceTIFFPath
);
//指定先に古いTIFF用フォルダがあれば削除し、新たに作成(前回作業時の生成物との混同防止)
//CSRenderの実行
try
...
...
@@ -282,14 +247,8 @@ namespace CSRender
}
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;
string
WorkCategory
=
"リファレンスPDFのTIFF画像生成"
;
ExceptionMessage
(
ex
,
workLogPath
,
WorkCategory
);
}
ripTime
.
Stop
();
//RIP時間の計測終了
...
...
@@ -310,13 +269,8 @@ namespace CSRender
}
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
);
string
WorkCategory
=
"検版レポートの編集"
;
ExceptionMessage
(
ex
,
workLogPath
,
WorkCategory
);
}
string
workDir
=
""
;
...
...
@@ -391,14 +345,8 @@ namespace CSRender
}
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
WorkCategory
=
"検版処理"
;
ExceptionMessage
(
ex
,
workLogPath
,
WorkCategory
);
}
try
...
...
@@ -411,14 +359,8 @@ namespace CSRender
}
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
WorkCategory
=
"検版ログの出力"
;
ExceptionMessage
(
ex
,
workLogPath
,
WorkCategory
);
}
string
PDFName
=
""
;
...
...
@@ -436,14 +378,8 @@ namespace CSRender
}
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
WorkCategory
=
"レポート名の取得"
;
ExceptionMessage
(
ex
,
workLogPath
,
WorkCategory
);
}
try
...
...
@@ -453,14 +389,8 @@ namespace CSRender
}
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
WorkCategory
=
"ログファイルの移動"
;
ExceptionMessage
(
ex
,
workLogPath
,
WorkCategory
);
}
//レポートのパスを表示
...
...
@@ -1037,6 +967,8 @@ namespace CSRender
ResultConsole
.
Text
+=
"<変換中止>\r\n"
;
Properties
.
Settings
.
Default
.
targetSetting
=
""
;
Properties
.
Settings
.
Default
.
Save
();
reviveButton
();
//終了前にメニューを復帰
return
;
}
...
...
@@ -1052,6 +984,8 @@ namespace CSRender
workBox
.
Text
=
""
;
Properties
.
Settings
.
Default
.
workSpaceSetting
=
""
;
Properties
.
Settings
.
Default
.
Save
();
reviveButton
();
//終了前にメニューを復帰
return
;
}
}
...
...
@@ -1072,6 +1006,22 @@ namespace CSRender
Properties
.
Settings
.
Default
.
Save
();
}
//例外発生時のメッセージボックス
private
void
ExceptionMessage
(
Exception
ex
,
string
workLogPath
,
string
inErrorWork
)
{
if
(!
Directory
.
Exists
(
workLogPath
))
{
Directory
.
CreateDirectory
(
workLogPath
);
}
CustomMsgBox
.
Show
(
mainWindow
,
ex
.
Message
,
"エラーが発生しました"
,
MessageBoxButton
.
OK
,
MessageBoxImage
.
Warning
);
//ログ記述
DateTime
faileTIme
=
DateTime
.
Now
;
string
logText
=
"["
+
faileTIme
+
"]"
+
Environment
.
NewLine
;
logText
+=
"例外の生じた処理:"
+
inErrorWork
+
Environment
.
NewLine
;
logText
+=
ex
.
Message
+
"\n"
+
ex
.
StackTrace
+
Environment
.
NewLine
;
File
.
AppendAllText
(
System
.
IO
.
Path
.
Combine
(
workLogPath
,
"CSRender.log"
),
logText
);
}
//メニュを明示的に更新する
private
void
DoEvents
()
{
...
...
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