Пример #1
0
        private static void GetDowngrades(DownGradeOptions opts)
        {
            if (!AMSTools.FileOK(opts.FileName))
            {
                return;
            }

            var t = GetFromToTime(opts.Today, opts.Yesterday, opts.Tomorrow, opts.From, opts.To);

            if (t == null)
            {
                return;
            }

            using (AMSIntegrationServiceClient client = new AMSIntegrationServiceClient(AMSTools.GetWSBinding(), AMSTools.GetWSEndPoint())) {
                try {
                    XmlElement res = client.GetStandDowngrades(Parameters.TOKEN, t.Item1, t.Item2, Parameters.APT_CODE, AirportIdentifierType.IATACode);

                    //Output in XML format
                    AMSTools.Out(AMSTools.PrintXML(res.OuterXml), opts.FileName);
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                }
            }
        }
Пример #2
0
        public static string GetAircraftTypes()
        {
            using (AMSIntegrationServiceClient client = new AMSIntegrationServiceClient(AMSTools.GetWSBinding(), AMSTools.GetWSEndPoint())) {
                try {
                    XmlElement res = client.GetAircraftTypes(Parameters.TOKEN);
                    return(res.OuterXml);
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                }
            }

            return(null);
        }
Пример #3
0
        public static string GetAirlines(bool csv = false)
        {
            using (AMSIntegrationServiceClient client = new AMSIntegrationServiceClient(AMSTools.GetWSBinding(), AMSTools.GetWSEndPoint())) {
                try {
                    XmlElement res = client.GetAirlines(Parameters.TOKEN);
                    if (csv)
                    {
                        return(ConvertToCSV(res));
                    }
                    else
                    {
                        return(res.OuterXml);
                    }
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                }
            }

            return(null);
        }
Пример #4
0
        public void UpdateDowngrades(bool reset = false)
        {
            Controller.SOP("Updating downgrades for type " + this.resourceType);

            try {
                AMSIntegrationServiceClient client = new AMSIntegrationServiceClient();
                XmlElement x;
                switch (this.resourceType)
                {
                case "CheckIn":
                    x = client.GetCheckInDowngrades(Parameters.TOKEN, Parameters.EARLIEST_DOWNGRADE, Parameters.LATEST_DOWNGRADE, Parameters.APT_CODE, AirportIdentifierType.IATACode);
                    SetDowngrades(this.CreateDowngrades(x, "CheckInDowngrade"), reset);
                    break;

                case "Gate":
                    x = client.GetGateDowngrades(Parameters.TOKEN, Parameters.EARLIEST_DOWNGRADE, Parameters.LATEST_DOWNGRADE, Parameters.APT_CODE, AirportIdentifierType.IATACode);
                    SetDowngrades(this.CreateDowngrades(x, "GateDowngrade"), reset);
                    break;

                case "Chute":
                    x = client.GetChuteDowngrades(Parameters.TOKEN, Parameters.EARLIEST_DOWNGRADE, Parameters.LATEST_DOWNGRADE, Parameters.APT_CODE, AirportIdentifierType.IATACode);
                    SetDowngrades(this.CreateDowngrades(x, "ChuteDowngrade"), reset);
                    break;

                case "Stand":
                    x = client.GetStandDowngrades(Parameters.TOKEN, Parameters.EARLIEST_DOWNGRADE, Parameters.LATEST_DOWNGRADE, Parameters.APT_CODE, AirportIdentifierType.IATACode);
                    SetDowngrades(this.CreateDowngrades(x, "StandDowngrade"), reset);
                    break;

                case "Carousel":
                    x = client.GetCarouselDowngrades(Parameters.TOKEN, Parameters.EARLIEST_DOWNGRADE, Parameters.LATEST_DOWNGRADE, Parameters.APT_CODE, AirportIdentifierType.IATACode);
                    SetDowngrades(this.CreateDowngrades(x, "CarouselDowngrade"), reset);
                    break;
                }
                client.Close();

                Controller.SOP(this.ToString());
            } catch (Exception ex) {
                Controller.SOP(ex.Message, true);
            }
        }
Пример #5
0
        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);
        }
