-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
97 lines (84 loc) · 3.74 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
using System;
using System.Collections.Generic;
using System.IO;
using ConsoleTable;
using System.Linq;
using Microsoft.Extensions.Configuration;
namespace VatBoardCons
{
class Program
{
public IConfiguration config;
static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddJsonFile("VatBoard.json", true, true)
.Build();
string remoteUri = config["VATSIMURL"];
string dataFile = config["VATSIMDATAFILE"];
if (!File.Exists(dataFile))
File.Create(dataFile).Close();
Util.SetLastDownload(true, dataFile);
string lookFor;
int refreshInterval;
var VATSIMList = new List<VatLine>();
var tableArrivals = new Table();
var tableDepartures = new Table();
Console.CursorSize = 100;
Console.BackgroundColor = ConsoleColor.Black;
Console.Clear();
Util.typeWriter(
Util.ascVATSIM,
4,
(ConsoleColor)Convert.ToInt32(config["ASCIICOLORVATBOARD"]));
Util.WriteLn(
"\n(c) 2021 - Elias Stassinos - More Info: http://www.estassinos.com/vatboard ",
ConsoleColor.DarkGreen,
ConsoleColor.White);
Util.WriteLn(
string.Format("\n\nVersion: {0} ", Util.GetVersion()),
ConsoleColor.DarkGreen,
ConsoleColor.White, false);
lookFor = ReadLine.Read("\n\nAirport ICAO:", "").ToUpper();
refreshInterval = Convert.ToInt32(ReadLine.Read("\nRefresh Interval (default 10sec):", "10"));
do
{
tableArrivals.ClearRows();
tableDepartures.ClearRows();
VATSIMList = Util.DownloadVatsimData(remoteUri, dataFile, config["VATSIMINTERVAL"]);
tableArrivals.SetHeaders("Callsign", "Aircraft", "Departure", "Arrival", "TAS", "Altitude", "Distance To");
VATSIMList.Where(d => d.planned_destairport == lookFor).OrderBy(o => o.DistanceTo).ToList().ForEach(d =>
{
tableArrivals.AddRow(
d.callsign,
d.planned_aircraft,
d.planned_depairport,
d.planned_destairport,
d.planned_tascruise,
d.altitude,
d.DistanceTo.ToString("N0"));
});
tableDepartures.SetHeaders("Callsign", "Aircraft", "Departure", "Arrival", "TAS", "Altitude", "Distance From");
VATSIMList.Where(d => d.planned_depairport == lookFor).OrderBy(o => o.DistanceFrom).ToList().ForEach(d =>
{
tableDepartures.AddRow(
d.callsign,
d.planned_aircraft,
d.planned_depairport,
d.planned_destairport,
d.planned_tascruise,
d.altitude,
d.DistanceFrom.ToString("N0"));
});
Console.Clear();
Util.typeWriter(Util.ascARRIVALS, 4, (ConsoleColor)Convert.ToInt32(config["ASCIICOLORARRIVALS"]));
Util.typeWriter(tableArrivals.ToString(), 4);
System.Threading.Thread.Sleep(5000);
Console.Clear();
Util.typeWriter(Util.ascDEPARTURES, 4, (ConsoleColor)Convert.ToInt32(config["ASCIICOLORDEPARTURES"]));
Util.typeWriter(tableDepartures.ToString(), 4);
System.Threading.Thread.Sleep(refreshInterval * 1000);
} while (true);
}
}
}