Пример #1
0
        //checks if a time table is valid
        public static Boolean IsTimeTableValid(RouteTimeTable timeTable, FleetAirliner airliner, List<RouteTimeTableEntry> entries, Boolean withSlots = true)
        {
            foreach (RouteTimeTableEntry e in timeTable.Entries)
            {

                if (!IsRouteEntryValid(e, airliner, entries, withSlots))
                    return false;
            }
            return true;
        }
Пример #2
0
        public RouteTimeTableEntry(RouteTimeTable timeTable, DayOfWeek day, TimeSpan time, RouteEntryDestination destination)
        {
            Guid id = Guid.NewGuid();

            this.Day         = day;
            this.Time        = time;
            this.TimeTable   = timeTable;
            this.Destination = destination;
            this.ID          = id.ToString();
        }
Пример #3
0
        public static Boolean IsRoutePlannerTimeTableValid(RouteTimeTable timeTable, FleetAirliner airliner, List<RouteTimeTableEntry> entries, Boolean withSlots = true)
        {
            var tEntries = new List<RouteTimeTableEntry>();
            tEntries.AddRange(entries);
            tEntries.AddRange(timeTable.Entries);

             foreach (RouteTimeTableEntry e in timeTable.Entries)
            {
                var cEntries = new List<RouteTimeTableEntry>(tEntries);
                cEntries.Remove(e);

                if (!IsRouteEntryValid(e, airliner, cEntries, withSlots))
                    return false;
            }
            return true;
        }
Пример #4
0
        private void EntryChanged_Event(object sender, System.Windows.RoutedEventArgs e)
        {
            object[] entries =  e.OriginalSource as object[];

            TimelineEntry oldEntry = entries[0] as TimelineEntry;
            TimelineEntry newEntry = entries[1] as TimelineEntry;

            RouteTimeTableEntry oEntry = (RouteTimeTableEntry)oldEntry.Source;

            RouteTimeTable rt = new RouteTimeTable(oEntry.TimeTable.Route);
            RouteTimeTableEntry nEntry = new RouteTimeTableEntry(rt,(DayOfWeek)newEntry.StartTime.Days,newEntry.StartTime,oEntry.Destination);
            nEntry.Airliner = this.Airliner;
            rt.addEntry(nEntry);

            List<RouteTimeTableEntry> tEntries = new List<RouteTimeTableEntry>(this.Entries);
            tEntries.Remove(oEntry);

            if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, tEntries))
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok);
            else
            {
                this.Entries.Remove(oEntry);

                this.Entries.Add(nEntry);
            }
        }
Пример #5
0
        //adds entries to the planner
        private void addEntries(List<DayOfWeek> days)
        {
            Route route = (Route)cbHomebound.SelectedItem;

            Airport origin = (Airport)cbOutbound.SelectedItem;
            Airport airport = route.Destination1 == origin ? route.Destination2 : route.Destination1;

            TimeSpan time = new TimeSpan(tpTime.Value.Value.Hour, tpTime.Value.Value.Minute, 0);

            string flightCode = this.Airliner.Airliner.Airline.Profile.IATACode + txtSchedulerFlightNumber.Text;

            RouteTimeTable rt = new RouteTimeTable(route);

            foreach (DayOfWeek dayOfWeek in days)
            {
                RouteTimeTableEntry entry = new RouteTimeTableEntry(route.TimeTable, dayOfWeek, time, new RouteEntryDestination(airport, flightCode));
                entry.Airliner = this.Airliner;

                rt.addEntry(entry);
            }

            if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, this.Entries.ToList()))
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok);
            else
            {

                foreach (RouteTimeTableEntry entry in rt.Entries)
                {
                    this.Entries.Add(entry);

                }

            }
        }
