Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
auto-tx
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vamp
auto-tx
Commits
d1e733ee
Commit
d1e733ee
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Reduce number of global variables.
parent
6d28bb5e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ATxService/AutoTx.cs
+15
-16
15 additions, 16 deletions
ATxService/AutoTx.cs
with
15 additions
and
16 deletions
ATxService/AutoTx.cs
+
15
−
16
View file @
d1e733ee
...
...
@@ -14,6 +14,9 @@ using NLog.Config;
using
NLog.Targets
;
using
RoboSharp
;
// NOTE on naming conventions: variables containing "Path" are strings, variables containing
// "Dir" are DirectoryInfo objects!
namespace
ATxService
{
public
partial
class
AutoTx
:
ServiceBase
...
...
@@ -24,11 +27,6 @@ namespace ATxService
private
const
string
LogFormatDefault
=
@"${date:format=yyyy-MM-dd HH\:mm\:ss} [${level}] ${message}"
;
// private const string LogFormatDefault = @"${date:format=yyyy-MM-dd HH\:mm\:ss} [${level}] (${logger}) ${message}"
// naming convention: variables containing "Path" are strings, variables
// containing "Dir" are DirectoryInfo objects
private
string
_pathToConfig
;
private
string
_pathToStatus
;
private
readonly
List
<
string
>
_transferredFiles
=
new
List
<
string
>();
private
RoboCommand
_roboCommand
;
...
...
@@ -192,9 +190,6 @@ namespace ATxService
private
void
LoadSettings
()
{
try
{
_transferState
=
TxState
.
Stopped
;
var
baseDir
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
_pathToConfig
=
Path
.
Combine
(
baseDir
,
"configuration.xml"
);
_pathToStatus
=
Path
.
Combine
(
baseDir
,
"status.xml"
);
LoadConfigXml
();
LoadStatusXml
();
...
...
@@ -214,13 +209,15 @@ namespace ATxService
/// Load the configuration xml file.
/// </summary>
private
void
LoadConfigXml
()
{
var
confPath
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"configuration.xml"
);
try
{
_config
=
ServiceConfig
.
Deserialize
(
_pathToConfig
);
Log
.
Debug
(
"Loaded config from [{0}]"
,
_pathToConfig
);
_config
=
ServiceConfig
.
Deserialize
(
confPath
);
Log
.
Debug
(
"Loaded config from [{0}]"
,
confPath
);
}
catch
(
ConfigurationErrorsException
ex
)
{
Log
.
Error
(
"ERROR validating configuration file [{0}]: {1}"
,
_pathToConfig
,
ex
.
Message
);
confPath
,
ex
.
Message
);
throw
new
Exception
(
"Error validating configuration."
);
}
catch
(
Exception
ex
)
{
...
...
@@ -234,14 +231,16 @@ namespace ATxService
/// Load the status xml file.
/// </summary>
private
void
LoadStatusXml
()
{
try
{
Log
.
Debug
(
"Trying to load status from [{0}]"
,
_pathToStatus
);
_status
=
ServiceStatus
.
Deserialize
(
_pathToStatus
,
_config
);
Log
.
Debug
(
"Loaded status from [{0}]"
,
_pathToStatus
);
var
statusPath
=
Path
.
Combine
(
AppDomain
.
CurrentDomain
.
BaseDirectory
,
"status.xml"
);
try
{
Log
.
Debug
(
"Trying to load status from [{0}]"
,
statusPath
);
_status
=
ServiceStatus
.
Deserialize
(
statusPath
,
_config
);
Log
.
Debug
(
"Loaded status from [{0}]"
,
statusPath
);
}
catch
(
Exception
ex
)
{
Log
.
Error
(
"loading status XML from [{0}] failed: {1} {2}"
,
_pathToS
tatus
,
ex
.
Message
,
ex
.
StackTrace
);
s
tatus
Path
,
ex
.
Message
,
ex
.
StackTrace
);
// this should terminate the service process:
throw
new
Exception
(
"Error loading status."
);
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment