-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCheckElo.cs
77 lines (67 loc) · 3.36 KB
/
CheckElo.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
using System;
using System.Diagnostics;
using check_elo.Commands.impl;
using check_elo.Configuration;
using check_elo.Parameters;
using check_elo.Response;
using CommandLine;
using log4net;
using pcm.IXClient7;
namespace check_elo
{
internal class CheckElo
{
private static readonly ILog Log = LogManager.GetLogger(typeof(CheckElo));
private static void Main(string[] args)
{
CheckResult checkResult = new CheckResult();
var configFilePath = Process.GetCurrentProcess().ProcessName + ".json";
var settings = ConfigReader.ReadConfigFile(configFilePath);
if (settings == null)
{
var errorMsg =
$"Unable to find settings file. Please provide a settings file with name: {configFilePath}";
Log.Error(errorMsg);
new CheckResult {Message = errorMsg, ExitCode = ExitCode.Critical}.Commit();
Environment.Exit(2);
}
var client = IXClient.Instance;
Parser.Default.ParseArguments<
DocCountParameters,
FileUploadParameters,
IxSessionParameters,
EloLoginParameters,
SqlConnectionParameters,
TomcatParameters,
WebappParameters,
WorkflowNodesParameters,
OcrParameters,
PasswordParameters>(args)
.MapResult((DocCountParameters parameters) => new DocCountCommand(client, settings, parameters, checkResult).Run(),
(FileUploadParameters parameters) => new FileUploadCommand(client, settings, parameters, checkResult).Run(),
(IxSessionParameters parameters) => new IxSessionCommand(client, settings, parameters, checkResult).Run(),
(EloLoginParameters parameters) => new LoginCommand(client, settings, parameters, checkResult).Run(),
(SqlConnectionParameters parameters) =>
new SqlConnectionCommand(client, settings, parameters, checkResult).Run(),
(TomcatParameters parameters) => new TomcatCommand(client, settings, parameters, checkResult).Run(),
(WebappParameters parameters) => new WebappCommand(client, settings, parameters, checkResult).Run(),
(WorkflowNodesParameters parameters) =>
new WorkflowNodesCommand(client, settings, parameters, checkResult).Run(),
(OcrParameters parameters) => new OcrCommand(client, settings, parameters, checkResult).Run(),
(PasswordParameters parameters) => new PasswordCommand(client, settings, parameters, checkResult).Run(),
parseErrors =>
{
var response = new CheckResult
{
Message = "Failed to parse parameters.",
ExitCode = ExitCode.Unknown
};
response.Commit();
foreach (var error in parseErrors) Log.Error($"Unable to parse Parameter '{error.Tag}'.");
return false;
}
);
Environment.Exit(Convert.ToInt32(checkResult.ExitCode));
}
}
}