-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
600 lines (440 loc) · 18.2 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
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
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
using jtcTestClient;
using System.Diagnostics;
using System.Text.Json;
using System.Text.Json.Serialization;
bool bJustFileSync = false;
if (args.Length > 0)
{
foreach (var arg in args)
{
Console.WriteLine($"Argument={arg}");
if (arg.Length > 0 && arg.StartsWith("filesync"))
{
bJustFileSync = true;
}
}
}
else
{
Console.WriteLine("No arguments");
}
Stopwatch timer = new Stopwatch();
string accessToken = string.Empty;
string bearerToken = string.Empty;
const string API_BASE = "https://customer.jetnetconnect.com/api/"; // live customer api
//const string API_BASE = "https://testcustomer.jetnetconnect.com/api/"; // test customer api
//const string API_BASE = "https://www.jetnetconnectlocal.com/api/"; // local customer api (IIS)
//const string API_BASE = "https://localhost:44382/api/"; // local customer api (IISExpress)
//const string API_BASE = "https://localhost:5001/api/"; // local customer api (IIS)
string apiBase = ""; // base api path
apiBase = API_BASE;
string authURL = "Admin/APILogin";
string aircraftControler = "Aircraft";
string companyControler = "Company";
string contactControler = "Contact";
string utilityControler = "Utility";
string exportsControler = "CustomEndpoints";
string getAccountInfo = utilityControler + "/getAccountInfo/{0}";
string getAircraft = aircraftControler + "/getAircraft/{0}/{1}";
string getAircraftPictures = aircraftControler + "/getPictures/{0}/{1}";
string getAircraftList = aircraftControler + "/getAircraftList/{0}";
string getAircraftHistoryList = aircraftControler + "/getHistoryList/{0}";
string getAircraftHistoryListPaged = aircraftControler + "/getHistoryListPaged/{0}/{1}/{2}";
string getAircraftFlightsList = aircraftControler + "/getFlightData/{0}";
string getCondensedOwnerOperators = aircraftControler + "/getCondensedOwnerOperators/{0}";
string getGulfstreamExport = exportsControler + "/getGulfstreamExport/{0}";
string getFulerLinxExport = exportsControler + "/getFuelerLinxExport/{0}/{1}";
string getCompany = companyControler + "/getCompany/{0}/{1}";
string getCompanyList = companyControler + "/getCompanyList/{0}";
string getAllCompanyInfo = companyControler + "/getAllCompanyInfo/{0}";
string getContact = contactControler + "/getContact/{0}/{1}";
string getContactList = contactControler + "/getContactList/{0}";
Console.WriteLine("Connect To API");
var serializeOptions = new JsonSerializerOptions
{
WriteIndented = true,
PropertyNameCaseInsensitive = true,
Converters =
{
new JsonStringEnumConverter(null, true)
}
};
ApiUser loginUser = new()
{
EmailAddress = @"[email protected]",
Password = @"g846ii2v"
};
// login to api example
responseAPILogin loginResponse = new();
apiConnection customerAPI = new();
string restURL = apiBase + authURL;
string? returnValue = customerAPI.GetFromAPI("", restURL, loginUser, "PUT").Result;
if (returnValue is not null)
{
loginResponse = JsonSerializer.Deserialize<responseAPILogin>(returnValue)!;
// bearer token and access token
accessToken = loginResponse.apiToken!;
bearerToken = loginResponse.bearerToken!;
Console.WriteLine("\nUSER {0} customer API Token {1}", loginUser.EmailAddress.Trim(), accessToken.Trim());
}
else
Console.WriteLine("\nERROR : USER {0} FAILED LOGIN", loginUser.EmailAddress.Trim());
returnValue = null;
// get users account example
string tmpString = string.Format(getAccountInfo, accessToken.Trim());
restURL = apiBase + tmpString;
returnValue = customerAPI.GetFromAPI(bearerToken, restURL, null).Result;
responseAccountInfo accountResponse = new();
if (returnValue is not null && !string.IsNullOrWhiteSpace(returnValue.Trim()))
{
accountResponse = JsonSerializer.Deserialize<responseAccountInfo>(returnValue)!;
if (accountResponse.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\ngetAccountInfo {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : getAccountInfo {0}", accountResponse.responsestatus!.Trim());
}
else
Console.WriteLine("ERROR : getAccountInfo {0}", returnValue!.Trim());
returnValue = null;
// get aircraft example
tmpString = string.Format(getAircraft, "193093", accessToken.Trim());
restURL = apiBase + tmpString;
returnValue = customerAPI.GetFromAPI(bearerToken, restURL, null).Result;
responseAircraft aircraftResponse = new();
if (returnValue is not null)
{
aircraftResponse = JsonSerializer.Deserialize<responseAircraft>(returnValue, serializeOptions)!;
if (aircraftResponse.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\ngetAircraft {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : getAircraft {0}", aircraftResponse.responsestatus!.Trim());
}
returnValue = null;
// get aircraft pictures example
tmpString = string.Format(getAircraftPictures, "214067", accessToken.Trim());
restURL = apiBase + tmpString;
//returnValue = customerAPI.GetFromAPI(bearerToken, restURL, null).Result;
responseAcPictures responseAcPictures = new();
if (returnValue is not null)
{
responseAcPictures = JsonSerializer.Deserialize<responseAcPictures>(returnValue, serializeOptions)!;
if (responseAcPictures.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\ngetAircraftPictures {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : getAircraftPictures {0}", responseAcPictures.responsestatus!.Trim());
}
returnValue = null;
// get company example
tmpString = string.Format(getCompany, "7223", accessToken.Trim());
restURL = apiBase + tmpString;
// returnValue = customerAPI.GetFromAPI(bearerToken, restURL, null).Result;
responseCompany companyResponse = new();
if (returnValue is not null)
{
companyResponse = JsonSerializer.Deserialize<responseCompany>(returnValue)!;
if (companyResponse.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\ngetCompany {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : getCompany {0}", companyResponse.responsestatus!.Trim());
}
returnValue = null;
// get contact example
tmpString = string.Format(getContact, "345384", accessToken.Trim());
restURL = apiBase + tmpString;
// returnValue = customerAPI.GetFromAPI(bearerToken, restURL, null).Result;
responseContact contactResponse = new();
if (returnValue is not null)
{
contactResponse = JsonSerializer.Deserialize<responseContact>(returnValue)!;
if (contactResponse.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\ngetContact {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : getContact {0}", contactResponse.responsestatus!.Trim());
}
returnValue = null;
// get aircraft list example
tmpString = string.Format(getAircraftList, accessToken.Trim());
restURL = apiBase + tmpString;
List<string> tmpStateName = new();
tmpStateName.Add("new york");
//tmpState.Add("NJ");
//tmpState.Add("PA");
AcListOptions content = new()
{
airframetype = eAirFrameTypes.None,
maketype = eMakeTypes.None,
sernbr = "",
regnbr = "",
modelid = 1271,
make = "",
forsale = "true",
lifecycle = eLifeCycle.None,
basestate = null,
basestatename = null,
basecountry = "",
basecode = "",
actiondate = "",
companyid = 0,
contactid = 0,
yearmfr = 0,
yeardlv = 0,
aircraftchanges = "",
aclist = null,
modlist = null
};
// returnValue = customerAPI.GetFromAPI(bearerToken, restURL, content, "PUT").Result;
responseAircraftList aircraftList = new();
if (returnValue is not null)
{
aircraftList = JsonSerializer.Deserialize<responseAircraftList>(returnValue)!;
if (aircraftList.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\naircraft list {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : aircraft list {0}", aircraftList.responsestatus!.Trim());
}
returnValue = null;
// get aircraft history list example
tmpString = string.Format(getAircraftHistoryList, accessToken.Trim());
restURL = apiBase + tmpString;
List<eAcTransTypes> transtypes = new();
transtypes.Add(eAcTransTypes.FullSale);
transtypes.Add(eAcTransTypes.ShareSale);
transtypes.Add(eAcTransTypes.Lease);
//AcHistoryOptions content3 = new()
//{
// aircraftid = 0,
// airframetype = eAirFrameTypes.None,
// maketype = eMakeTypes.None,
// modelid = 0,
// make = "GULFSTREAM",
// companyid = 0,
// isnewaircraft = eYesNoIgnoreFlag.Ignore,
// allrelationships = true,
// transtype = null, //transtypes,
// startdate = "01/01/2024",
// enddate = "",
// lastactionstartdate = "",
// lastactionenddate = "",
// aclist = null,
// modlist = null,
// ispreownedtrans = eYesNoIgnoreFlag.Ignore,
// isretailtrans = eYesNoIgnoreFlag.Ignore,
// isinternaltrans = eYesNoIgnoreFlag.Ignore
//};
AcHistoryOptions content3 = new()
{
make = "KING AIR",
startdate = "01/01/2024"
};
returnValue = customerAPI.GetFromAPI(bearerToken, restURL, content3, "PUT").Result;
responseAcHistory aircraftHistoryList = new();
if (returnValue is not null)
{
aircraftHistoryList = JsonSerializer.Deserialize<responseAcHistory>(returnValue)!;
if (aircraftHistoryList.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\naircraft history list {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : aircraft history list {0}", aircraftHistoryList.responsestatus!.Trim());
}
tmpString = string.Format(getAircraftHistoryListPaged, accessToken.Trim(), "100", "1");
restURL = apiBase + tmpString;
//returnValue = customerAPI.GetFromAPI(bearerToken, restURL, content3, "PUT").Result;
responseAcHistory aircraftHistoryList2 = new();
if (returnValue is not null)
{
aircraftHistoryList2 = JsonSerializer.Deserialize<responseAcHistory>(returnValue)!;
if (aircraftHistoryList2.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\naircraft history list {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : aircraft history list {0}", aircraftHistoryList2.responsestatus!.Trim());
}
returnValue = null;
// get Condensed Owner Operators report example
tmpString = string.Format(getCondensedOwnerOperators, accessToken.Trim());
restURL = apiBase + tmpString;
AcListOptions content5 = new()
{
make = "GULFSTREAM",
lifecycle = eLifeCycle.InOperation
};
timer.Start();
Console.WriteLine("\nSTART : {0} get Condensed Owner/Operator Report et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
//returnValue = customerAPI.GetFromAPI(bearerToken, restURL, content5, "PUT").Result;
responseCondensedOwnerOperatorReport condensedOwnerOperatorReport = new();
if (returnValue is not null)
{
condensedOwnerOperatorReport = JsonSerializer.Deserialize<responseCondensedOwnerOperatorReport>(returnValue, serializeOptions)!;
if (condensedOwnerOperatorReport.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\nRETURN Condensed Owner/Operator Report {0} et: {1:hh\\:mm\\:ss}", returnValue.Trim(), timer.Elapsed);
else
Console.WriteLine("\nERROR : Condensed Owner/Operator Report {0} et: {1:hh\\:mm\\:ss}", condensedOwnerOperatorReport.responsestatus!.Trim(), timer.Elapsed);
Console.WriteLine("\nEND get Condensed Owner/Operator Report {0} et: {1:hh\\:mm\\:ss}", condensedOwnerOperatorReport.aircraftowneroperators!.Count.ToString(), timer.Elapsed);
}
timer.Stop();
Console.WriteLine("\nEND : {0} get Condensed Owner/Operator Report et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
returnValue = null;
// get aircraft flights list example
tmpString = string.Format(getAircraftFlightsList, accessToken.Trim());
restURL = apiBase + tmpString;
AcFlightDataOptions content4 = new()
{
aircraftid = 0,
airframetype = eAirFrameTypes.None,
sernbr = "",
regnbr = "N909XJ",
maketype = eMakeTypes.None,
modelid = 0,
make = "",
origin = "",
destination = "",
//startdate = "09-01-2024", // 00:00:00",
//enddate = "09-02-2024", // 06:00:00",
aclist = null,
modlist = null,
lastactionstartdate = "",
lastactionenddate = ""
};
timer.Reset();
timer.Start();
Console.WriteLine("\nSTART : {0} get aircraft flights list et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
// returnValue = customerAPI.GetFromAPI(bearerToken, restURL, content4, "PUT").Result;
responseAcFlightData aircraftFlightsList = new();
if (returnValue is not null)
{
aircraftFlightsList = JsonSerializer.Deserialize<responseAcFlightData>(returnValue)!;
if (aircraftFlightsList.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\nRETURN aircraft flights list {0} et: {1:hh\\:mm\\:ss}", returnValue.Trim(), timer.Elapsed);
else
Console.WriteLine("\nERROR : aircraft flights list {0} et: {1:hh\\:mm\\:ss}", aircraftFlightsList.responsestatus!.Trim(), timer.Elapsed);
Console.WriteLine("\nEND get aircraft flights list et: {0:hh\\:mm\\:ss}", timer.Elapsed);
}
timer.Stop();
Console.WriteLine("\nEND : {0} get aircraft flights list et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
returnValue = null;
// get gulfstream export example
tmpString = string.Format(getGulfstreamExport, accessToken.Trim());
restURL = apiBase + tmpString;
timer.Reset();
timer.Start();
Console.WriteLine("\nSTART : {0} get gulfstream export et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
//returnValue = customerAPI.GetFromAPI(bearerToken, restURL, null).Result;
Console.WriteLine("\nRESPONSE : {0} et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
responseGulfstreamExport gulfstreamExport = new();
if (returnValue is not null)
{
gulfstreamExport = JsonSerializer.Deserialize<responseGulfstreamExport>(returnValue, serializeOptions)!;
if (gulfstreamExport.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\nRETURN get gulfstream export {0} et: {1:hh\\:mm\\:ss}", returnValue.Trim(), timer.Elapsed);
else
Console.WriteLine("\nERROR : get gulfstream export {0} et: {1:hh\\:mm\\:ss}", gulfstreamExport.responsestatus!.Trim(), timer.Elapsed);
Console.WriteLine("\nEND get gulfstream export {0} et: {1:hh\\:mm\\:ss}", gulfstreamExport.exportaircraftcount!.ToString(), timer.Elapsed);
}
timer.Stop();
Console.WriteLine("\nEND : {0} get gulfstream export et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
returnValue = null;
// get gulfstream export example
tmpString = string.Format(getFulerLinxExport, "N516MX", accessToken.Trim());
restURL = apiBase + tmpString;
timer.Reset();
timer.Start();
Console.WriteLine("\nSTART : {0} get FuelerLinx export et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
//returnValue = customerAPI.GetFromAPI(bearerToken, restURL, null).Result;
Console.WriteLine("\nRESPONSE : {0} et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
responseFuelerLinxExport fuelerLinxExport = new();
if (returnValue is not null)
{
fuelerLinxExport = JsonSerializer.Deserialize<responseFuelerLinxExport>(returnValue, serializeOptions)!;
if (fuelerLinxExport.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\nRETURN get FuelerLinx export {0} et: {1:hh\\:mm\\:ss}", returnValue.Trim(), timer.Elapsed);
else
Console.WriteLine("\nERROR : get FuelerLinx export {0} et: {1:hh\\:mm\\:ss}", fuelerLinxExport.responsestatus!.Trim(), timer.Elapsed);
Console.WriteLine("\nEND get FuelerLinx export {0} et: {1:hh\\:mm\\:ss}", "1", timer.Elapsed);
}
timer.Stop();
Console.WriteLine("\nEND : {0} get FuelerLinx export et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
returnValue = null;
// get all company info example
tmpString = string.Format(getAllCompanyInfo, accessToken.Trim());
restURL = apiBase + tmpString;
timer.Reset();
timer.Start();
Console.WriteLine("\nSTART : {0} getAllCompanyInfo et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
//returnValue = customerAPI.GetFromAPI(bearerToken, restURL, null).Result;
responseAllCompanyInfo allCompanyInfo = new();
if (returnValue is not null)
{
allCompanyInfo = JsonSerializer.Deserialize<responseAllCompanyInfo>(returnValue)!;
if (allCompanyInfo.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\nRETURN getAllCompanyInfo {0} et: {1:hh\\:mm\\:ss}", returnValue.Trim(), timer.Elapsed);
else
Console.WriteLine("\nERROR : getAllCompanyInfo {0} et: {1:hh\\:mm\\:ss}", allCompanyInfo.responsestatus!.Trim(), timer.Elapsed);
Console.WriteLine("\nEND getAllCompanyInfo {0} et: {1:hh\\:mm\\:ss}", allCompanyInfo!.allcompanyinfo!.Count!.ToString(), timer.Elapsed);
}
timer.Stop();
Console.WriteLine("\nEND : {0} getAllCompanyInfo et: {1:hh\\:mm\\:ss}", DateTime.Now.ToLongTimeString(), timer.Elapsed);
returnValue = null;
// get copmpany list example
tmpString = string.Format(getCompanyList, accessToken.Trim());
restURL = apiBase + tmpString;
List<string> tmpState = new();
tmpState.Add("NY");
tmpState.Add("NJ");
tmpState.Add("PA");
CompListOptions content1 = new()
{
aircraftid = null,
name = "ab",
country = "",
city = "",
state = tmpState,
statename = null,
bustype = null,
airframetype = eAirFrameTypes.None,
maketype = eMakeTypes.None,
modelid = null,
make = null,
relationship = null,
isoperator = "",
actiondate = "",
companychanges = "false",
website = "",
complist = null
};
// returnValue = customerAPI.GetFromAPI(bearerToken, restURL, content1, "PUT").Result;
responseCompanyList companyList = new();
if (returnValue is not null)
{
companyList = JsonSerializer.Deserialize<responseCompanyList>(returnValue)!;
if (companyList.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\ncompany list {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : company list {0}", companyList.responsestatus!.Trim());
}
returnValue = null;
// get contact list example
tmpString = string.Format(getContactList, accessToken.Trim());
restURL = apiBase + tmpString;
ContListOptions content2 = new()
{
aircraftid = null,
companyid = 0,
companyname = "JETNET",
firstname = "",
lastname = "",
title = "",
email = "",
actiondate = "",
phonenumber = "",
contactchanges = "false",
contlist = null
};
// returnValue = customerAPI.GetFromAPI(bearerToken, restURL, content2, "PUT").Result;
responseContactList contactList = new();
if (returnValue is not null)
{
contactList = JsonSerializer.Deserialize<responseContactList>(returnValue)!;
if (contactList.responsestatus!.ToUpper().Contains(@"SUCCESS"))
Console.WriteLine("\ncontact list {0}", returnValue.Trim());
else
Console.WriteLine("\nERROR : contact list {0}", contactList.responsestatus!.Trim());
}