public void getListOfAllAvailableFlightsBetweenCitiesOnDates(string sStartCityCode, string sEndCityCode, DateTime dtStartDate, DateTime dtEndDate) { Console.WriteLine("In getListOfAllAvailableFlightsBetweenCitiesOnDates({0}, {1}, {2}, {3})", sStartCityCode, sEndCityCode, dtStartDate.ToString(), dtEndDate.ToString()); IFlightQueryCallback callerProxy = OperationContext.Current.GetCallbackChannel<IFlightQueryCallback>(); CultureInfo provider = CultureInfo.InvariantCulture; //start date time set to 00:00 and end date time component set to 23:59 dtStartDate = new DateTime(dtStartDate.Year, dtStartDate.Month, dtStartDate.Day, 00, 00, 00); dtEndDate = new DateTime(dtEndDate.Year, dtEndDate.Month, dtEndDate.Day, 23, 59, 59); List<FlightInfo> lstReturn = new List<FlightInfo>(); List<Flight_DAL.Route> lstRoutes; lock (this) { lstRoutes = myFlightBLL.getFlightBLLInstance().getFlightsBetweenCities(sStartCityCode, sEndCityCode); } if (lstRoutes == null) { Console.WriteLine("No routes found"); callerProxy.onFlightInfoQueryCallback(null); } else { Console.WriteLine("Found - {0} routes", lstRoutes.Count); DateTime dtFlight = DateTime.Now; FlightInfo fInfo; string sDate; foreach (Route r in lstRoutes) { dtFlight = dtStartDate; while (dtFlight <= dtEndDate) { Console.WriteLine("Checking route {1} for date - {0}", r.FlightTime, r.RouteID); fInfo = new FlightInfo(); fInfo.RouteID = r.RouteID; fInfo.AdultRate = r.AdultFare; fInfo.ChildRate = r.ChildFare; fInfo.EndCityCode = r.Destination1.CityCode; fInfo.EndCityName = r.Destination1.City; fInfo.StartCityCode = r.Destination.CityCode; fInfo.StartCityName = r.Destination.City; fInfo.FlightName = r.Flight.FlightID; sDate = dtFlight.ToString("dd MMM yyyy ") + r.FlightTime; fInfo.FlightTime = DateTime.ParseExact(sDate, "dd MMM yyyy HH:mm", null); //date+time component fInfo.NumSeatsAvailable = getNumSeatsAvailable(r, fInfo.FlightTime); lstReturn.Add(fInfo); dtFlight = dtFlight.AddDays(1); } } callerProxy.onFlightInfoQueryCallback(lstReturn.ToArray()); } }
public void getListOfAllFlightsBetweenCities(string sStartCityCode, string sEndCityCode) { Console.WriteLine("In getListOfAllFlightsBetweenCities({0}, {1}) function... ", sStartCityCode, sEndCityCode); IFlightQueryCallback callerProxy = OperationContext.Current.GetCallbackChannel<IFlightQueryCallback>(); CultureInfo provider = CultureInfo.InvariantCulture; List<FlightInfo> lstReturn = new List<FlightInfo>(); List<Flight_DAL.Route> lstRoutes; lock (this) { lstRoutes = myFlightBLL.getFlightBLLInstance().getFlightsBetweenCities(sStartCityCode, sEndCityCode); } if (lstRoutes == null) { callerProxy.onFlightInfoQueryCallback(null); } else { Console.WriteLine("Found - {0} routes", lstRoutes.Count); FlightInfo fInfo; foreach (Route r in lstRoutes) { fInfo = new FlightInfo(); fInfo.RouteID = r.RouteID; fInfo.AdultRate = r.AdultFare; fInfo.ChildRate = r.ChildFare; fInfo.EndCityCode = r.Destination1.CityCode; fInfo.EndCityName = r.Destination1.City; fInfo.StartCityCode = r.Destination.CityCode; fInfo.StartCityName = r.Destination.City; fInfo.FlightName = r.Flight.FlightID; fInfo.FlightTime = DateTime.ParseExact(r.FlightTime, "HH:mm", null); //only time component Console.WriteLine(fInfo.ToString()); lstReturn.Add(fInfo); } callerProxy.onFlightInfoQueryCallback(lstReturn.ToArray()); } }