コード例 #1
0
        public bool CanAddToRow(int rowIndex, SlotRecord slot)
        {
            List <SlotRecord> row = bucket[rowIndex];

            foreach (SlotRecord slotRecord in row)
            {
                int currentLeft  = slotRecord.left;
                int currentRight = Math.Max(slotRecord.left + slotRecord.width, slotRecord.left + this.minSlotLength);

                int testLeft  = slot.left;
                int testRight = Math.Max(slotRecord.left + slotRecord.width, slotRecord.left + this.minSlotLength);

                if (currentLeft <= testLeft && testLeft <= currentRight)
                {
                    return(false);
                }

                if (testLeft <= currentLeft && currentLeft <= testRight)
                {
                    return(false);
                }
            }

            return(true);
        }
コード例 #2
0
        public void AddToBucket(SlotRecord slot)
        {
            if (slot.left == 0 && slot.width == 0)
            {
                return;
            }

            bool added    = false;
            int  rowIndex = 0;

            foreach (List <SlotRecord> row in bucket)
            {
                if (CanAddToRow(rowIndex, slot))
                {
                    AddToRow(rowIndex, slot);
                    added = true;
                    break;
                }
                rowIndex++;
            }

            if (!added)
            {
                AddToRow(rowIndex++, slot);
            }
        }
コード例 #3
0
 public void AddToRow(int rowIndex, SlotRecord slot)
 {
     if (bucket.Count < rowIndex + 1)
     {
         AddRow();
     }
     bucket[rowIndex].Add(slot);
     slot.row = rowIndex + 1;
 }
コード例 #4
0
        private XmlElement CreateSlotDiv(SlotRecord slot, List <DownGradeRecord> downgradeList)
        {
            //Adjust so dont overflow end of gantt
            if (slot.left + slot.width > 1440)
            {
                slot.width = 1440 - slot.left;
            }

            XmlElement outerDiv    = doc.CreateElement("div");
            XmlElement fromTimeDiv = doc.CreateElement("div");

            fromTimeDiv.SetAttribute("class", "fromTimeDiv");
            XmlElement toTimeDiv = doc.CreateElement("div");

            toTimeDiv.SetAttribute("class", "toTimeDiv");
            toTimeDiv.SetAttribute("style", $"left:{slot.width}px");

            String fromTime = slot.slotStartDateTime.ToString("HH:mm");
            String toTime   = slot.slotEndDateTime.ToString("HH:mm");


            fromTimeDiv.InnerText = fromTime;
            toTimeDiv.InnerText   = toTime;

            FlightRecord f      = slot.flight;
            int          radius = 0;
            //if (slot.left == 0) {
            //    radius = 0;
            //}


            XmlElement fltDiv = doc.CreateElement("div");

            //Vertical position in the row
            int top = 2 + (slot.row - 1) * 42;

            outerDiv.SetAttribute("style", $"position:absolute; left:{slot.left + 150}px; top:{top}px;");

            //Horizontal position in the row
            fltDiv.SetAttribute("style", $"width:{slot.width}px; border-radius:{radius}px; ");



            // Clsss dependand on whether it is on a downgraded stand.
            if (slot.onDowngrade)
            {
                string clazz = "ondowngradeflight";
                if (slot.towToStand != null)
                {
                    clazz += " fromStand";
                }
                if (slot.towFromStand != null)
                {
                    clazz += " toStand";
                }
                fltDiv.SetAttribute("class", clazz);
            }
            else
            {
                string clazz = "flight";
                if (slot.slotStand == "Unallocated")
                {
                    clazz = "flightUnallocated";
                }
                if (slot.towToStand != null)
                {
                    clazz += " fromStand";
                }
                if (slot.towFromStand != null)
                {
                    clazz += " toStand";
                }
                fltDiv.SetAttribute("class", clazz);
            }

            // The text for the flight
            fltDiv.InnerText = f.ToString(fltMap);

            outerDiv.AppendChild(fromTimeDiv);
            outerDiv.AppendChild(fltDiv);
            outerDiv.AppendChild(toTimeDiv);
            return(outerDiv);
        }
コード例 #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);
        }