-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
51 lines (39 loc) · 1.66 KB
/
Program.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
using System;
using DbConnect.Services;
namespace DbConnect
{
class Program
{
static void Main(string[] args)
{
ArgumentService parsing = new ArgumentService();
int parsingresult = parsing.ParsingArguments(args);
if (parsingresult == 1)
{
Console.WriteLine("\nUsage: DbConnect.exe <-ping|-sql> <database>\n");
Environment.Exit(0);
}
string commandname = args[0];
string databasename = args[1];
// Build the configuration settings to be used in this application.
ConfigurationService service = new ConfigurationService(databasename);
var configuration = service.Configuration;
DatabaseService database = new DatabaseService();
// Get connection string from configuration source.
string connectionstring = database.ConnectionString(configuration, databasename);
switch (commandname)
{
case "-ping":
// Get database status using the connection string from configuration source.
string statusmessage = database.ConnectionStatus(connectionstring, databasename);
Console.WriteLine(statusmessage);
break;
case "-sql":
// Run SQL command using the connection string from configuration source.
string commandstring = database.CommandString(configuration, databasename);
database.Command(connectionstring, commandstring);
break;
}
}
}
}