Пример #6
0
        //creates the entries for the stopoverflight
        private void createEntries(RouteTimeTableEntry mainEntry)
        {
            List <Route> routes = mainEntry.TimeTable.Route.Stopovers.SelectMany(s => s.Legs).ToList();

            TimeSpan time = mainEntry.Time;

            Boolean isInbound = mainEntry.DepartureAirport == mainEntry.TimeTable.Route.Destination2;

            if (isInbound)
            {
                routes.Reverse();
            }

            foreach (Route route in routes)
            {
                RouteTimeTable timetable = new RouteTimeTable(route);

                RouteTimeTableEntry entry;
                //inbound
                if (isInbound)
                {
                    entry = new RouteTimeTableEntry(timetable, mainEntry.Day, time, new RouteEntryDestination(route.Destination1, mainEntry.Destination.FlightCode));

                    time            = time.Add(entry.TimeTable.Route.getFlightTime(mainEntry.Airliner.Airliner.Type)).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(mainEntry.Airliner));
                    entry.Airliner  = mainEntry.Airliner;
                    entry.MainEntry = mainEntry;
                }
                //outbound
                else
                {
                    entry           = new RouteTimeTableEntry(timetable, mainEntry.Day, time, new RouteEntryDestination(route.Destination2, mainEntry.Destination.FlightCode));
                    entry.Airliner  = mainEntry.Airliner;
                    entry.MainEntry = mainEntry;

                    time = time.Add(entry.TimeTable.Route.getFlightTime(mainEntry.Airliner.Airliner.Type)).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(mainEntry.Airliner));
                }

                if (route.Type == Route.RouteType.Passenger || route.Type == Route.RouteType.Mixed)
                {
                    List <FlightAirlinerClass> classes = new List <FlightAirlinerClass>();
                    foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
                    {
                        FlightAirlinerClass faClass;
                        if (isInbound)
                        {
                            faClass = new FlightAirlinerClass(((PassengerRoute)route).getRouteAirlinerClass(aClass.Type), PassengerHelpers.GetStopoverFlightPassengers(this.Airliner, aClass.Type, route.Destination2, route.Destination1, routes, isInbound));
                        }
                        else
                        {
                            faClass = new FlightAirlinerClass(((PassengerRoute)route).getRouteAirlinerClass(aClass.Type), PassengerHelpers.GetStopoverFlightPassengers(this.Airliner, aClass.Type, route.Destination1, route.Destination2, routes, isInbound));
                        }

                        classes.Add(faClass);
                    }

                    this.AllClasses.Add(entry, classes);
                }
                if (route.Type == Route.RouteType.Cargo || route.Type == Route.RouteType.Mixed)
                {
                    if (isInbound)
                    {
                        this.AllCargo.Add(entry, PassengerHelpers.GetStopoverFlightCargo(this.Airliner, route.Destination2, route.Destination1, routes, isInbound));
                    }
                    else
                    {
                        this.AllCargo.Add(entry, PassengerHelpers.GetStopoverFlightCargo(this.Airliner, route.Destination1, route.Destination2, routes, isInbound));
                    }
                }
            }
        }