Пример #6
0
        private static int GetFlight(FlightOptions 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);
            }


            double fromOffset = (t.Item1 - DateTime.Now).TotalDays;
            double toOffset   = (t.Item2 - DateTime.Now).TotalDays;

            int start = Convert.ToInt32(Math.Floor(fromOffset));
            int stop  = Convert.ToInt32(Math.Ceiling(toOffset));


            string result = @"<Flights xmlns=""http://www.sita.aero/ams6-xml-api-datatypes>"">";

            for (int off = start; off <= stop; off++)
            {
                bool     found = false;
                DateTime date  = DateTime.Now.AddDays(off);

                using (AMSIntegrationServiceClient client = new AMSIntegrationServiceClient(AMSTools.GetWSBinding(), AMSTools.GetWSEndPoint())) {
                    FlightId arr = AMSTools.GetFlightID(true, opts.Airline, opts.FlightNum, off);

                    try {
                        XmlElement res = client.GetFlight(Parameters.TOKEN, arr);

                        if (!res.OuterXml.Contains("FLIGHT_NOT_FOUND"))
                        {
                            found   = true;
                            result += res.OuterXml;
                            Console.WriteLine($"Arrival Flight {opts.Airline}{opts.FlightNum} found for {date}");
                        }
                    } catch (Exception e) {
                        Console.WriteLine(e.Message);
                    }


                    FlightId dep = AMSTools.GetFlightID(false, opts.Airline, opts.FlightNum, off);

                    try {
                        XmlElement res = client.GetFlight(Parameters.TOKEN, dep);
                        if (!res.OuterXml.Contains("FLIGHT_NOT_FOUND"))
                        {
                            found   = true;
                            result += res.OuterXml;
                            Console.WriteLine($"Departure Flight {opts.Airline}{opts.FlightNum} found for {date}");
                        }
                    } catch (Exception e) {
                        Console.WriteLine(e.Message);
                    }
                }

                if (!found)
                {
                    Console.WriteLine($"Flight {opts.Airline}{opts.FlightNum} not found for {date}");
                }
            }

            result += "</Flights>";

            if (opts.CSV)
            {
                //Output in CSV format
                AMSTools.Out(GetCSV(result, "Flight", BaseType.Flight, ".//ams:FlightState", opts.FlightNum, opts.Linked), opts.FileName);
            }
            else
            {
                //Output in XML format
                AMSTools.Out(AMSTools.PrintXML(result), opts.FileName);
            }

            return(1);
        }
Пример #7
0
        private static int GetFlights(FlightsOptions 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);
            }

            using (AMSIntegrationServiceClient client = new AMSIntegrationServiceClient(AMSTools.GetWSBinding(), AMSTools.GetWSEndPoint())) {
                try {
                    XmlElement res = client.GetFlights(Parameters.TOKEN, t.Item1, t.Item2, Parameters.APT_CODE, AirportIdentifierType.IATACode);

                    if (!res.OuterXml.Contains("FLIGHT_NOT_FOUND"))
                    {
                        if (opts.Airline == null)
                        {
                            // If there is no specific airline specified

                            if (opts.CSV)
                            {
                                //Output in CSV format
                                AMSTools.Out(GetCSV(res.OuterXml, "Flight", BaseType.Flight, ".//ams:FlightState"), opts.FileName);
                            }
                            else
                            {
                                //Output in XML format
                                AMSTools.Out(AMSTools.PrintXML(res.OuterXml), opts.FileName);
                            }
                        }
                        else
                        {
                            // A specifc airline was requested
                            XmlNamespaceManager nsmgr = new XmlNamespaceManager(res.OwnerDocument.NameTable);
                            nsmgr.AddNamespace("ams", "http://www.sita.aero/ams6-xml-api-datatypes");

                            string result = @"<Flights xmlns=""http://www.sita.aero/ams6-xml-api-datatypes>"">";

                            foreach (XmlElement el in res.SelectNodes("//ams:Flights/ams:Flight", nsmgr))
                            {
                                {
                                    XmlNamespaceManager nsmgr2 = new XmlNamespaceManager(el.OwnerDocument.NameTable);
                                    nsmgr2.AddNamespace("ams", "http://www.sita.aero/ams6-xml-api-datatypes");

                                    XmlNode node = el.SelectSingleNode("//ams:FlightId/ams:AirlineDesignator[@codeContext='IATA']", nsmgr2);
                                    if (node?.InnerText == opts.Airline)
                                    {
                                        result += el.OuterXml;
                                    }
                                    else
                                    {
                                        Console.WriteLine($"Flight rejected. Airline Code = {node.InnerText}");
                                    }
                                }
                            }
                            result += "</Flights>";

                            if (opts.CSV)
                            {
                                //Output in CSV format
                                AMSTools.Out(GetCSV(result, "Flight", BaseType.Flight, ".//ams:FlightState"), opts.FileName);
                            }
                            else
                            {
                                //Output in XML format
                                AMSTools.Out(AMSTools.PrintXML(result), opts.FileName);
                            }
                        }
                    }
                } catch (Exception e) {
                    Console.WriteLine(e.Message);
                }
            }


            return(1);
        }