-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLauncher.cs
159 lines (142 loc) · 5.18 KB
/
Launcher.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
// --------------------------------------------------------------------------------
// VariScan module
//
// Description:
//
// Environment: Windows 10 executable, 32 and 64 bit
//
// Usage: TBD
//
// Author: (REM) Rick McAlister, [email protected]
//
// Edit Log: Rev 1.0 Initial Version
//
// Date Who Vers Description
// ----------- --- ----- -------------------------------------------------------
//
// ---------------------------------------------------------------------------------
//
using System;
using System.Diagnostics;
namespace VariScan
{
public static class Launcher
{
public static void WaitStage()
{
// Wait method gets the staging time from the AGNSurvey configuration file,
// then runs a one second sleep loop until the current time is greater than the
// staging time.
Configuration cfg = new Configuration();
//Check to see if Staging executable has been enabled
// If so, then wait until the current time is greater than stage system time
if (Convert.ToBoolean(cfg.StageSystemOn))
{
DateTime stageTime = DateTime.Parse(cfg.StageSystemTime);
while (stageTime > System.DateTime.Now)
{
System.Threading.Thread.Sleep(1000);
//AGNSurveyForm.ActiveForm.Show();
System.Windows.Forms.Application.DoEvents();
}
}
return;
}
public static void WaitStart()
{
// Wait method gets the start up time from the AGNSurvey configuration file,
// then runs a one second sleep loop until the current time is greater than the
// start up time.
Configuration cfg = new Configuration();
if (Convert.ToBoolean(cfg.StartUpOn))
{
DateTime startTime = DateTime.Parse(cfg.StartUpTime);
while (startTime > System.DateTime.Now)
{
System.Threading.Thread.Sleep(1000);
//AGNSurveyForm.ActiveForm.Show();
System.Windows.Forms.Application.DoEvents();
}
return;
}
}
public static bool CheckEnd()
{
// CheckEnd gets the configured end time and returns true
// if the datetime exceeds the end time
Configuration cfg = new Configuration();
if (Convert.ToBoolean(cfg.ShutDownOn))
{
DateTime startTime = DateTime.Parse(cfg.StartUpTime);
DateTime endTime = DateTime.Parse(cfg.ShutDownTime);
//if (startTime > endTime)
//{
// endTime = endTime.AddDays(1);
//}
if (endTime < System.DateTime.Now)
{
return (true);
}
else
{
return (false);
}
}
else
{
return (false);
}
}
public static void RunStageSystem()
{
//If StageSystemOn is set, then RunStageSystem gets the StageSystem filepath from the AGNSurvey config file, if any
// then launches it and waits for completion.
Configuration cfg = new Configuration();
if (Convert.ToBoolean(cfg.StageSystemOn))
{
Process stageSystemExe = new Process();
if (cfg.StageSystemPath != "")
{
stageSystemExe.StartInfo.FileName = cfg.StageSystemPath;
stageSystemExe.Start();
stageSystemExe.WaitForExit();
}
}
return;
}
public static void RunStartUp()
{
//If StageSystemOn is set, then RunStageSystem gets the StageSystem filepath from the AGNSurvey config file, if any
// then launches it and waits for completion.
Configuration cfg = new Configuration();
if (Convert.ToBoolean(cfg.StartUpOn))
{
if (cfg.StartUpPath != "")
{
Process startUpExe = new Process();
startUpExe.StartInfo.FileName = cfg.StartUpPath;
startUpExe.Start();
startUpExe.WaitForExit();
}
}
return;
}
public static void RunShutDown()
{
//If ShutDownOn is set, then RunShutDown gets the postscan filepath from the AGNSurvey config file, if any
// then launches it and waits for completion.
Configuration cfg = new Configuration();
if (Convert.ToBoolean(cfg.ShutDownOn))
{
if (cfg.ShutDownPath != "")
{
Process shutDownExe = new Process();
shutDownExe.StartInfo.FileName = cfg.ShutDownPath;
shutDownExe.Start();
shutDownExe.WaitForExit();
}
}
return;
}
}
}