internal AirCreateReservationRsp AirBook(AirPricingSolution lowestPrice, AirService.AirItinerary airItinerary) { AirCreateReservationReq reservationReq = new AirCreateReservationReq(); AirCreateReservationRsp reservationRsp; BillingPointOfSaleInfo billSaleInfo = new BillingPointOfSaleInfo(); billSaleInfo.OriginApplication = "UAPI"; reservationReq.BillingPointOfSaleInfo = billSaleInfo; reservationReq.ContinuityCheckOverride = new ContinuityCheckOverride() { Key = "1T", Value = "true" }; reservationReq.BookingTraveler = AddBookingTraveler(airItinerary); reservationReq.FormOfPayment = AddFormOfPayment(); reservationReq.AirPricingSolution = AddAirPriceSolution(lowestPrice, airItinerary); List <ActionStatus> statusList = new List <ActionStatus>(); ActionStatus actionStatus = new ActionStatus() { ProviderCode = "1G", Type = ActionStatusType.TAW, TicketDate = reservationReq.AirPricingSolution.AirPricingInfo[0].LatestTicketingTime }; statusList.Add(actionStatus); reservationReq.ActionStatus = statusList.ToArray(); reservationReq.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH); reservationReq.RetainReservation = typeRetainReservation.Both; AirCreateReservationPortTypeClient client = new AirCreateReservationPortTypeClient("AirCreateReservationPort", WsdlService.AIR_ENDPOINT); client.ClientCredentials.UserName.UserName = Helper.RetrunUsername(); client.ClientCredentials.UserName.Password = Helper.ReturnPassword(); try { var httpHeaders = Helper.ReturnHttpHeader(); client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders)); reservationRsp = client.service(null, reservationReq); return(reservationRsp); } catch (Exception se) { Console.WriteLine("Error : " + se.Message); client.Abort(); return(null); } }
public AirCreateReservationRsp AirBookingReservationRequest(OFly.AirService.AirPricingSolution airPricingSolution, OFly.AirService.AirItinerary airItinerary, string CommissionOrDiscount, string Amount, List<OFly.Models.BookingTravellerInfos> TravellerList, OFly.Models.FormOfPaymentInfo formOfPaymentInfo) { AirCreateReservationReq request = new AirCreateReservationReq(); AirCreateReservationRsp airCreateReservationRsp = new AirCreateReservationRsp(); try { OFly.AirService.AirPricingSolution aps = airPricingSolution; List<OFly.AirService.typeBaseAirSegment> segmentList = airItinerary.AirSegment.ToList(); List<OFly.AirService.AirPricingInfo> pricingInfo = aps.AirPricingInfo.ToList(); List<ActionStatus> actionStatus = new List<ActionStatus>(); List<BookingTraveler> bookingTraveler = new List<BookingTraveler>(); request.AuthorizedBy = "user"; request.ProviderCode = segmentList[0].ProviderCode; request.RetainReservation = typeRetainReservation.Both; request.TargetBranch = OFly.Utilities.CommonUtility.GetConfigValue(OFly.Utilities.ProjectConstants.G_TARGET_BRANCH); BillingPointOfSaleInfo billSaleInfo = new BillingPointOfSaleInfo(); billSaleInfo.OriginApplication = ConfigurationManager.AppSettings["OriginApplication"]; request.BillingPointOfSaleInfo = billSaleInfo; AirPricingSolution apsu = new AirPricingSolution(); // converted SegmentList from AirService to UniversalRecordService string SegmentListXMLString = SegmentListConvertToXML(segmentList); List<typeBaseAirSegment> tbas = LoadFromXMLToSegmentList(SegmentListXMLString); // converted PriceInfoList from AirService to UniversalRecordService string PricingInfoXMLString = PricingInfoListConvertToXML(pricingInfo); List<AirPricingInfo> api = LoadFromXMLToPricingInfo(PricingInfoXMLString); //// need to add dynamic travelers as per textbox bookingTraveler = BookingTravelerList(TravellerList); request.BookingTraveler = bookingTraveler.ToArray(); //apsu.AirItinerarySolutionRef apsu.AirPricingInfo = api.ToArray(); //apsu.AirPricingResultMessage apsu.AirSegment = tbas.ToArray(); apsu.AirSegmentRef = null; apsu.ApproximateBasePrice = aps.ApproximateBasePrice; apsu.ApproximateFees = aps.ApproximateFees; apsu.ApproximateTaxes = aps.ApproximateTaxes; apsu.ApproximateTotalPrice = aps.ApproximateTotalPrice; //apsu.AvailableSSR apsu.BasePrice = aps.BasePrice; apsu.CompleteItinerary = aps.CompleteItinerary; //apsu.Connection apsu.EquivalentBasePrice = aps.EquivalentBasePrice; apsu.FareNote = null; apsu.FareNoteRef = null; //apsu.FeeInfo apsu.Fees = aps.Fees; //apsu.HostToken //apsu.Itinerary apsu.ItinerarySpecified = aps.ItinerarySpecified; //apsu.Journey apsu.Key = aps.Key; //apsu.LegRef //apsu.MetaData //apsu.OptionalServices //apsu.PricingDetails apsu.QuoteDate = aps.QuoteDate; apsu.QuoteDateSpecified = aps.QuoteDateSpecified; apsu.Services = aps.Services; apsu.Taxes = aps.Taxes; //apsu.TaxInfo apsu.TotalPrice = aps.TotalPrice; request.AirPricingSolution = apsu; //// Applying Commission/Discount if applicable. //if (CommissionOrDiscount != null && CommissionOrDiscount != "" && Amount != null && Amount != "") //{ // List<ManualFareAdjustment> fareAdjustmentList = new List<ManualFareAdjustment>(); // ManualFareAdjustment adjustment = new ManualFareAdjustment(); // if (CommissionOrDiscount == "Amount") // { // adjustment.AdjustmentType = typeAdjustmentType.Amount; // } // else // { // adjustment.AdjustmentType = typeAdjustmentType.Percentage; // } // adjustment.AppliedOn = typeAdjustmentTarget.Base; // adjustment.Value = Convert.ToInt32(Amount); // adjustment.PassengerRef = "1"; // fareAdjustmentList.Add(adjustment); // api[0].AirPricingModifiers = new AirPricingModifiers() // { // ManualFareAdjustment = fareAdjustmentList.ToArray() // }; //} actionStatus.Add(new ActionStatus { Type = ActionStatusType.ACTIVE, TicketDate = "T*", ProviderCode = request.ProviderCode }); request.ActionStatus = actionStatus.ToArray(); request.FormOfPayment = AddFormOfPayment(formOfPaymentInfo); AirCreateReservationPortTypeClient client = new AirCreateReservationPortTypeClient("AirCreateReservationPort", OFly.Utilities.WsdlService.AIR_ENDPOINT); client.ClientCredentials.UserName.UserName = OFly.Utilities.Helper.RetrunUsername(); client.ClientCredentials.UserName.Password = OFly.Utilities.Helper.ReturnPassword(); var httpHeaders = OFly.Utilities.Helper.ReturnHttpHeader(); client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders)); SupportedVersions supportedVersions = new SupportedVersions(); supportedVersions.airVersion = "air_v31_0"; airCreateReservationRsp = client.service(supportedVersions, request); return airCreateReservationRsp; } catch (Exception se) { throw se; } }
private AirPricingSolution AddAirPriceSolution(AirService.AirPricingSolution lowestPrice, AirService.AirItinerary airItinerary) { AirPricingSolution finalPrice = new AirPricingSolution() { Key = lowestPrice.Key, TotalPrice = lowestPrice.TotalPrice, BasePrice = lowestPrice.BasePrice, ApproximateTotalPrice = lowestPrice.ApproximateTotalPrice, ApproximateBasePrice = lowestPrice.ApproximateBasePrice, Taxes = lowestPrice.Taxes, ApproximateTaxes = lowestPrice.ApproximateTaxes, QuoteDate = lowestPrice.QuoteDate }; List <typeBaseAirSegment> finalSegments = new List <typeBaseAirSegment>(); List <AirPricingInfo> finalPriceInfo = new List <AirPricingInfo>(); foreach (var segmentRef in lowestPrice.AirSegmentRef) { foreach (var segment in airItinerary.AirSegment) { if (segmentRef.Key.CompareTo(segment.Key) == 0) { typeBaseAirSegment univSeg = new typeBaseAirSegment() { ArrivalTime = segment.ArrivalTime, AvailabilityDisplayType = segment.AvailabilityDisplayType, AvailabilitySource = segment.AvailabilitySource, Carrier = segment.Carrier, ChangeOfPlane = segment.ChangeOfPlane, ClassOfService = segment.ClassOfService, DepartureTime = segment.DepartureTime, Destination = segment.Destination, Distance = segment.Distance, Equipment = segment.Equipment, FlightNumber = segment.FlightNumber, FlightTime = segment.FlightTime, Group = segment.Group, Key = segment.Key, LinkAvailability = segment.LinkAvailability, OptionalServicesIndicator = segment.OptionalServicesIndicator, Origin = segment.Origin, ParticipantLevel = segment.ParticipantLevel, PolledAvailabilityOption = segment.PolledAvailabilityOption, ProviderCode = segment.ProviderCode, TravelTime = segment.TravelTime, }; finalSegments.Add(univSeg); break; } } } foreach (var priceInfo in lowestPrice.AirPricingInfo) { AirPricingInfo info = new AirPricingInfo() { ApproximateBasePrice = priceInfo.ApproximateBasePrice, ApproximateTotalPrice = priceInfo.ApproximateTotalPrice, BasePrice = priceInfo.BasePrice, ETicketability = (typeEticketability)priceInfo.ETicketability, IncludesVAT = priceInfo.IncludesVAT, Key = priceInfo.Key, LatestTicketingTime = priceInfo.LatestTicketingTime, //PlatingCarrier = priceInfo.PlatingCarrier, Optional but might be required for some carriers PricingMethod = (typePricingMethod)priceInfo.PricingMethod, ProviderCode = priceInfo.ProviderCode, Taxes = priceInfo.Taxes, TotalPrice = priceInfo.TotalPrice, }; List <FareInfo> fareInfoList = new List <FareInfo>(); List <ManualFareAdjustment> fareAdjustmentList = new List <ManualFareAdjustment>(); ManualFareAdjustment adjustment = new ManualFareAdjustment() { AdjustmentType = typeAdjustmentType.Amount, AppliedOn = typeAdjustmentTarget.Base, Value = +40, PassengerRef = "gr8AVWGCR064r57Jt0+8bA==" }; fareAdjustmentList.Add(adjustment); info.AirPricingModifiers = new AirPricingModifiers() { ManualFareAdjustment = fareAdjustmentList.ToArray() }; foreach (var fareInfo in priceInfo.FareInfo) { FareInfo createInfo = new FareInfo() { Amount = fareInfo.Amount, DepartureDate = fareInfo.DepartureDate, Destination = fareInfo.Destination, EffectiveDate = fareInfo.EffectiveDate, FareBasis = fareInfo.FareBasis, Key = fareInfo.Key, NotValidAfter = fareInfo.NotValidAfter, NotValidBefore = fareInfo.NotValidBefore, Origin = fareInfo.Origin, PassengerTypeCode = fareInfo.PassengerTypeCode, PrivateFare = (typePrivateFare)fareInfo.PrivateFare, PseudoCityCode = fareInfo.PseudoCityCode, FareRuleKey = new FareRuleKey() { FareInfoRef = fareInfo.FareRuleKey.FareInfoRef, ProviderCode = fareInfo.FareRuleKey.ProviderCode, Value = fareInfo.FareRuleKey.Value } }; List <Endorsement> endorsementList = new List <Endorsement>(); if (fareInfo.Endorsement != null) { foreach (var endorse in fareInfo.Endorsement) { Endorsement createEndorse = new Endorsement() { Value = endorse.Value }; endorsementList.Add(createEndorse); } createInfo.Endorsement = endorsementList.ToArray(); } fareInfoList.Add(createInfo); } info.FareInfo = fareInfoList.ToArray(); List <BookingInfo> bInfo = new List <BookingInfo>(); foreach (var bookingInfo in priceInfo.BookingInfo) { BookingInfo createBookingInfo = new BookingInfo() { BookingCode = bookingInfo.BookingCode, CabinClass = bookingInfo.CabinClass, FareInfoRef = bookingInfo.FareInfoRef, SegmentRef = bookingInfo.SegmentRef }; bInfo.Add(createBookingInfo); } info.BookingInfo = bInfo.ToArray(); List <typeTaxInfo> taxes = new List <typeTaxInfo>(); foreach (var tax in priceInfo.TaxInfo) { typeTaxInfo createTaxInfo = new typeTaxInfo() { Amount = tax.Amount, Category = tax.Category, Key = tax.Key }; taxes.Add(createTaxInfo); } info.TaxInfo = taxes.ToArray(); info.FareCalc = priceInfo.FareCalc; List <PassengerType> passengers = new List <PassengerType>(); /*foreach (var pass in priceInfo.PassengerType) * { * PassengerType passType = new PassengerType() * { * BookingTravelerRef = pass.BookingTravelerRef, * Code = pass.BookingTravelerRef * }; * * passengers.Add(passType); * }*/ passengers.Add(new PassengerType() { Code = "ADT", BookingTravelerRef = "gr8AVWGCR064r57Jt0+8bA==" }); info.PassengerType = passengers.ToArray(); if (priceInfo.ChangePenalty != null) { info.ChangePenalty = new typeFarePenalty() { Amount = priceInfo.ChangePenalty.Amount }; } List <BaggageAllowanceInfo> baggageInfoList = new List <BaggageAllowanceInfo>(); foreach (var allowanceInfo in priceInfo.BaggageAllowances.BaggageAllowanceInfo) { BaggageAllowanceInfo createBaggageInfo = new BaggageAllowanceInfo() { Carrier = allowanceInfo.Carrier, Destination = allowanceInfo.Destination, Origin = allowanceInfo.Origin, TravelerType = allowanceInfo.TravelerType }; List <URLInfo> urlInfoList = new List <URLInfo>(); foreach (var url in allowanceInfo.URLInfo) { URLInfo urlInfo = new URLInfo() { URL = url.URL }; urlInfoList.Add(urlInfo); } createBaggageInfo.URLInfo = urlInfoList.ToArray(); List <ConsoleApplication1.UniversalService.TextInfo> textInfoList = new List <UniversalService.TextInfo>(); foreach (var textData in allowanceInfo.TextInfo) { ConsoleApplication1.UniversalService.TextInfo textInfo = new UniversalService.TextInfo() { Text = textData.Text }; textInfoList.Add(textInfo); } createBaggageInfo.TextInfo = textInfoList.ToArray(); List <BagDetails> bagDetailsList = new List <BagDetails>(); foreach (var bagDetails in allowanceInfo.BagDetails) { BagDetails bag = new BagDetails() { ApplicableBags = bagDetails.ApplicableBags, ApproximateBasePrice = bagDetails.ApproximateBasePrice, ApproximateTotalPrice = bagDetails.ApproximateTotalPrice, BasePrice = bagDetails.BasePrice, TotalPrice = bagDetails.TotalPrice, }; List <BaggageRestriction> bagRestictionList = new List <BaggageRestriction>(); foreach (var restriction in bagDetails.BaggageRestriction) { List <ConsoleApplication1.UniversalService.TextInfo> restrictionTextList = new List <UniversalService.TextInfo>(); foreach (var bagResTextInfo in restriction.TextInfo) { ConsoleApplication1.UniversalService.TextInfo resText = new UniversalService.TextInfo() { Text = bagResTextInfo.Text }; restrictionTextList.Add(resText); } BaggageRestriction bagRes = new BaggageRestriction() { TextInfo = restrictionTextList.ToArray() }; bagRestictionList.Add(bagRes); } bag.BaggageRestriction = bagRestictionList.ToArray(); bagDetailsList.Add(bag); } createBaggageInfo.BagDetails = bagDetailsList.ToArray(); baggageInfoList.Add(createBaggageInfo); } List <CarryOnAllowanceInfo> carryOnAllowanceList = new List <CarryOnAllowanceInfo>(); foreach (var carryOnBag in priceInfo.BaggageAllowances.CarryOnAllowanceInfo) { CarryOnAllowanceInfo carryOn = new CarryOnAllowanceInfo() { Carrier = carryOnBag.Carrier, Destination = carryOnBag.Destination, Origin = carryOnBag.Origin }; carryOnAllowanceList.Add(carryOn); } List <BaseBaggageAllowanceInfo> embargoInfoList = new List <BaseBaggageAllowanceInfo>(); if (priceInfo.BaggageAllowances.EmbargoInfo != null) { foreach (AirService.BaseBaggageAllowanceInfo embargoInfo in priceInfo.BaggageAllowances.EmbargoInfo) { BaseBaggageAllowanceInfo embargo = new BaseBaggageAllowanceInfo() { Carrier = embargoInfo.Carrier, Destination = embargoInfo.Destination, Origin = embargoInfo.Origin }; List <URLInfo> embargoURLList = new List <URLInfo>(); foreach (var embargoUrl in embargoInfo.URLInfo) { URLInfo url = new URLInfo() { URL = embargoUrl.URL, Text = embargoUrl.Text }; embargoURLList.Add(url); } embargo.URLInfo = embargoURLList.ToArray(); List <ConsoleApplication1.UniversalService.TextInfo> embargoTextList = new List <UniversalService.TextInfo>(); foreach (var embargoText in embargoInfo.TextInfo) { ConsoleApplication1.UniversalService.TextInfo text = new UniversalService.TextInfo() { Text = embargoText.Text }; embargoTextList.Add(text); } embargo.TextInfo = embargoTextList.ToArray(); embargoInfoList.Add(embargo); } } info.BaggageAllowances = new BaggageAllowances() { BaggageAllowanceInfo = baggageInfoList.ToArray(), CarryOnAllowanceInfo = carryOnAllowanceList.ToArray(), EmbargoInfo = embargoInfoList.ToArray() }; finalPriceInfo.Add(info); break; } finalPrice.AirPricingInfo = finalPriceInfo.ToArray(); finalPrice.AirSegment = finalSegments.ToArray(); return(finalPrice); }
private AirPricingSolution AddAirPriceSolution(AirService.AirPricingSolution lowestPrice, AirService.AirItinerary airItinerary) { AirPricingSolution finalPrice = new AirPricingSolution() { Key = lowestPrice.Key, TotalPrice = lowestPrice.TotalPrice, BasePrice = lowestPrice.BasePrice, ApproximateTotalPrice = lowestPrice.ApproximateTotalPrice, ApproximateBasePrice = lowestPrice.ApproximateBasePrice, Taxes = lowestPrice.Taxes, ApproximateTaxes = lowestPrice.ApproximateTaxes, QuoteDate = lowestPrice.QuoteDate }; List<typeBaseAirSegment> finalSegments = new List<typeBaseAirSegment>(); List<AirPricingInfo> finalPriceInfo =new List<AirPricingInfo>(); foreach (var segmentRef in lowestPrice.AirSegmentRef) { foreach (var segment in airItinerary.AirSegment) { if (segmentRef.Key.CompareTo(segment.Key) == 0) { typeBaseAirSegment univSeg = new typeBaseAirSegment() { ArrivalTime = segment.ArrivalTime, AvailabilityDisplayType = segment.AvailabilityDisplayType, AvailabilitySource = segment.AvailabilitySource, Carrier = segment.Carrier, ChangeOfPlane = segment.ChangeOfPlane, ClassOfService = segment.ClassOfService, DepartureTime = segment.DepartureTime, Destination = segment.Destination, Distance = segment.Distance, Equipment = segment.Equipment, FlightNumber = segment.FlightNumber, FlightTime = segment.FlightTime, Group = segment.Group, Key = segment.Key, LinkAvailability = segment.LinkAvailability, OptionalServicesIndicator = segment.OptionalServicesIndicator, Origin = segment.Origin, ParticipantLevel = segment.ParticipantLevel, PolledAvailabilityOption = segment.PolledAvailabilityOption, ProviderCode = segment.ProviderCode, TravelTime = segment.TravelTime, }; finalSegments.Add(univSeg); break; } } } foreach (var priceInfo in lowestPrice.AirPricingInfo) { AirPricingInfo info = new AirPricingInfo() { ApproximateBasePrice = priceInfo.ApproximateBasePrice, ApproximateTotalPrice = priceInfo.ApproximateTotalPrice, BasePrice = priceInfo.BasePrice, ETicketability = (typeEticketability)priceInfo.ETicketability, IncludesVAT = priceInfo.IncludesVAT, Key = priceInfo.Key, LatestTicketingTime = priceInfo.LatestTicketingTime, //PlatingCarrier = priceInfo.PlatingCarrier, Optional but might be required for some carriers PricingMethod = (typePricingMethod)priceInfo.PricingMethod, ProviderCode = priceInfo.ProviderCode, Taxes = priceInfo.Taxes, TotalPrice = priceInfo.TotalPrice, }; List<FareInfo> fareInfoList = new List<FareInfo>(); List<ManualFareAdjustment> fareAdjustmentList = new List<ManualFareAdjustment>(); ManualFareAdjustment adjustment = new ManualFareAdjustment() { AdjustmentType = typeAdjustmentType.Amount, AppliedOn = typeAdjustmentTarget.Base, Value = +40, PassengerRef = "gr8AVWGCR064r57Jt0+8bA==" }; fareAdjustmentList.Add(adjustment); info.AirPricingModifiers = new AirPricingModifiers() { ManualFareAdjustment = fareAdjustmentList.ToArray() }; foreach (var fareInfo in priceInfo.FareInfo) { FareInfo createInfo = new FareInfo() { Amount = fareInfo.Amount, DepartureDate = fareInfo.DepartureDate, Destination = fareInfo.Destination, EffectiveDate = fareInfo.EffectiveDate, FareBasis = fareInfo.FareBasis, Key = fareInfo.Key, NotValidAfter = fareInfo.NotValidAfter, NotValidBefore = fareInfo.NotValidBefore, Origin = fareInfo.Origin, PassengerTypeCode = fareInfo.PassengerTypeCode, PrivateFare = (typePrivateFare)fareInfo.PrivateFare, PseudoCityCode = fareInfo.PseudoCityCode, FareRuleKey = new FareRuleKey() { FareInfoRef = fareInfo.FareRuleKey.FareInfoRef, ProviderCode = fareInfo.FareRuleKey.ProviderCode, Value = fareInfo.FareRuleKey.Value } }; List<Endorsement> endorsementList = new List<Endorsement>(); if (fareInfo.Endorsement != null) { foreach (var endorse in fareInfo.Endorsement) { Endorsement createEndorse = new Endorsement() { Value = endorse.Value }; endorsementList.Add(createEndorse); } createInfo.Endorsement = endorsementList.ToArray(); } fareInfoList.Add(createInfo); } info.FareInfo = fareInfoList.ToArray(); List<BookingInfo> bInfo = new List<BookingInfo>(); foreach (var bookingInfo in priceInfo.BookingInfo) { BookingInfo createBookingInfo = new BookingInfo() { BookingCode = bookingInfo.BookingCode, CabinClass = bookingInfo.CabinClass, FareInfoRef = bookingInfo.FareInfoRef, SegmentRef = bookingInfo.SegmentRef }; bInfo.Add(createBookingInfo); } info.BookingInfo = bInfo.ToArray(); List<typeTaxInfo> taxes = new List<typeTaxInfo>(); foreach (var tax in priceInfo.TaxInfo) { typeTaxInfo createTaxInfo = new typeTaxInfo() { Amount = tax.Amount, Category = tax.Category, Key = tax.Key }; taxes.Add(createTaxInfo); } info.TaxInfo = taxes.ToArray(); info.FareCalc = priceInfo.FareCalc; List<PassengerType> passengers = new List<PassengerType>(); /*foreach (var pass in priceInfo.PassengerType) { PassengerType passType = new PassengerType() { BookingTravelerRef = pass.BookingTravelerRef, Code = pass.BookingTravelerRef }; passengers.Add(passType); }*/ passengers.Add(new PassengerType() { Code = "ADT", BookingTravelerRef = "gr8AVWGCR064r57Jt0+8bA==" }); info.PassengerType = passengers.ToArray(); if (priceInfo.ChangePenalty != null) { info.ChangePenalty = new typeFarePenalty() { Amount = priceInfo.ChangePenalty.Amount }; } List<BaggageAllowanceInfo> baggageInfoList = new List<BaggageAllowanceInfo>(); foreach (var allowanceInfo in priceInfo.BaggageAllowances.BaggageAllowanceInfo) { BaggageAllowanceInfo createBaggageInfo = new BaggageAllowanceInfo() { Carrier = allowanceInfo.Carrier, Destination = allowanceInfo.Destination, Origin = allowanceInfo.Origin, TravelerType = allowanceInfo.TravelerType }; List<URLInfo> urlInfoList = new List<URLInfo>(); foreach (var url in allowanceInfo.URLInfo) { URLInfo urlInfo = new URLInfo() { URL = url.URL }; urlInfoList.Add(urlInfo); } createBaggageInfo.URLInfo = urlInfoList.ToArray(); List<ConsoleApplication1.UniversalService.TextInfo> textInfoList = new List<UniversalService.TextInfo>(); foreach (var textData in allowanceInfo.TextInfo) { ConsoleApplication1.UniversalService.TextInfo textInfo = new UniversalService.TextInfo() { Text = textData.Text }; textInfoList.Add(textInfo); } createBaggageInfo.TextInfo = textInfoList.ToArray(); List<BagDetails> bagDetailsList = new List<BagDetails>(); foreach (var bagDetails in allowanceInfo.BagDetails) { BagDetails bag = new BagDetails() { ApplicableBags = bagDetails.ApplicableBags, ApproximateBasePrice = bagDetails.ApproximateBasePrice, ApproximateTotalPrice = bagDetails.ApproximateTotalPrice, BasePrice = bagDetails.BasePrice, TotalPrice = bagDetails.TotalPrice, }; List<BaggageRestriction> bagRestictionList = new List<BaggageRestriction>(); foreach (var restriction in bagDetails.BaggageRestriction) { List<ConsoleApplication1.UniversalService.TextInfo> restrictionTextList = new List<UniversalService.TextInfo>(); foreach (var bagResTextInfo in restriction.TextInfo) { ConsoleApplication1.UniversalService.TextInfo resText = new UniversalService.TextInfo() { Text = bagResTextInfo.Text }; restrictionTextList.Add(resText); } BaggageRestriction bagRes = new BaggageRestriction() { TextInfo = restrictionTextList.ToArray() }; bagRestictionList.Add(bagRes); } bag.BaggageRestriction = bagRestictionList.ToArray(); bagDetailsList.Add(bag); } createBaggageInfo.BagDetails = bagDetailsList.ToArray(); baggageInfoList.Add(createBaggageInfo); } List<CarryOnAllowanceInfo> carryOnAllowanceList = new List<CarryOnAllowanceInfo>(); foreach (var carryOnBag in priceInfo.BaggageAllowances.CarryOnAllowanceInfo) { CarryOnAllowanceInfo carryOn = new CarryOnAllowanceInfo() { Carrier = carryOnBag.Carrier, Destination = carryOnBag.Destination, Origin = carryOnBag.Origin }; carryOnAllowanceList.Add(carryOn); } List<BaseBaggageAllowanceInfo> embargoInfoList = new List<BaseBaggageAllowanceInfo>(); if(priceInfo.BaggageAllowances.EmbargoInfo != null) { foreach(AirService.BaseBaggageAllowanceInfo embargoInfo in priceInfo.BaggageAllowances.EmbargoInfo) { BaseBaggageAllowanceInfo embargo = new BaseBaggageAllowanceInfo() { Carrier = embargoInfo.Carrier, Destination = embargoInfo.Destination, Origin = embargoInfo.Origin }; List<URLInfo> embargoURLList = new List<URLInfo>(); foreach(var embargoUrl in embargoInfo.URLInfo){ URLInfo url = new URLInfo() { URL = embargoUrl.URL, Text = embargoUrl.Text }; embargoURLList.Add(url); } embargo.URLInfo = embargoURLList.ToArray(); List<ConsoleApplication1.UniversalService.TextInfo> embargoTextList = new List<UniversalService.TextInfo>(); foreach(var embargoText in embargoInfo.TextInfo){ ConsoleApplication1.UniversalService.TextInfo text = new UniversalService.TextInfo() { Text = embargoText.Text }; embargoTextList.Add(text); } embargo.TextInfo = embargoTextList.ToArray(); embargoInfoList.Add(embargo); } } info.BaggageAllowances = new BaggageAllowances() { BaggageAllowanceInfo = baggageInfoList.ToArray(), CarryOnAllowanceInfo = carryOnAllowanceList.ToArray(), EmbargoInfo = embargoInfoList.ToArray() }; finalPriceInfo.Add(info); break; } finalPrice.AirPricingInfo = finalPriceInfo.ToArray(); finalPrice.AirSegment = finalSegments.ToArray(); return finalPrice; }
static void Main(string[] args) { // // PING REQUEST // String payload = "this my payload; there are many like it but this one is mine"; String someTraceId = "doesntmatter-8176"; String originApp = "UAPI"; //set up the request parameters into a PingReq object PingReq req = new PingReq(); req.Payload = payload; req.TraceId = someTraceId; ConsoleApplication1.SystemService.BillingPointOfSaleInfo billSetInfo = new ConsoleApplication1.SystemService.BillingPointOfSaleInfo(); billSetInfo.OriginApplication = originApp; req.BillingPointOfSaleInfo = billSetInfo; req.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH); Console.WriteLine(req); try { //run the ping request //WSDLService.sysPing.showXML(true); SystemPingPortTypeClient client = new SystemPingPortTypeClient("SystemPingPort", WsdlService.SYSTEM_ENDPOINT); //Console.WriteLine(client.Endpoint); client.ClientCredentials.UserName.UserName = Helper.RetrunUsername(); client.ClientCredentials.UserName.Password = Helper.ReturnPassword(); /*var httpHeaders = new Dictionary<string, string>(); * httpHeaders.Add("Username", "travelportsuperadmin"); * httpHeaders.Add("Password", "abc123"); * client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders));*/ /*HttpRequestMessageProperty httpRequestProperty = new HttpRequestMessageProperty(); * httpRequestProperty.Headers[HttpRequestHeader.Authorization] = "Basic " + * Convert.ToBase64String(Encoding.ASCII.GetBytes(client.ClientCredentials.UserName.UserName + * ":" + client.ClientCredentials.UserName.Password)); * * using (OperationContextScope scope = new OperationContextScope(client.InnerChannel)) * { * OperationContext.Current.OutgoingMessageProperties[HttpRequestMessageProperty.Name] = * httpRequestProperty; * return client.processRequest(castRequest) as TSRsp; * } * * * OperationContext.Current.OutgoingMessageProperties*/ var httpHeaders = Helper.ReturnHttpHeader(); client.Endpoint.EndpointBehaviors.Add(new HttpHeadersEndpointBehavior(httpHeaders)); PingRsp rsp = client.service(req); //print results.. payload and trace ID are echoed back in response Console.WriteLine(rsp.Payload); //Console.WriteLine(rsp.TraceId); //Console.WriteLine(rsp.TransactionId); AirportDetails airports = new AirportDetails(); //Here we are getting the list of airports, we can use it anyway we want IDictionary <String, String> airportsList = airports.AllAirportsList(); //Here we are getting the list of airports in a particular city, we are harcoding the city as New York here IDictionary <String, String> airportInCityList = airports.GetAllAiportsFromParticualrCity("New York"); AirSvcTest airTest = new AirSvcTest(); airTest.Availability(); AirLFSTest lfsTest = new AirLFSTest(); Boolean solutionResult = false; //Change it to true if you want AirPricingSolution, by default it is false //and will send AirPricePoint in the result LowFareSearchRsp lowFareRsp = lfsTest.LowFareShop(solutionResult); if (lowFareRsp != null) { typeBaseAirSegment[] airSegments = lowFareRsp.AirSegmentList; List <typeBaseAirSegment> pricingSegments = new List <typeBaseAirSegment>(); IEnumerator items = lowFareRsp.Items.GetEnumerator(); AirPricingSolution lowestFare = null; AirPricePoint lowest = null; while (items.MoveNext()) { if (solutionResult) { AirPricingSolution airPricingSolution = (AirPricingSolution)items.Current; if (lowestFare == null) { lowestFare = airPricingSolution; } else { if (Helper.ConvertToDecimal(lowestFare.TotalPrice) > Helper.ConvertToDecimal(airPricingSolution.TotalPrice)) { lowestFare = airPricingSolution; } } } else { AirPricePointList airPricePointList = (AirPricePointList)items.Current; if (airPricePointList != null) { foreach (var airPricePoint in airPricePointList.AirPricePoint) { if (lowest == null) { lowest = airPricePoint; } else { if (Helper.ConvertToDecimal(lowest.TotalPrice) > Helper.ConvertToDecimal(airPricePoint.TotalPrice)) { lowest = airPricePoint; } } } } } } if (lowestFare != null) { IEnumerator journeys = lowestFare.Journey.GetEnumerator(); while (journeys.MoveNext()) { Journey journeyDetails = (Journey)journeys.Current; if (journeyDetails != null) { AirSegmentRef[] segmentRef = journeyDetails.AirSegmentRef; string refKey = segmentRef[0].Key; IEnumerator airSegmentList = airSegments.GetEnumerator(); while (airSegmentList.MoveNext()) { typeBaseAirSegment airSeg = (typeBaseAirSegment)airSegmentList.Current; if (airSeg.Key.CompareTo(refKey) == 0) { pricingSegments.Add(airSeg); break; } } } } } if (lowest != null) { IEnumerator pricingInfos = lowest.AirPricingInfo.GetEnumerator(); while (pricingInfos.MoveNext()) { AirPricingInfo priceInfo = (AirPricingInfo)pricingInfos.Current; if (priceInfo != null) { foreach (var flightOption in priceInfo.FlightOptionsList) { FlightOption option = flightOption; IEnumerator options = option.Option.GetEnumerator(); if (options.MoveNext()) { Option opt = (Option)options.Current; if (opt != null) { IEnumerator bookingInfoList = opt.BookingInfo.GetEnumerator(); if (bookingInfoList.MoveNext()) { BookingInfo bookingInfo = (BookingInfo)bookingInfoList.Current; if (bookingInfo != null) { String key = bookingInfo.SegmentRef; IEnumerator airSegmentList = airSegments.GetEnumerator(); while (airSegmentList.MoveNext()) { typeBaseAirSegment airSeg = (typeBaseAirSegment)airSegmentList.Current; if (airSeg.Key.CompareTo(key) == 0) { pricingSegments.Add(airSeg); break; } } } } } } break; } } } } AirPriceRsp priceRsp = AirReq.AirPrice(pricingSegments); AirPricingSolution lowestPrice = null; if (priceRsp != null) { if (priceRsp.AirPriceResult != null) { IEnumerator priceResults = priceRsp.AirPriceResult.GetEnumerator(); if (priceResults.MoveNext())//We would take the first Price Result and will Search for the lowest Price { AirPriceResult result = (AirPriceResult)priceResults.Current; if (result.AirPricingSolution != null) { IEnumerator priceingSolutions = result.AirPricingSolution.GetEnumerator(); while (priceingSolutions.MoveNext()) { AirPricingSolution priceSol = (AirPricingSolution)priceingSolutions.Current; if (lowestPrice == null) { lowestPrice = priceSol; } else { if (Helper.ConvertToDecimal(lowestPrice.TotalPrice) > Helper.ConvertToDecimal(priceSol.TotalPrice)) { lowestPrice = priceSol; } } } } } } if (lowestPrice != null && priceRsp.AirItinerary != null) { AirBookTest book = new AirBookTest(); ConsoleApplication1.UniversalService.AirCreateReservationRsp bookResponse = book.AirBook(lowestPrice, priceRsp.AirItinerary); if (bookResponse != null) { var urLocatorCode = bookResponse.UniversalRecord.LocatorCode; Console.WriteLine("Universal Record Locator Code :" + urLocatorCode); UniversalRetrieveTest univ = new UniversalRetrieveTest(); univ.RetrieveRecord(urLocatorCode); } } } } } catch (Exception e) { //usually only the error message is useful, not the full stack //trace, since the stack trace in is your address space... Console.WriteLine("Error : " + e.Message); } }