private void CloneFlightBookingModel(FlightBookingModel model) { var cloneFlightResult = Newtonsoft.Json.JsonConvert.SerializeObject(model); var fileName = System.IO.Path.GetFileName("FlightListResult" + DateTime.Now.ToString("yyyyMMdd") + ".txt"); var path = Server.MapPath("~/cache/"); var fullPath = System.IO.Path.Combine(path, fileName); if (!System.IO.Directory.Exists(path)) { System.IO.Directory.CreateDirectory(path); } System.IO.File.WriteAllText(fullPath, cloneFlightResult); }
/// <summary> /// Updates the asynchronous. /// </summary> /// <param name="model">The model.</param> /// <returns> /// UpdateAsync /// </returns> public async Task <FlightBookingModel> UpdateAsync(FlightBookingModel model) { var record = await this.flightBookingRepository.Table.FirstOrDefaultAsync(m => m.Id == model.Id); if (record != null) { record.Pnr = model.Pnr; record.Origin = model.Origin; record.Destination = model.Destination; record.TboBookingId = model.TboBookingId; record.BookingDate = model.BookingDate; record.Remark = model.Remark; record.UpdateAuditInfo(model.UpdatedBy); } await this.flightBookingRepository.SaveChangesAsync(); return(model); }
public FlightBookingModel BindSearchCookies(FlightBookingModel model, UserSearchFHCookiesModel cookie) { if (cookie != null) { model.SearchFlightResultViewModel = new SearchFlightResultViewModel() { DepartureStation = cookie.From, ArrivalStation = cookie.Destination, BeginDate = cookie.ArrivalDate.Value.ToLocalTime(), EndDate = cookie.DepartureDate.Value.ToLocalTime(), Adults = cookie.AdultNo, Childrens = cookie.ChildrenNo, Infants = cookie.InfantNo, PrefferedAirlineCode = cookie.PrefferedAirlineCode, NoOfRoom = cookie.RoomNo, CabinClass = cookie.CabinClass, TripType = cookie.TripType }; } return(model); }
/// <summary> /// Inserts the asynchronous. /// </summary> /// <param name="model">The model.</param> /// <returns>Insert Fligt Booking</returns> public async Task <FlightBookingModel> InsertAsync(FlightBookingModel model) { await this.flightBookingRepository.InsertAsync(model); return(model); }
private static void SabreFlightSearch(FlightSearchBatch f) { try { log.Debug("SabreFlightSearch Started."); DateTime fromPeriod = f.SeachPeriodFrom ?? DateTime.Today; DateTime toPeriod = f.SeachPeriodTo ?? DateTime.Today; int stayduration = f.SeachStayDuration ?? 0; int totalAdults = f.TotalAdult ?? 1; int totalChild = f.TotalChild ?? 0; int totalInfants = f.TotalInfant ?? 0; #region Validation if (f.SeachPeriodFrom == null || f.SeachPeriodTo == null || f.FROM == null || f.TO == null) { log.Debug("Fligh Search Batch not complete. BatchID = " + f.BatchID); SendErrorMail("Fligh Search Batch not complete. BatchID = " + f.BatchID); } if ((toPeriod - fromPeriod).TotalDays < 0 || (fromPeriod - DateTime.Now).TotalDays > 365 || DateTime.Now > fromPeriod) { log.Debug("Fligh Search Batch Seach Period not correct. BatchID = " + f.BatchID); SendErrorMail("Fligh Search Batch Seach Period not correct. BatchID = " + f.BatchID); } #endregion if (//(DateTime.Now - lastSeachDate).TotalDays > rerunday && (fromPeriod - DateTime.Now).TotalDays < 365 && DateTime.Now < fromPeriod) { while (fromPeriod <= toPeriod) { FlightBookingModel model = new FlightBookingModel() { SearchFlightResultViewModel = new SearchFlightResultViewModel() { DepartureStation = f.FROM, ArrivalStation = f.TO, BeginDate = fromPeriod, EndDate = fromPeriod.AddDays(stayduration), CabinClass = string.IsNullOrWhiteSpace(f.CabinClass) ? "Y" : f.CabinClass, PrefferedAirlineCode = string.IsNullOrWhiteSpace(f.PreferredAirlineCode) ? "-" : f.PreferredAirlineCode, TripType = "Return", DirectFlight = false, Adults = totalAdults, Childrens = totalChild, Infants = totalInfants } }; Alphareds.Module.SabreWebService.SWS.SearchFlightBargainFinderMaxResponse rs = SabreServiceCall.SearchFlightBargainFinderMaxResponse(model); if (rs.Output == null) { } else { SqlCommand command = new SqlCommand(); try { //model.FlightSearchResultViewModel.FullFlightSearchResult = rs.Output.ToList(); List <Alphareds.Module.SabreWebService.SWS.PricedItineryModel> result = rs.Output.ToList(); foreach (Alphareds.Module.SabreWebService.SWS.PricedItineryModel resultItem in result) { InsertFlightSearchResultService(command, resultItem, f.BatchID, fromPeriod, fromPeriod.AddDays(stayduration)); } command.Transaction.Commit(); } catch (Exception ex) { command.Transaction.Rollback(); throw ex; } } fromPeriod = fromPeriod.AddDays(1); int pauseDuration = 5000; int.TryParse(Core.GetAppSettingValueEnhanced("PauseDuration").ToString(), out pauseDuration); Thread.Sleep(pauseDuration); } } UpdateFlightSearchBatchService(f); GenerateReport(f); log.Debug("SabreFlightSearch Completed."); } catch (Exception ex) { log.Debug("Unable to complete SabreFlightSearch."); throw ex; } }
public ActionResult Index(string errorMsg) { int dayAdvance = Convert.ToInt32(Core.GetSettingValue("dayadvance")); FlightBookingModel model = Session["FlightBooking"] == null ? null : (FlightBookingModel)Session["FlightBooking"]; int userid = 0; if (Request.IsAuthenticated && Core.EnableCMS) { return(RedirectToAction("RedirectAndPOST", "DynamicFormPostSurface", new { destinationUrl = System.Web.Configuration.WebConfigurationManager.AppSettings["AlphaReds.CMSUrl"], type = "SessionTransfer" })); } else if (Core.EnableCMS) { string CMSUrl = Core.GetAppSettingValueEnhanced("AlphaReds.CMSUrl"); string landingPageUrl = string.IsNullOrWhiteSpace(CMSUrl) ? "https://www.mayflower.com.my/" : CMSUrl; UriBuilder builder = new UriBuilder(landingPageUrl); var query = HttpUtility.ParseQueryString(builder.Query); if (Request.QueryString != null && Request.QueryString.Count > 0) { foreach (var item in Request.QueryString) { query[item.ToString()] = Request.QueryString[item.ToString()]; } } builder.Query = query.ToString(); Response.Redirect(builder.ToString()); } /*else if (User.Identity.IsAuthenticated) * { * if (model == null) * { * userid = Convert.ToInt32(User.Identity.Name); * //model = HomeServiceController.getHomeModelWhenIsUserLogin(userid, dayAdvance); * } * }*/ // Initialize for Anonymous user //start validate model = Alphareds.Module.Public.Flight.Helper.GetHomeModelAnonymousUser(model, dayAdvance); List <UserSearchFHCookiesModel> UserCookies = new List <UserSearchFHCookiesModel>(); UserSearchFHCookiesModel LatestFlightCookie = new UserSearchFHCookiesModel(); JavaScriptSerializer jsSerializer = new JavaScriptSerializer(); string trackingUserSearchCookiesList; string encryptCookies; if (Request.Cookies["SaveUserCookies"] != null) { encryptCookies = Request.Cookies["SaveUserCookies"].Value; trackingUserSearchCookiesList = Cryptography.AES.Decrypt(encryptCookies); UserCookies = jsSerializer.Deserialize <List <UserSearchFHCookiesModel> >(trackingUserSearchCookiesList).ToList(); LatestFlightCookie = UserCookies.LastOrDefault(x => x.ProductType == "flight"); if (LatestFlightCookie != null) { if (LatestFlightCookie.ArrivalDate.HasValue && LatestFlightCookie.ArrivalDate.Value.ToLocalTime().AddDays(1) < DateTime.Now.AddDays(dayAdvance)) { LatestFlightCookie = null; } if (LatestFlightCookie != null) { model = BindSearchCookies(model, LatestFlightCookie); } } } var locationList = Alphareds.Module.ServiceCall.CarsRentalServiceCall.GetBranchList(); ViewBag.locationList = locationList; return(View(model)); }
public ActionResult Index(FlightBookingModel model, [Bind(Exclude = "SearchResults")] SearchFlightResultViewModel searchModel) { tripid = Guid.NewGuid().ToString(); sessionNameBooking = Enumeration.SessionName.FlightBooking + tripid; #region 2017/02/28 - Development Region, For Get Result from Dummy Cloned Set bool useDumpResultList = false; bool.TryParse(Core.GetAppSettingValueEnhanced("UseDumpResultList"), out useDumpResultList); if (useDumpResultList) { var dumpModel = GetDumpFlightBookingModel("FlightListResultFullList.txt"); Session[sessionNameBooking] = dumpModel; Session["FullFlightSearchResult"] = dumpModel.FlightSearchResultViewModel.FullFlightSearchResult; Session["FullODOResult"] = JsonConvert.DeserializeObject <FlightBookingModel>(JsonConvert.SerializeObject(dumpModel)); Session.Remove("filterParam"); return(RedirectToAction("FlightSearchResult", "FlightSearch", new { tripid })); } #endregion /*20170210 RECEIVE DATA PASSING FROM MAYFLOWER CMS - START */ if (Request.Form["TripTypeCMS"] != null) { model.SearchFlightResultViewModel = new SearchFlightResultViewModel(); DateTime beginDate = DateTime.ParseExact(Request.Form["BeginDateCMS"].ToString(), "dd-MMM-yyyy h:mm:ss tt", null); DateTime endDate = DateTime.ParseExact(Request.Form["EndDateCMS"].ToString(), "dd-MMM-yyyy h:mm:ss tt", null); model.SearchFlightResultViewModel.TripType = Request.Form["TripTypeCMS"].ToString(); model.SearchFlightResultViewModel.DepartureTime = Request.Form["DepartureTimeCMS"].ToString(); model.SearchFlightResultViewModel.ReturnTime = Request.Form["ReturnTimeCMS"].ToString(); model.SearchFlightResultViewModel.DepartureStation = Request.Form["DepartureStationCMS"]?.ToString().ToUpper(); model.SearchFlightResultViewModel.ArrivalStation = Request.Form["ArrivalStationCMS"]?.ToString().ToUpper(); model.SearchFlightResultViewModel.BeginDate = beginDate; model.SearchFlightResultViewModel.EndDate = endDate; model.SearchFlightResultViewModel.PrefferedAirlineCode = Request.Form["PrefferedAirlineCodeCMS"].ToString(); if (model.SearchFlightResultViewModel.PrefferedAirlineCode == "") { model.SearchFlightResultViewModel.PrefferedAirlineCode = null; } model.SearchFlightResultViewModel.PromoCode = Request.Form["PromoCodeCMS"] == null ? null : Request.Form["PromoCodeCMS"].ToString(); model.SearchFlightResultViewModel.Adults = Convert.ToInt32(Request.Form["AdultsCMS"].ToString()); model.SearchFlightResultViewModel.Childrens = Convert.ToInt32(Request.Form["ChildrensCMS"].ToString()); model.SearchFlightResultViewModel.Infants = Convert.ToInt32(Request.Form["InfantsCMS"].ToString()); model.SearchFlightResultViewModel.CabinClass = Request.Form["CabinClassCMS"].ToString(); model.SearchFlightResultViewModel.DirectFlight = Convert.ToBoolean(Request.Form["DirectFlightCMS"].ToString()); model.SearchFlightResultViewModel.IsDynamic = Convert.ToBoolean(Request.Form["IsDynamic"] != null ? Request.Form["IsDynamic"].ToString() : "false"); model.SearchFlightResultViewModel.NoOfRoom = Convert.ToInt32(Request.Form["DynamicRoomCMS"] != null ? Request.Form["DynamicRoomCMS"].ToString() : "1"); model.SearchFlightResultViewModel.IsFixedPrice = Convert.ToBoolean(Request.Form["IsFixedPrice"] != null ? Request.Form["IsFixedPrice"].ToString() : "false"); model.SearchFlightResultViewModel.MarketingMessage = Request.Form["MarketingMessage"]; } /*20170210 RECEIVE DATA PASSING FROM MAYFLOWER CMS - END */ AddFlightSearchCookie(model.SearchFlightResultViewModel); if (searchModel != null && !string.IsNullOrWhiteSpace(searchModel.DepartureStationCode) && searchModel.BeginDate != null) { model.SearchFlightResultViewModel = searchModel; } else { var stateItem = typeof(SearchFlightResultViewModel).GetProperties(); foreach (var item in stateItem) { if (ModelState[item.Name] != null) { ModelState[item.Name].Errors.Clear(); } } } Session[sessionNameBooking] = model; // 0 represent as guest account int userid = User.Identity.IsAuthenticated ? Convert.ToInt32(User.Identity.Name) : 0; try { if (ModelState.IsValid) { if (model.SearchFlightResultViewModel.IsFixedPrice) { return(RedirectToAction("GetFixedHotelSearch", "Hotel", new { tripid })); } else { // 20161126 - For testing next page list flight START return(RedirectToAction("Search", "Flight", new { tripid })); // 20161126 - For testing next page list flight END } } else { return(View(model)); } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); UtilitiesService.NlogExceptionForBookingFlow(logger, model, ex, userid, "HomeSearchFlightError", DateTime.Now.ToString(), ""); return(RedirectToAction("Index", "Home")); } }