示例#1
0
        public XmlElement AddGridRow(StandRecord stand, int rowIndex)
        {
            XmlElement row = doc.CreateElement("div");

            int rowHeight = Math.Max(42, 42 * stand.numRows);

            row.SetAttribute("style", $"width: 100px; height: {rowHeight}px; position: relative; display: flex; align-items:center; border-bottom: solid 1px gray; width:1590px");
            if (rowIndex % 2 == 0)
            {
                row.SetAttribute("class", "odd");
            }
            else
            {
                row.SetAttribute("class", "even");
            }
            XmlElement titleCell = doc.CreateElement("div");

            titleCell.InnerText = stand.name;
            titleCell.SetAttribute("style", $"left:0px; width:150px");


            row.AppendChild(titleCell);

            for (int i = 0; i < 24; i++)
            {
                XmlElement cell = doc.CreateElement("div");
                cell.SetAttribute("class", "hourIndicator");
                cell.SetAttribute("style", $"left:{150 + i * 60}px; width:50px");
                cell.InnerText = "&nbsp;";
                row.AppendChild(cell);
            }

            return(row);
        }
示例#2
0
        public List <SlotRecord> GetSlotsList(StandRecord stand)
        {
            if (stand.id == null)
            {
                return(new List <SlotRecord>());
            }

            foreach (SlotRecord slot in stand.slotList)
            {
                AddToBucket(slot);
            }

            List <SlotRecord> list = new List <SlotRecord>();

            foreach (List <SlotRecord> row in bucket)
            {
                list.AddRange(row);
            }
            return(list);
        }
示例#3
0
        private void AddTowFlags()
        {
            foreach (var pair in this.standMap)
            {
                StandRecord stand = pair.Value;
                foreach (TowRecord rec in stand.fromTows)
                {
                    foreach (SlotRecord slot in stand.slotList)
                    {
                        FlightRecord flt = slot.flight;
                        if (flt.FlightDescriptor == rec.arrDesc ||
                            flt.FlightDescriptor == rec.depDesc ||
                            flt.LinkedFlightDescriptor == rec.arrDesc ||
                            flt.LinkedFlightDescriptor == rec.depDesc
                            )
                        {
                            slot.towToStand = $" ({rec.toStand})";
                        }
                    }
                }

                foreach (TowRecord rec in stand.toTows)
                {
                    foreach (SlotRecord slot in stand.slotList)
                    {
                        FlightRecord flt = slot.flight;
                        if (flt.FlightDescriptor == rec.arrDesc ||
                            flt.FlightDescriptor == rec.depDesc ||
                            flt.LinkedFlightDescriptor == rec.arrDesc ||
                            flt.LinkedFlightDescriptor == rec.depDesc
                            )
                        {
                            slot.towFromStand = $" ({rec.fromStand})";
                        }
                    }
                }
            }
        }
示例#4
0
        public GanttHTML(IEnumerable <string> sets)
        {
            this.sets = sets;

            StandRecord unallocated = new StandRecord();

            unallocated.name      = "Unallocated";
            unallocated.area      = "Unallocated";
            unallocated.id        = "Unallocated";
            unallocated.sortOrder = Int32.MaxValue;

            standMap.Add(unallocated.id, unallocated);

            List <StandRecord> u = new List <StandRecord>();

            u.Add(unallocated);
            areaMap.Add("Unallocated", u);


            root = doc.CreateElement("hmtl");
            doc.AppendChild(root);
            this.head       = doc.CreateElement("head");
            this.body       = doc.CreateElement("body");
            this.style      = doc.CreateElement("style");
            css             = System.IO.File.ReadAllText(@"GanttStyle.css");
            style.InnerText = this.css;

            setsDoc.LoadXml(System.IO.File.ReadAllText(@"StandSets.xml"));
            foreach (XmlNode set in setsDoc.SelectNodes("//Set"))
            {
                List <string> areas = new List <string>();
                setsMap.Add(set.Attributes["name"].Value, areas);
                foreach (XmlNode area in set.SelectNodes("./Area"))
                {
                    areas.Add(area.Attributes["name"].Value);
                }
            }
        }
示例#5
0
        private void DeconflictSlotOverlay()
        {
            // Go through the slots for each stand and make sure they dont overlay each other
            // By moving them to the next row if necessary.
            foreach (var pair in this.standMap)
            {
                StandRecord stand = pair.Value;

                // if only 0 or 1 slot, then there is no overlap, so continue;
                if (stand.slotList.Count <= 1)
                {
                    stand.numRows = 1;
                    continue;
                }

                //Sort from lowest to highest.
                stand.slotList.Sort((p, q) => p.left.CompareTo(q.left));

                Bucket bucket = new Bucket();
                stand.slotList = bucket.GetSlotsList(stand);
                stand.numRows  = bucket.GetRows();
            }

            // Now Lets adjust for flight allocated to downgrade stands
            foreach (var pair in this.standMap)
            {
                StandRecord stand = pair.Value;
                if (stand.downgradeList.Count == 0 || stand.slotList.Count == 0)
                {
                    continue;
                }

                stand.numRows++;
                foreach (SlotRecord slot in stand.slotList)
                {
                    slot.row++;
                    foreach (DownGradeRecord down in stand.downgradeList)
                    {
                        if (slot.slotEndDateTime < down.start || slot.slotStartDateTime > down.end)
                        {
                            continue;
                        }
                        if (slot.slotStartDateTime >= down.start && slot.slotStartDateTime <= down.end)
                        {
                            slot.onDowngrade = true;
                            break;
                        }
                        if (slot.slotEndDateTime >= down.start && slot.slotEndDateTime <= down.end)
                        {
                            slot.onDowngrade = true;
                            break;
                        }
                        if (slot.slotEndDateTime >= down.end && slot.slotStartDateTime <= down.start)
                        {
                            slot.onDowngrade = true;
                            break;
                        }
                    }
                }
            }

            return;
        }
示例#6
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);
        }