public AddEntry ( RouteTimeTableEntry entry ) : void | ||
entry | RouteTimeTableEntry | |
Résultat | void |
private void EntryChanged_Event(object sender, RoutedEventArgs e) { var entries = e.OriginalSource as object[]; var oldEntry = entries[0] as TimelineEntry; var newEntry = entries[1] as TimelineEntry; var oEntry = (RouteTimeTableEntry)oldEntry.Source; var rt = new RouteTimeTable(oEntry.TimeTable.Route); var nEntry = new RouteTimeTableEntry( rt, (DayOfWeek)newEntry.StartTime.Days, newEntry.StartTime, oEntry.Destination); nEntry.Airliner = Airliner; rt.AddEntry(nEntry); var tEntries = new List<RouteTimeTableEntry>(Entries); tEntries.Remove(oEntry); if (!TimeTableHelpers.IsTimeTableValid(rt, Airliner, tEntries)) { WPFMessageBox.Show( Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok); } else { Entries.Remove(oEntry); Entries.Add(nEntry); } }
private void addEntries(List<DayOfWeek> days) { var route = (Route)cbHomebound.SelectedItem; var origin = (Airport)cbOutbound.SelectedItem; Airport airport = route.Destination1 == origin ? route.Destination2 : route.Destination1; var time = new TimeSpan(tpTime.Value.Value.Hour, tpTime.Value.Value.Minute, 0); string flightCode = Airliner.Airliner.Airline.Profile.IATACode + txtSchedulerFlightNumber.Text; var rt = new RouteTimeTable(route); foreach (DayOfWeek dayOfWeek in days) { var entry = new RouteTimeTableEntry( route.TimeTable, dayOfWeek, time, new RouteEntryDestination(airport, flightCode)); entry.Airliner = Airliner; rt.AddEntry(entry); } if (!TimeTableHelpers.IsRoutePlannerTimeTableValid(rt, Airliner, Entries.ToList())) { WPFMessageBox.Show( Translator.GetInstance().GetString("MessageBox", "2706"), Translator.GetInstance().GetString("MessageBox", "2706", "message"), WPFMessageBoxButtons.Ok); } else { foreach (RouteTimeTableEntry entry in rt.Entries) { Entries.Add(entry); } } setFlightNumbers(); }
private void btnSaveContract_Click(Object sender, RoutedEventArgs e) { Route route = (Route)cbSpecialRoute.SelectedItem; RouteTimeTable rtt = new RouteTimeTable(route); RouteTimeTableEntry entry = new RouteTimeTableEntry(rtt, DayOfWeek.Wednesday, new TimeSpan(12, 0, 0), new RouteEntryDestination(route.Destination2, "Charter")); entry.Airliner = Airliner; rtt.AddEntry(entry); route.TimeTable = rtt; Airliner.AddRoute(route); Airliner.Status = FleetAirliner.AirlinerStatus.OnCharter; }
//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"); if (routeStopoverList != null) foreach (XmlElement routeStopoverNode in routeStopoverList) { Airport stopoverAirport = Airports.GetAirportFromID(routeStopoverNode.Attributes["airport"].Value); var stopoverRoute = new StopoverRoute(stopoverAirport); XmlNodeList legsList = routeStopoverNode.SelectNodes("legs/leg"); if (legsList != null) 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"); if (routeClassList != null) foreach (XmlElement routeClassNode in routeClassList) { var 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)); var seatingType = (RouteAirlinerClass.SeatingType) Enum.Parse( typeof (RouteAirlinerClass.SeatingType), routeClassNode.Attributes["seating"].Value); var rClass = new RouteAirlinerClass( airlinerClassType, RouteAirlinerClass.SeatingType.ReservedSeating, fareprice) {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) { var routeCargoNode = (XmlElement) routeNode.SelectSingleNode("cargo"); if (routeCargoNode != null) { double unitPrice = Convert.ToDouble( routeCargoNode.Attributes["priceperunit"].Value, new CultureInfo("de-DE", false)); ((CargoRoute) route).PricePerUnit = unitPrice; } } var timeTable = new RouteTimeTable(route); XmlNodeList timetableList = routeNode.SelectNodes("timetable/timetableentry"); if (timetableList != null) foreach (XmlElement entryNode in timetableList) { Airport entryDest = Airports.GetAirport(entryNode.Attributes["destination"].Value); string flightCode = entryNode.Attributes["flightcode"].Value; var 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); var 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"); if (routeInvoiceList != null) foreach (XmlElement routeInvoiceNode in routeInvoiceList) { var 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, 1, invoiceAmount); } return route; }