Пример #7
0
        //loads a route
        private static Route LoadRoute(XmlElement routeNode, Airline airline, Route.RouteType routetype = Route.RouteType.Passenger)
        {
            string id = routeNode.Attributes["id"].Value;
            Airport dest1 = Airports.GetAirport(routeNode.Attributes["destination1"].Value);
            Airport dest2 = Airports.GetAirport(routeNode.Attributes["destination2"].Value);
            Boolean isBanned = Convert.ToBoolean(routeNode.Attributes["isbanned"].Value);

            if (routeNode.HasAttribute("type"))
                routetype = (Route.RouteType)Enum.Parse(typeof(Route.RouteType), routeNode.Attributes["type"].Value);

            Route route;

            if (routetype == Route.RouteType.Passenger || routetype == Route.RouteType.Mixed)
                route = new PassengerRoute(id, dest1, dest2, DateTime.Now,0);
            else
                route = new CargoRoute(id, dest1, dest2, DateTime.Now,0);

            route.Banned = isBanned;

            /* foreach (StopoverRoute stopover in route.Stopovers)
            {
                XmlElement routeStopoverNode = xmlDoc.CreateElement("stopover");
                routeStopoverNode.SetAttribute("airport", stopover.Stopover.Profile.ID);

                XmlElement stopoverLegsNode = xmlDoc.CreateElement("legs");
                foreach (Route leg in stopover.Legs)
                {
                    XmlElement stopoverLegNode = xmlDoc.CreateElement("leg");

                    stopoverLegNode.AppendChild(SaveRoute(xmlDoc, leg));

                    stopoverLegsNode.AppendChild(stopoverLegNode);
                }
                routeStopoverNode.AppendChild(stopoverLegsNode);
                routeStopoversNode.AppendChild(routeStopoverNode);*/

            XmlNodeList routeStopoverList = routeNode.SelectNodes("stopovers/stopover");

            foreach (XmlElement routeStopoverNode in routeStopoverList)
            {
                Airport stopoverAirport = Airports.GetAirportFromID(routeStopoverNode.Attributes["airport"].Value);

                StopoverRoute stopoverRoute = new StopoverRoute(stopoverAirport);

                XmlNodeList legsList = routeStopoverNode.SelectNodes("legs/leg");

                foreach (XmlElement legNode in legsList)
                {

                    stopoverRoute.addLeg(LoadRoute((XmlElement)legNode.SelectSingleNode("route"), airline, routetype));
                }

                route.addStopover(stopoverRoute);

            }

            if (routetype == Route.RouteType.Passenger || routetype == Route.RouteType.Mixed)
            {
                ((PassengerRoute)route).Classes.Clear();

                XmlNodeList routeClassList = routeNode.SelectNodes("routeclasses/routeclass");

                foreach (XmlElement routeClassNode in routeClassList)
                {
                    AirlinerClass.ClassType airlinerClassType = (AirlinerClass.ClassType)Enum.Parse(typeof(AirlinerClass.ClassType), routeClassNode.Attributes["type"].Value);
                    double fareprice = Convert.ToDouble(routeClassNode.Attributes["fareprice"].Value,new CultureInfo("de-DE", false));
                    RouteAirlinerClass.SeatingType seatingType = (RouteAirlinerClass.SeatingType)Enum.Parse(typeof(RouteAirlinerClass.SeatingType), routeClassNode.Attributes["seating"].Value);

                    RouteAirlinerClass rClass = new RouteAirlinerClass(airlinerClassType, RouteAirlinerClass.SeatingType.Reserved_Seating, fareprice);
                    rClass.Seating = seatingType;

                    foreach (RouteFacility.FacilityType ftype in Enum.GetValues(typeof(RouteFacility.FacilityType)))
                    {
                        if (routeClassNode.HasAttribute(ftype.ToString()))
                        {
                            RouteFacility facility = RouteFacilities.GetFacility(routeClassNode.Attributes[ftype.ToString()].Value);
                            rClass.addFacility(facility);
                        }
                    }

                    ((PassengerRoute)route).addRouteAirlinerClass(rClass);

                }
            }
            if (routetype == Route.RouteType.Mixed || routetype == Route.RouteType.Cargo)
            {
                XmlElement routeCargoNode = (XmlElement)routeNode.SelectSingleNode("cargo");
                double unitPrice = Convert.ToDouble(routeCargoNode.Attributes["priceperunit"].Value,new CultureInfo("de-DE", false));

                ((CargoRoute)route).PricePerUnit = unitPrice;

            }

            RouteTimeTable timeTable = new RouteTimeTable(route);

            XmlNodeList timetableList = routeNode.SelectNodes("timetable/timetableentry");

            foreach (XmlElement entryNode in timetableList)
            {
                Airport entryDest = Airports.GetAirport(entryNode.Attributes["destination"].Value);
                string flightCode = entryNode.Attributes["flightcode"].Value;
                DayOfWeek day = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), entryNode.Attributes["day"].Value);
                TimeSpan time = TimeSpan.Parse(entryNode.Attributes["time"].Value);
                FleetAirliner airliner = entryNode.Attributes["airliner"].Value == "-" ? null : airline.Fleet.Find(a => a.Airliner.ID == entryNode.Attributes["airliner"].Value); ;

                RouteTimeTableEntry entry = new RouteTimeTableEntry(timeTable, day, time, new RouteEntryDestination(entryDest, flightCode,null),null);

                if (entryNode.HasAttribute("id"))
                    entry.ID = entryNode.Attributes["id"].Value;

                if (entryNode.HasAttribute("mainentry")) entry.MainEntry = airline.Routes.SelectMany(r => r.TimeTable.Entries).ToList().Find(e => e.ID == entryNode.Attributes["mainentry"].Value);

                entry.Airliner = airliner;

                if (airliner != null && !airliner.Routes.Contains(route))
                    airliner.Routes.Add(route);

                timeTable.addEntry(entry);
            }
            route.TimeTable = timeTable;

            XmlNodeList routeInvoiceList = routeNode.SelectNodes("invoices/invoice");

            foreach (XmlElement routeInvoiceNode in routeInvoiceList)
            {
                Invoice.InvoiceType type = (Invoice.InvoiceType)Enum.Parse(typeof(Invoice.InvoiceType), routeInvoiceNode.Attributes["type"].Value);
                int invoiceYear = Convert.ToInt16(routeInvoiceNode.Attributes["year"].Value);
                int invoiceMonth = Convert.ToInt16(routeInvoiceNode.Attributes["month"].Value);
                double invoiceAmount = Convert.ToDouble(routeInvoiceNode.Attributes["amount"].Value, new CultureInfo("de-DE", false));

                route.setRouteInvoice(type, invoiceYear, invoiceMonth, invoiceAmount);
            }

            return route;
        }
        private void btnAdd_Click(object sender, RoutedEventArgs e)
        {
            ComboBoxItem item = (ComboBoxItem)cbDestination.SelectedItem;

            Route route = (Route)item.Tag;

            Airport airport = (Airport)item.Content;

            TimeSpan time = new TimeSpan(tpTime.Value.Value.Hour, tpTime.Value.Value.Minute, 0);

            string day = cbDay.SelectedItem.ToString();

            if (!this.ParentPage.Entries.ContainsKey(route))
                this.ParentPage.Entries.Add(route, new List<RouteTimeTableEntry>());

            string flightCode = cbFlightCode.SelectedItem.ToString();

            RouteTimeTable rt = new RouteTimeTable(route);

            if (day == "Daily")
            {

                foreach (DayOfWeek dayOfWeek in Enum.GetValues(typeof(DayOfWeek)))
                {
                    RouteTimeTableEntry entry = new RouteTimeTableEntry(route.TimeTable, dayOfWeek, time, new RouteEntryDestination(airport, flightCode));
                    entry.Airliner = this.Airliner;

                    rt.addEntry(entry);

                }

            }
            else
            {
                RouteTimeTableEntry entry = new RouteTimeTableEntry(route.TimeTable, (DayOfWeek)cbDay.SelectedItem, time, new RouteEntryDestination(airport, flightCode));
                entry.Airliner = this.Airliner;

                rt.addEntry(entry);

            }

            if (!TimeTableHelpers.IsTimeTableValid(rt, this.Airliner, this.ParentPage.Entries))
                WPFMessageBox.Show(Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok);

            else
            {
                this.ParentPage.NewestEntries.Clear();
                foreach (RouteTimeTableEntry entry in rt.Entries)
                {
                    this.ParentPage.Entries[route].Add(entry);

                    this.ParentPage.NewestEntries.Add(entry);
                }

            }

            this.ParentPage.showFlights();
        }
