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
fdc6757f
Commit
fdc6757f
authored
7 years ago
by
Niko Ehrenfeuchter
Browse files
Options
Downloads
Patches
Plain Diff
Allow specifying the base dir as a command line parameter.
Refers to
#2
parent
6e1d9910
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ATxTray/AutoTxTray.cs
+11
-10
11 additions, 10 deletions
ATxTray/AutoTxTray.cs
ATxTray/Program.cs
+5
-2
5 additions, 2 deletions
ATxTray/Program.cs
with
16 additions
and
12 deletions
ATxTray/AutoTxTray.cs
+
11
−
10
View file @
fdc6757f
...
@@ -26,9 +26,7 @@ namespace ATxTray
...
@@ -26,9 +26,7 @@ namespace ATxTray
private
static
readonly
Timer
AppTimer
=
new
Timer
(
1000
);
private
static
readonly
Timer
AppTimer
=
new
Timer
(
1000
);
private
static
bool
_terminate
=
false
;
private
static
bool
_terminate
=
false
;
private
static
readonly
string
BaseDir
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
private
static
string
_statusFile
;
private
static
readonly
string
ConfigFile
=
Path
.
Combine
(
BaseDir
,
"configuration.xml"
);
private
static
readonly
string
StatusFile
=
Path
.
Combine
(
BaseDir
,
"status.xml"
);
private
static
string
_submitPath
;
private
static
string
_submitPath
;
private
static
DateTime
_statusAge
;
private
static
DateTime
_statusAge
;
private
static
ServiceConfig
_config
;
private
static
ServiceConfig
_config
;
...
@@ -62,10 +60,10 @@ namespace ATxTray
...
@@ -62,10 +60,10 @@ namespace ATxTray
private
static
TaskDialog
_confirmDialog
;
private
static
TaskDialog
_confirmDialog
;
private
static
DirectoryInfo
_selectedDir
;
private
static
DirectoryInfo
_selectedDir
;
public
AutoTxTray
()
{
public
AutoTxTray
(
string
baseDir
)
{
#
region
logging
configuration
#
region
logging
configuration
var
logConfig
=
new
LoggingConfiguration
();
var
logConfig
=
new
LoggingConfiguration
();
var
fileTarget
=
new
FileTarget
{
var
fileTarget
=
new
FileTarget
{
FileName
=
Path
.
GetFileNameWithoutExtension
(
Application
.
ExecutablePath
)
+
".log"
,
FileName
=
Path
.
GetFileNameWithoutExtension
(
Application
.
ExecutablePath
)
+
".log"
,
...
@@ -80,13 +78,16 @@ namespace ATxTray
...
@@ -80,13 +78,16 @@ namespace ATxTray
#
endregion
#
endregion
var
configFile
=
Path
.
Combine
(
baseDir
,
"configuration.xml"
);
_statusFile
=
Path
.
Combine
(
baseDir
,
"status.xml"
);
Log
.
Info
(
"-----------------------"
);
Log
.
Info
(
"-----------------------"
);
Log
.
Info
(
"{0} initializing..."
,
AppTitle
);
Log
.
Info
(
"{0} initializing..."
,
AppTitle
);
Log
.
Info
(
"build: [{0}]"
,
Properties
.
Resources
.
BuildDate
.
Trim
());
Log
.
Info
(
"build: [{0}]"
,
Properties
.
Resources
.
BuildDate
.
Trim
());
Log
.
Info
(
"commit: [{0}]"
,
Properties
.
Resources
.
BuildCommit
.
Trim
());
Log
.
Info
(
"commit: [{0}]"
,
Properties
.
Resources
.
BuildCommit
.
Trim
());
Log
.
Info
(
"-----------------------"
);
Log
.
Info
(
"-----------------------"
);
Log
.
Debug
(
" - config file: [{0}]"
,
C
onfigFile
);
Log
.
Debug
(
" - config file: [{0}]"
,
c
onfigFile
);
Log
.
Debug
(
" - status file: [{0}]"
,
S
tatusFile
);
Log
.
Debug
(
" - status file: [{0}]"
,
_s
tatusFile
);
_notifyIcon
.
Icon
=
_tiStopped
;
_notifyIcon
.
Icon
=
_tiStopped
;
_notifyIcon
.
Visible
=
true
;
_notifyIcon
.
Visible
=
true
;
...
@@ -97,7 +98,7 @@ namespace ATxTray
...
@@ -97,7 +98,7 @@ namespace ATxTray
Log
.
Trace
(
"Trying to read service config and status files..."
);
Log
.
Trace
(
"Trying to read service config and status files..."
);
try
{
try
{
_config
=
ServiceConfig
.
Deserialize
(
C
onfigFile
);
_config
=
ServiceConfig
.
Deserialize
(
c
onfigFile
);
ReadStatus
();
ReadStatus
();
Log
.
Trace
(
"Completed reading service config and status files."
);
Log
.
Trace
(
"Completed reading service config and status files."
);
SetupContextMenu
();
SetupContextMenu
();
...
@@ -342,13 +343,13 @@ namespace ATxTray
...
@@ -342,13 +343,13 @@ namespace ATxTray
/// Read (or re-read) the service status file if it has changed since last time.
/// Read (or re-read) the service status file if it has changed since last time.
/// </summary>
/// </summary>
private
static
void
ReadStatus
()
{
private
static
void
ReadStatus
()
{
var
age
=
new
FileInfo
(
S
tatusFile
).
LastWriteTime
;
var
age
=
new
FileInfo
(
_s
tatusFile
).
LastWriteTime
;
if
(
age
==
_statusAge
)
if
(
age
==
_statusAge
)
return
;
return
;
Log
.
Trace
(
"Status file was updated, trying to re-read..."
);
Log
.
Trace
(
"Status file was updated, trying to re-read..."
);
_statusAge
=
age
;
_statusAge
=
age
;
_status
=
ServiceStatus
.
Deserialize
(
S
tatusFile
,
_config
);
_status
=
ServiceStatus
.
Deserialize
(
_s
tatusFile
,
_config
);
}
}
/// <summary>
/// <summary>
...
...
This diff is collapsed.
Click to expand it.
ATxTray/Program.cs
+
5
−
2
View file @
fdc6757f
...
@@ -9,10 +9,13 @@ namespace ATxTray
...
@@ -9,10 +9,13 @@ namespace ATxTray
/// The main entry point for the application.
/// The main entry point for the application.
/// </summary>
/// </summary>
[
STAThread
]
[
STAThread
]
private
static
void
Main
()
{
private
static
void
Main
(
string
[]
args
)
{
Application
.
EnableVisualStyles
();
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
AutoTxTray
());
var
baseDir
=
AppDomain
.
CurrentDomain
.
BaseDirectory
;
if
(
args
.
Length
>
0
)
baseDir
=
args
[
0
];
Application
.
Run
(
new
AutoTxTray
(
baseDir
));
}
}
}
}
}
}
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