-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
361 lines (344 loc) · 19.4 KB
/
Copy pathProgram.cs
File metadata and controls
361 lines (344 loc) · 19.4 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading;
namespace JARVIS4
{
class Program
{
/// <summary>
/// Handle all JARVIS logic
/// </summary>
/// <param name="args"></param>
static void Main(string[] args)
{
Dictionary<string, Type> JARVIS_types = new Dictionary<string, Type>();
Dictionary<string, MethodInfo> JARVIS_methods = new Dictionary<string, MethodInfo>();
List<Thread> available_threads = new List<Thread>();
List<JARVISDataSource> available_datasources = new List<JARVISDataSource>();
bool program_running = true;
string user_input = "";
Console.Write("Enter a command: ");
user_input = Console.ReadLine();
while (program_running)
{
JARVISLearning.log_command(user_input);
List<string> command_parameters = user_input.Split(' ').ToList();
string primary_command = command_parameters[0].Trim().ToLower();
try
{
if (primary_command != "exit")
{
if (primary_command == "start")
{
if (command_parameters.ElementAtOrDefault(1) != null)
{
string secondary_command = command_parameters[1];
if (secondary_command == "process")
{
string path = user_input.Remove(0, "start process".Length).Trim();
if (path.Length > 0)
{
Console.WriteLine("Starting process {0}", path);
}
else
{
Console.WriteLine("Invalid process path/name");
}
JARVISDiagnostics.StartProcess(path);
}
else
{
Console.WriteLine("Unable to perform operation \"start\". Incorrect secondary command");
}
}
else
{
}
}
else if(primary_command == "help")
{
string secondary_command = command_parameters.ElementAtOrDefault(1);
if(secondary_command != null)
{
if(secondary_command == "method")
{
string method_name = command_parameters.ElementAtOrDefault(2);
List<string> method_list = new List<string>();
if(method_name != null)
{
method_list = JARVISDiagnostics.FindMethod(method_name);
JARVISConsole.list_to_console(method_list);
}
}
}
}
else if (primary_command == "new")
{
if (command_parameters.ElementAtOrDefault(1) != null)
{
string secondary_command = command_parameters[1];
if (secondary_command == "class")
{
}
else
{
Console.WriteLine("Unable to perform operation \"start\". Incorrect secondary command");
}
}
}
else if (primary_command == "diagnostics")
{
JARVISConsole.list_to_console(JARVISDiagnostics.ListJARVISTypes());
JARVISConsole.list_to_console(JARVISDiagnostics.ListJARVISTypeProperties("JARVIS4.JARVISLearning"));
Console.WriteLine("Path = {0}", JARVISDiagnostics.GetJARVISExecutablePath());
}
else if (primary_command == "read")
{
JARVISCustomAlgorithms.MerimenRequestStatistics_Analyze(@"C:\JARVIS4\CustomAlgorithmSources\MERIMEN");
}
else if(primary_command == "getfuseboxfuseaction")
{
string claims_path = user_input.Replace("getfuseboxfuseaction", "").Trim();
if(claims_path != null)
{
StatusObject SO_GetFuseboxFuseaction = JARVISCustomAlgorithms.GetFuseboxFuseactionList(claims_path);
if (SO_GetFuseboxFuseaction.Status != StatusObject.StatusCode.FAILURE)
{
}
else
{
Console.WriteLine(SO_GetFuseboxFuseaction.ErrorStacktrace);
}
}
else
{
Console.WriteLine("Invalid path");
}
}
else if (primary_command == "customalgo")
{
Console.WriteLine("JARVIS Custom Algorithms");
JARVISConsole.list_to_console(JARVISDiagnostics.ListJARVISTypeProperties("JARVIS4.JARVISCustomAlgorithms"));
}
else if (primary_command == "fileprocessing")
{
if (command_parameters.ElementAtOrDefault(1) != null)
{
string file_path = user_input.Replace("fileprocessing","").Trim();
JARVISFileProcessing.read_large_text_file(file_path);
}
else
{
Console.WriteLine("Unable to perform operation \"textprocessing\". File name not provided");
}
}
else if (primary_command == "run")
{
if(command_parameters.ElementAtOrDefault(1) != null)
{
string type_name = command_parameters[1];
string function_name = command_parameters.ElementAtOrDefault(2);
string function_parameters = command_parameters.ElementAtOrDefault(3);
JARVISDiagnostics.RunJARVISMethod("JARVIS4", type_name, function_name, function_parameters);
}
else
{
Console.WriteLine("Unable to peform operation \"run\". Type name not provided");
}
}
else if (primary_command == "thread")
{
string secondary_command = command_parameters.ElementAtOrDefault(1);
if(secondary_command != null)
{
if (secondary_command == "add")
{
}
else if (secondary_command == "stop")
{
}
else if (secondary_command == "stopall")
{
}
}
else
{
Console.WriteLine("Unable to perform operation \"add\". Insufficient Information Provided");
}
}
else if (primary_command == "datasource")
{
string secondary_command = command_parameters.ElementAtOrDefault(1);
string auth_type = command_parameters.ElementAtOrDefault(2);
if (secondary_command != null && secondary_command.Length > 0)
{
if (secondary_command == "add")
{
if(auth_type == "sqlauth")
{
string server_name = command_parameters.ElementAtOrDefault(3);
string database_name = command_parameters.ElementAtOrDefault(4);
string database_user_id = command_parameters.ElementAtOrDefault(5);
string database_password = command_parameters.ElementAtOrDefault(6);
StatusObject SO_AddDataSource = JARVISDataSourceManager.AddDataSource(server_name, database_name, database_user_id, database_password);
if (SO_AddDataSource.Status == StatusObject.StatusCode.FAILURE)
{
Console.WriteLine(SO_AddDataSource.ErrorStacktrace);
}
}
else if (auth_type == "winauth")
{
string server_name = command_parameters.ElementAtOrDefault(3);
string database_name = command_parameters.ElementAtOrDefault(4);
StatusObject SO_AddDataSource = JARVISDataSourceManager.AddDataSource(server_name, database_name);
if (SO_AddDataSource.Status == StatusObject.StatusCode.FAILURE)
{
Console.WriteLine(SO_AddDataSource.ErrorStacktrace);
}
}
}
else if(secondary_command == "sqlexecute")
{
string sql = user_input.Replace("datasource", "").Replace("sqlexecute", "").Trim();
JARVISDataSourceAlgorithms.ExecuteSQL(new JARVISDataSource("sql2008kl", "claims_dev", "sa", "password").CreateConnection(), sql);
}
else if (secondary_command == "ssptofile")
{
string server_name = command_parameters.ElementAtOrDefault(3);
string database_name = command_parameters.ElementAtOrDefault(4);
string database_user_id = command_parameters.ElementAtOrDefault(5);
string database_password = command_parameters.ElementAtOrDefault(6);
JARVISDataSource target_datasource = new JARVISDataSource();
if (auth_type == "sqlauth")
{
target_datasource = new JARVISDataSource(server_name, database_name, database_user_id, database_password);
}
else if(auth_type == "winauth")
{
target_datasource = new JARVISDataSource(server_name, database_name);
}
StatusObject SO_ssptofile = JARVISDataSourceAlgorithms.StoredProceduresToFile(target_datasource.CreateConnection());
if (SO_ssptofile.Status != StatusObject.StatusCode.FAILURE)
{
}
else
{
Console.WriteLine(SO_ssptofile.ErrorStacktrace);
}
}
else if (secondary_command == "tracksspchanges")
{
string server_name = command_parameters.ElementAtOrDefault(3);
string database_name = command_parameters.ElementAtOrDefault(4);
string database_user_id = command_parameters.ElementAtOrDefault(5);
string database_password = command_parameters.ElementAtOrDefault(6);
JARVISDataSource target_datasource = new JARVISDataSource();
if (auth_type == "sqlauth")
{
target_datasource = new JARVISDataSource(server_name, database_name, database_user_id, database_password);
}
else if (auth_type == "winauth")
{
target_datasource = new JARVISDataSource(server_name, database_name);
}
bool tracking = true;
while (tracking)
{
StatusObject SO_ssptofile = JARVISDataSourceAlgorithms.TrackStoredProcedureChanges(target_datasource.CreateConnection());
if (SO_ssptofile.Status != StatusObject.StatusCode.FAILURE)
{
}
else
{
Console.WriteLine(SO_ssptofile.ErrorStacktrace);
tracking = false;
}
Thread.Sleep(60000);
}
}
else if (secondary_command == "multidbssptofile")
{
if (File.Exists(@"C:\JARVIS4\UserDefinedDataSources\BatchExtracts\targets.txt"))
{
StreamReader file_reader = new StreamReader(@"C:\JARVIS4\UserDefinedDataSources\BatchExtracts\targets.txt");
string databaseconfig;
while ((databaseconfig = file_reader.ReadLine()) != null)
{
Console.WriteLine(databaseconfig);
JARVISDataSource target_datasource = new JARVISDataSource(databaseconfig);
StatusObject SO_ssptofile = JARVISDataSourceAlgorithms.StoredProceduresToFile(target_datasource.CreateConnection());
if (SO_ssptofile.Status != StatusObject.StatusCode.FAILURE)
{
}
else
{
Console.WriteLine(SO_ssptofile.ErrorStacktrace);
}
}
file_reader.Close();
}
else
{
Console.WriteLine(@"Unable to find batch scripts. Please place batch scripts in \nC:\JARVIS4\UserDefinedDataSources\BatchExtracts\targets.txt");
Directory.CreateDirectory(@"C:\JARVIS4\UserDefinedDataSources\BatchExtracts");
StreamWriter new_file = new StreamWriter(@"C:\JARVIS4\UserDefinedDataSources\BatchExtracts\targets.txt");
new_file.Close();
}
}
}
}
else if (primary_command == "record")
{
string secondary_command = command_parameters.ElementAtOrDefault(1);
if (secondary_command != null)
{
}
else
{
Console.WriteLine("Incorrect syntax for command {0}", primary_command);
}
}
else if (primary_command == "winform")
{
}
else if (primary_command == "writetoexcel")
{
StatusObject SO_WriteToExcel = JARVISFileProcessing.WriteExcelFile();
if(SO_WriteToExcel.Status != StatusObject.StatusCode.FAILURE)
{
}
else
{
Console.WriteLine(SO_WriteToExcel.ErrorStacktrace);
}
}
else
{
Console.WriteLine("Invalid Command");
}
Console.Write("Enter a command: ");
user_input = Console.ReadLine();
}
else
{
program_running = false;
// Do exit logic here
}
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.Write("Enter a command: ");
user_input = Console.ReadLine();
program_running = true;
}
}
}
}
}