public override string ToString() { String sReturn = "RouteID - " + RouteID + " => FlightName: " + FlightName + ", StartCity: " + StartCityName + "(" + StartCityCode + "), Destination: " + EndCityName + " (" + EndCityCode + "), Departure Time: " + FlightTime.ToString("dd MMM yyyy HH:mm") + ", Rate(A/C): " + AdultRate + "/" + ChildRate + ", NumSeats: " + NumSeatsAvailable; return(sReturn); }
private List <Flight> CreateFlights(string fname, DateTime dtBegin, DateTime dtEnd) { List <Flight> flights = new List <Flight>(); string beginDate = dtBegin.ToString("yyyy/MM/dd HH:mm"); string endDate = dtEnd.ToString("yyyy/MM/dd HH:mm"); using (var fs = new FileStream(fname, FileMode.Open, FileAccess.Read)) { using (var sr = new StreamReader(fs, Encoding.UTF8)) { string line; int rowCount = 0; ; while ((line = sr.ReadLine()) != null)// && rowCount < 6) { if (rowCount % 2 == 1) { Flight flight = new Flight(); string[] cols = line.Split('\t'); flight.commercialFlightNumber = cols[0]; string commercialFlightNumber = cols[0]; string airline = "FL"; string strFlightNumber = string.Format("{0:000}", cols[0].Substring(2)); if (cols[0].Substring(0, 2).Equals("ME")) { airline = "ME"; strFlightNumber = string.Format("{0:000}", cols[0].Substring(3)); } //fflightAirline = airline; ushort flightNumber = Convert.ToUInt16(strFlightNumber); // Aircraft Type string aircraftType = cols[13]; string aircraftATCType = cols[13]; // Get FROM and TO string from = cols[1].Substring(0, 4); string to = cols[4].Substring(0, 4); // Departure and arrival time FlightTime depTime = new FlightTime( Convert.ToInt32(cols[1].Substring(6, 2)), Convert.ToInt32(cols[1].Substring(8, 2))); FlightTime arrTime = new FlightTime( Convert.ToInt32(cols[4].Substring(6, 2)), Convert.ToInt32(cols[4].Substring(8, 2))); DateTime depDate = DateTime.Today; DateTime arrDate = depDate; if (depTime > arrTime) { // Add one day to arrival date arrDate = arrDate.AddDays(1.0); } // Format the dates so that they can be stored in STD and STA string std = depDate.ToString("yyyy/MM/dd") + " " + depTime.ToString(); string sta = arrDate.ToString("yyyy/MM/dd") + " " + arrTime.ToString(); // add the begin date and end date of the schedule string BeginDate = dtBegin.ToString("yyyy/MM/dd HH:mm"); string EndDate = dtEnd.ToString("yyyy/MM/dd HH:mm"); int randomPayload = 1; int repetative = 1; // Get days of operation uint days = GetDaysOfOperation(cols); int isMaster = 1; int adults = -1; int females = -1; int children = -1; int infants = -1; int baggage = -1; //int baggage = -1; int cargo = -1; int payload = -1; string aircraft = null; // Misc. fields int maxPax = -1; int maxCargo = -1; flight = new Flight(airline, flightNumber, commercialFlightNumber, from, to, aircraft, aircraftType, aircraftATCType, std, sta, maxPax, maxCargo, randomPayload, repetative, isMaster, beginDate, endDate, days, adults, females, children, infants, baggage, cargo, payload); flights.Add(flight); } rowCount++; } } } return(flights); }