private void CreateBooking(List<FlightRequest> objFlightRequests) { foreach (var objFlightRequest in objFlightRequests) { if (!string.IsNullOrEmpty(objFlightRequest.Origin) && !string.IsNullOrEmpty(objFlightRequest.Destination) && objFlightRequest.TotalPNRsRequired > 0) { for (int i = 0; i < objFlightRequest.TotalPNRsRequired; i++) { ProcessedCount++; var token = GetToken(); if (!string.IsNullOrEmpty(token)) { try { List<PaxWiseFareIdResult> objColPaxWiseFareId = CreateFareQuoteRequest(objFlightRequest.Origin, objFlightRequest.Destination, token, objFlightRequest.AdtCount, objFlightRequest.ChdCount, objFlightRequest.InfCount, objFlightRequest.DepartureDate, objFlightRequest.ReturnDate, objFlightRequest.OutboundFlightNo, objFlightRequest.InboundFlightNo, objFlightRequest.IsRT, objFlightRequest.OutboundCabin, objFlightRequest.InboundCabin); if (objColPaxWiseFareId != null && objColPaxWiseFareId.Count > 0) { var lastName = Helper.RandomString(5); ViewPNR objSummaryPNR = GenerateSummary(objColPaxWiseFareId, token, Convert.ToInt16(objFlightRequest.AdtCount), Convert.ToInt16(objFlightRequest.ChdCount), Convert.ToInt16(objFlightRequest.InfCount), lastName, objFlightRequest); List<Voucher> colVoucher = new List<Voucher>(); if (!string.IsNullOrEmpty(objFlightRequest.VoucherNo)) { colVoucher = GetVoucherInfo(token, objFlightRequest.VoucherNo); } if (colVoucher != null && colVoucher.Count > 0 && colVoucher[0].BalanceAmount > 0 || string.IsNullOrEmpty(objFlightRequest.VoucherNo)) { decimal reservationBalance = 0; if (!string.IsNullOrEmpty(objFlightRequest.VoucherNo)) reservationBalance = AddVoucher(token, colVoucher[0].VoucherNumFull); if (reservationBalance <= 0 || string.IsNullOrEmpty(objFlightRequest.VoucherNo)) { using (ReservationService.ConnectPoint_Reservation objReservationClient = new ReservationService.ConnectPoint_Reservation()) { ViewPNR PNR = objReservationClient.CreatePNR(new CreatePNR() { SecurityGUID = token, CarrierCodes = GetCarrierCodes(), ClientIPAddress = string.Empty, HistoricUserName = string.Empty, ActionType = CreatePNRActionTypes.CommitSummary, ReservationInfo = new ReservationInfo() { ConfirmationNumber = string.Empty, SeriesNumber = "299" } }); if (PNR.Exceptions != null) { foreach (var exception in PNR.Exceptions) { if (exception.ExceptionCode != 0) { var radixxException = new RadixxException( message: exception.ExceptionDescription, radixxExceptionCode: this.ParseErrorCode(exception.ExceptionDescription) ?? exception.ExceptionCode, radixxExceptionSource: exception.ExceptionSource, type: new StackFrame(1, true).GetType(), flydubaiOperation: new StackFrame(1, true).GetMethod().Name, securityGuid: token, request: "",//DataHelpers.SerializeToString(request), responseMessage: "");//DataHelpers.SerializeToString(response)); throw radixxException; } } } lstPNRsProcessed.Add(new PNRsProcessed() { DepartureDate = objFlightRequest.DepartureDate, ReturnDate = (objFlightRequest.IsRT ? objFlightRequest.ReturnDate : DateTime.MinValue), Origin = objFlightRequest.Origin, Destination = objFlightRequest.Destination, PNR = PNR.ConfirmationNumber, LastName = lastName, FlightNo = objFlightRequest.OutboundFlightNo + (!string.IsNullOrEmpty(objFlightRequest.InboundFlightNo) ? " - " + objFlightRequest.InboundFlightNo : string.Empty) }); SuccessCount++; Logger.LogToFile("PNR: " + PNR.ConfirmationNumber + ", Lastname: " + lastName + " created successfully."); } } else { Logger.LogToFile("Origin: " + objFlightRequest.Origin + ", Destination: " + objFlightRequest.Destination + " not processed."); Logger.LogToFile(string.Format("Error message: Voucher no: {0} doesn't have enough amount to pay this booking ,", objFlightRequest.VoucherNo)); FailedCount++; } } else { Logger.LogToFile("Origin: " + objFlightRequest.Origin + ", Destination: " + objFlightRequest.Destination + " not processed."); Logger.LogToFile(string.Format("Error message: Voucher no: {0} not valid or Balanced amount is 0 ,", objFlightRequest.VoucherNo)); FailedCount++; } } else { Logger.LogToFile("Origin: " + objFlightRequest.Origin + ", Destination: " + objFlightRequest.Destination + " not processed."); Logger.LogToFile("Error message: Fares not available"); FailedCount++; } } catch (Exception ex) { FailedCount++; Logger.LogToFile("Origin: " + objFlightRequest.Origin + ", Destination: " + objFlightRequest.Destination + " not processed."); Logger.LogToFile("Error message: " + ex.Message); } } else { FailedCount++; Logger.LogToFile("Origin: " + objFlightRequest.Origin + ", Destination: " + objFlightRequest.Destination + " not processed."); Logger.LogToFile("Error message: Security service is not accessible."); } } } } this.progressBar.BeginInvoke((MethodInvoker)delegate() { progressBar.Visible = false; progressBar.Refresh(); lblInfo.Text = "PROCESS COMPLETED"; lblInfo.Refresh(); lblInfo.ForeColor = Color.Green; btnCreate.Enabled = true; }); frmProcessReport objfrmProcessReport = new frmProcessReport(); objfrmProcessReport.DSPNRsProcessed = lstPNRsProcessed; objfrmProcessReport.StartPosition = FormStartPosition.CenterParent; objfrmProcessReport.Failed = FailedCount; objfrmProcessReport.Processed = ProcessedCount; objfrmProcessReport.Successful = SuccessCount; Invoke((Action)(() => { objfrmProcessReport.ShowDialog(); })); Logger.LogToFile("====== Create PNR Process ended at : " + DateTime.Now.ToString()); }
/// <summary> /// 3. Create summary /// </summary> /// <param name="objColPaxWiseFareId"></param> /// <param name="token"></param> /// <param name="adtCount"></param> /// <param name="childCount"></param> /// <param name="infantCount"></param> /// <param name="lastName"></param> /// <returns></returns> public ViewPNR GenerateSummary(List<PaxWiseFareIdResult> objColPaxWiseFareId, string token, int adtCount, int childCount, int infantCount, string lastName, FlightRequest objFlightRequest) { ViewPNR viewPnr = new ViewPNR(); try { var request = new SummaryPNR { ActionType = SummaryPNRActionTypes.GetSummary, Address = GetEmptyAddress(), CarrierCodes = GetCarrierCodes(), SecurityGUID = token, ClientIPAddress = string.Empty, SecurityToken = token, ReceiptLanguageID = "1", ReservationInfo = new ReservationInfo { ConfirmationNumber = "NA", SeriesNumber = "299" }, User = "******", CarrierCurrency = ReservationService.EnumerationsCurrencyCodeTypes.AED, ContactInfos = GetPassengerContactInfos().ToArray(), DisplayCurrency = ReservationService.EnumerationsCurrencyCodeTypes.AED, Payments = GetEmptyPayments().ToArray(), }; List<Person> lstPersons = GetPersons(adtCount, childCount, infantCount, lastName); request.Passengers = lstPersons.ToArray(); request.Segments = GetSegments(token, lstPersons, objColPaxWiseFareId, objFlightRequest).ToArray(); using (ReservationService.ConnectPoint_Reservation client = new ReservationService.ConnectPoint_Reservation()) { viewPnr = client.SummaryPNR(request); if (viewPnr.Exceptions != null) { foreach (var exception in viewPnr.Exceptions) { if (exception.ExceptionCode != 0) { var radixxException = new RadixxException( message: exception.ExceptionDescription, radixxExceptionCode: this.ParseErrorCode(exception.ExceptionDescription) ?? exception.ExceptionCode, radixxExceptionSource: exception.ExceptionSource, type: new StackFrame(1, true).GetType(), flydubaiOperation: new StackFrame(1, true).GetMethod().Name, securityGuid: token, request: "",//DataHelpers.SerializeToString(request), responseMessage: "");//DataHelpers.SerializeToString(response)); throw radixxException; } } } } } catch (Exception ex) { throw ex; } return viewPnr; }