Пример #9
0
 public RouteTimeTableEntry(RouteTimeTable timeTable, DayOfWeek day, TimeSpan time, RouteEntryDestination destination)
     : this(timeTable, day, time, destination, null)
 {
 }
        //creates the entries for the stopoverflight
        private void createEntries(RouteTimeTableEntry mainEntry)
        {
            List<Route> routes = mainEntry.TimeTable.Route.Stopovers.SelectMany(s => s.Legs).ToList();

            TimeSpan time = mainEntry.Time;

            Boolean isInbound = mainEntry.DepartureAirport == mainEntry.TimeTable.Route.Destination2;

            if (isInbound)
                routes.Reverse();

            foreach (Route route in routes)
            {
                RouteTimeTable timetable = new RouteTimeTable(route);

                RouteTimeTableEntry entry;
                //inbound
                if (isInbound)
                {
                    entry = new RouteTimeTableEntry(timetable, mainEntry.Day, time, new RouteEntryDestination(route.Destination1, mainEntry.Destination.FlightCode));

                    time = time.Add(entry.TimeTable.Route.getFlightTime(mainEntry.Airliner.Airliner.Type)).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(mainEntry.Airliner));
                    entry.Airliner = mainEntry.Airliner;
                    entry.MainEntry = mainEntry;

                }
                //outbound
                else
                {
                    entry = new RouteTimeTableEntry(timetable, mainEntry.Day, time, new RouteEntryDestination(route.Destination2, mainEntry.Destination.FlightCode));
                    entry.Airliner = mainEntry.Airliner;
                    entry.MainEntry = mainEntry;

                    time = time.Add(entry.TimeTable.Route.getFlightTime(mainEntry.Airliner.Airliner.Type)).Add(FleetAirlinerHelpers.GetMinTimeBetweenFlights(mainEntry.Airliner));

                }

                if (route.Type == Route.RouteType.Passenger || route.Type == Route.RouteType.Mixed)
                {
                    List<FlightAirlinerClass> classes = new List<FlightAirlinerClass>();
                    foreach (AirlinerClass aClass in this.Airliner.Airliner.Classes)
                    {
                        FlightAirlinerClass faClass;
                        if (isInbound)
                            faClass = new FlightAirlinerClass(((PassengerRoute)route).getRouteAirlinerClass(aClass.Type), PassengerHelpers.GetStopoverFlightPassengers(this.Airliner, aClass.Type, route.Destination2, route.Destination1, routes, isInbound));
                        else
                            faClass = new FlightAirlinerClass(((PassengerRoute)route).getRouteAirlinerClass(aClass.Type), PassengerHelpers.GetStopoverFlightPassengers(this.Airliner, aClass.Type, route.Destination1, route.Destination2, routes, isInbound));

                        classes.Add(faClass);
                    }

                    this.AllClasses.Add(entry, classes);
                }
                if (route.Type == Route.RouteType.Cargo || route.Type == Route.RouteType.Mixed)
                {
                    if (isInbound)
                        this.AllCargo.Add(entry, PassengerHelpers.GetStopoverFlightCargo(this.Airliner, route.Destination2, route.Destination1, routes, isInbound));
                    else
                        this.AllCargo.Add(entry, PassengerHelpers.GetStopoverFlightCargo(this.Airliner, route.Destination1, route.Destination2, routes,isInbound));

                }

            }
        }