private static int GetTowings(TowingsOptions opts) { if (!AMSTools.FileOK(opts.FileName)) { return(-1); } var t = GetFromToTime(opts.Today, opts.Yesterday, opts.Tomorrow, opts.From, opts.To); if (t == null) { return(-1); } string start = t.Item1.ToString("yyyy-MM-ddTHH:mm:ss"); string end = t.Item2.ToString("yyyy-MM-ddTHH:mm:ss"); string uri = Parameters.AMS_REST_SERVICE_URI + "/" + Parameters.APT_CODE + "/Towings/" + start + "/" + end; if (opts.CSV) { AMSTools.Out(GetCSV(AMSTools.GetRestURI(uri).Result, "Towing", BaseType.Towing, null), opts.FileName); } else { AMSTools.Out(AMSTools.PrintXML(AMSTools.GetRestURI(uri).Result), opts.FileName); } return(1); }
private static int GetCarousels(CarouselOptions opts) { if (!AMSTools.FileOK(opts.FileName)) { return(-1); } try { string uri = Parameters.AMS_REST_SERVICE_URI + $"{Parameters.APT_CODE}/Carousels"; string result = AMSTools.GetRestURI(uri).Result; AMSTools.Out(AMSTools.PrintXML(result), opts.FileName); } catch (Exception e) { Console.WriteLine(e.Message); } return(1); }
private static int GetStand(StandOptions opts) { if (!AMSTools.FileOK(opts.FileName)) { return(-1); } try { string uri = Parameters.AMS_REST_SERVICE_URI + $"{Parameters.APT_CODE}/Stands"; string result = AMSTools.GetRestURI(uri).Result; XElement xmlRoot = XDocument.Parse(result).Root; XElement db = (from n in xmlRoot.Descendants() where (n.Name == "FixedResource" && n.Elements("Name").FirstOrDefault().Value == opts.Stand) select n).FirstOrDefault <XElement>(); if (db == null) { Console.WriteLine($"Stand {opts.Stand} not found"); return(-1); } AMSTools.Out(AMSTools.PrintXML(db.ToString()), opts.FileName); } catch (Exception e) { Console.WriteLine(e.Message); } return(1); }
public bool Prepare() { // Calculate the time of the zero time DateTime now = DateTime.Now; zeroTime = now.AddHours(-3); zeroTime = new DateTime(zeroTime.Year, zeroTime.Month, zeroTime.Day, zeroTime.Hour, 0, 0); head.AppendChild(style); root.AppendChild(head); root.AppendChild(body); try { string result = AMSTools.GetRestURI(Parameters.AMS_REST_SERVICE_URI + $"{Parameters.APT_CODE}/Stands").Result; standsDoc = new XmlDocument(); standsDoc.LoadXml(result); } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("Retrieving Stands"); // Create the StandRecords and put them into lists according to Stand Area foreach (XmlNode stand in standsDoc.SelectNodes(".//FixedResource")) { StandRecord standRecord = new StandRecord(stand); standMap.Add(standRecord.id, standRecord); if (!areaMap.ContainsKey(standRecord.area)) { areaMap.Add(standRecord.area, new List <StandRecord>()); } areaMap[standRecord.area].Add(standRecord); } Console.WriteLine("Retrieving Downgrades"); using (AMSIntegrationServiceClient client = new AMSIntegrationServiceClient(AMSTools.GetWSBinding(), AMSTools.GetWSEndPoint())) { // Get the Downgrade records and add them to the appropriat stand try { XmlElement xdowngrades = client.GetStandDowngrades(Parameters.TOKEN, DateTime.Now.AddHours(-24), DateTime.Now.AddHours(24), Parameters.APT_CODE, AirportIdentifierType.IATACode); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xdowngrades.OwnerDocument.NameTable); nsmgr.AddNamespace("ams", "http://www.sita.aero/ams6-xml-api-datatypes"); foreach (XmlElement el in xdowngrades.SelectNodes("//ams:StandDowngradeState", nsmgr)) { DownGradeRecord drec = new DownGradeRecord(el, nsmgr); foreach (string standID in drec.standList) { standMap[standID].downgradeList.Add(drec); } } } catch (Exception e) { Debug.WriteLine(e.Message); } } Console.WriteLine("Retrieving Flights"); using (AMSIntegrationServiceClient client = new AMSIntegrationServiceClient(AMSTools.GetWSBinding(), AMSTools.GetWSEndPoint())) { XmlElement res = client.GetFlights(Parameters.TOKEN, DateTime.Now.AddHours(-24), DateTime.Now.AddHours(24), Parameters.APT_CODE, AirportIdentifierType.IATACode); XmlNamespaceManager nsmgr = new XmlNamespaceManager(res.OwnerDocument.NameTable); nsmgr.AddNamespace("ams", "http://www.sita.aero/ams6-xml-api-datatypes"); // Create the flight records and add them to the stands. Position them horizontally. foreach (XmlElement el in res.SelectNodes("//ams:Flights/ams:Flight", nsmgr)) { { FlightRecord flight = new FlightRecord(el, nsmgr); fltMap.Add(flight.flightUniqueID, flight); XmlNode slots = el.SelectSingleNode("./ams:FlightState/ams:StandSlots", nsmgr); if (slots != null) { // Iterate through each of the Stand Slots for the flight foreach (XmlNode slot in slots.SelectNodes("./ams:StandSlot", nsmgr)) { SlotRecord slotRecord = new SlotRecord(slot, nsmgr, flight); if (slotRecord.slotStand == null) { slotRecord.slotStand = "Unallocated"; } if (!slotRecord.flight.ShowFlight()) { continue; } if (slotRecord.slotEndDateTime < this.zeroTime || slotRecord.slotStartDateTime > this.zeroTime.AddHours(23)) { //Outside range of Gantt continue; } TimeSpan tss = slotRecord.slotStartDateTime - this.zeroTime; TimeSpan tse = slotRecord.slotEndDateTime - this.zeroTime; // End of slot before start of zeroTime if (tse.TotalMinutes < 0) { continue; } // Start of slot more than end of chart if (tss.TotalHours > 23) { continue; } int width = Convert.ToInt32(tse.TotalMinutes - tss.TotalMinutes); int left = Convert.ToInt32(tss.TotalMinutes); if (left < 0) { width += left; left = 0; } slotRecord.left = left; slotRecord.width = width; slotRecord.row = 1; standMap[slotRecord.slotStand].slotList.Add(slotRecord); } } else { // No Stand Slot Defined for the flight SlotRecord slotRecord = new SlotRecord(null, nsmgr, flight); standMap["Unallocated"].slotList.Add(slotRecord); } } } } // Get the towings { Console.WriteLine("Retrieving Tow Events"); string start = DateTime.Now.AddHours(-24).ToString("yyyy-MM-ddTHH:mm:ss"); string end = DateTime.Now.AddHours(24).ToString("yyyy-MM-ddTHH:mm:ss"); string uri = Parameters.AMS_REST_SERVICE_URI + "/" + Parameters.APT_CODE + "/Towings/" + start + "/" + end; string towingsXML = AMSTools.GetRestURI(uri).Result; var towsDoc = new XmlDocument(); towsDoc.LoadXml(towingsXML); //Add the tow records to the stand foreach (XmlElement el in towsDoc.SelectNodes("//Towing")) { TowRecord towRec = new TowRecord(el); try { standMap[towRec.fromStand].fromTows.Add(towRec); } catch (Exception e) { Debug.WriteLine(e.Message); } try { standMap[towRec.toStand].toTows.Add(towRec); } catch (Exception e) { Debug.WriteLine(e.Message); } } } // Position the flight vertically withing row to avoid overlays Console.WriteLine("Arranging Layout"); DeconflictSlotOverlay(); //Add Tow Flag to slot record AddTowFlags(); return(true); }
public async Task Execute() { if (dataFromFile) { Console.WriteLine("\n======> Reading Data from files <=========="); } else { Console.WriteLine("\n======> Checking AMS Access <=========="); bool amsOK = AMSTools.IsAMSWebServiceAvailable().Result; if (!amsOK) { Console.WriteLine("======> Error: Cannot access AMS <=========="); Console.WriteLine("\nHit Any Key to Exit.."); Console.ReadKey(); return; } else { Console.WriteLine("======> AMS Access Confirmed <=========="); } } try { if (hasAirport) { Console.WriteLine("\n======> Checking Airports <=========="); XmlElement airports = await GetXML(GETAIRPORTSTemplate, Parameters.TOKEN, "http://www.sita.aero/ams6-xml-api-webservice/IAMSIntegrationService/GetAirports", Parameters.AMS_WEB_SERVICE_URI, "airports.xml"); Check(airports, "//ams:Airport", "./ams:AirportState/ams:Value[@propertyName='Name']", BaseType.Airport); } if (hasAirline) { Console.WriteLine("\n======> Checking Airlines <=========="); XmlElement airlines = await GetXML(GETAIRLINESTemplate, Parameters.TOKEN, "http://www.sita.aero/ams6-xml-api-webservice/IAMSIntegrationService/GetAirlines", Parameters.AMS_WEB_SERVICE_URI, "airlines.xml"); Check(airlines, "//ams:Airline", "./ams:AirlineState/ams:Value[@propertyName='Name']", BaseType.Airline); } if (hasAircraft) { Console.WriteLine("\n======> Checking Aircraft <=========="); XmlElement aircrafts = await GetXML(GETAIRCRAFTSTemplate, Parameters.TOKEN, "http://www.sita.aero/ams6-xml-api-webservice/IAMSIntegrationService/GetAircrafts", Parameters.AMS_WEB_SERVICE_URI, "aircrafts.xml"); Check(aircrafts, "//ams:Aircraft", "./ams:AircraftId/ams:Registration", BaseType.Aircraft); } if (hasAircraftType) { Console.WriteLine("\n======> Checking Aircraft Types <=========="); XmlElement actypes = await GetXML(GETAIRCRAFTTYPESSTemplate, Parameters.TOKEN, "http://www.sita.aero/ams6-xml-api-webservice/IAMSIntegrationService/GetAircraftTypes", Parameters.AMS_WEB_SERVICE_URI, "actypes.xml"); Check(actypes, "//ams:AircraftType", "./ams:AircraftTypeState/ams:Value[@propertyName='Name']", BaseType.AircraftType); } if (hasCheckins) { Console.WriteLine("\n======> Checking Checkins <=========="); string uri = Parameters.AMS_REST_SERVICE_URI + $"{Parameters.APT_CODE}/CheckIns"; string result = AMSTools.GetRestURI(uri).Result; Check(result, BaseType.Checkin); } if (hasGates) { Console.WriteLine("\n======> Checking Gates <=========="); string uri = Parameters.AMS_REST_SERVICE_URI + $"{Parameters.APT_CODE}/Gates"; string result = AMSTools.GetRestURI(uri).Result; Check(result, BaseType.Gate); } if (hasStands) { Console.WriteLine("\n======> Checking Stands <=========="); string uri = Parameters.AMS_REST_SERVICE_URI + $"{Parameters.APT_CODE}/Stands"; string result = AMSTools.GetRestURI(uri).Result; Check(result, BaseType.Stand); } if (hasCarousels) { Console.WriteLine("\n======> Checking Carousels <=========="); string uri = Parameters.AMS_REST_SERVICE_URI + $"{Parameters.APT_CODE}/Carousels"; string result = AMSTools.GetRestURI(uri).Result; Check(result, BaseType.Carousel); } } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine("\nHit Any Key to Exit.."); Console.ReadKey(); } Console.WriteLine("\nHit Any Key to Exit.."); Console.ReadKey(); }