internal AirFareDisplayRsp GetAirFareDisplayDetails(List <typeBaseAirSegment> pricingSegments) { AirFareDisplayReq fareDisplayReq = new AirFareDisplayReq(); AirFareDisplayRsp fareDisplayRsp; fareDisplayReq.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH); string depart = ""; IEnumerator <typeBaseAirSegment> segments = pricingSegments.GetEnumerator(); if (segments.MoveNext()) { typeBaseAirSegment seg = segments.Current; if (seg.Origin != null) { fareDisplayReq.Origin = seg.Origin; } if (seg.Destination != null) { fareDisplayReq.Destination = seg.Destination; } if (seg.DepartureTime != null) { depart = seg.DepartureTime; } fareDisplayReq.ProviderCode = "1G"; } fareDisplayReq.BillingPointOfSaleInfo = new BillingPointOfSaleInfo() { OriginApplication = "UAPI" }; fareDisplayReq.PassengerType = AddPassengerType(); fareDisplayReq.AirFareDisplayModifiers = AddAirFareDisplayModifiers(depart); AirFareDisplayPortTypeClient client = new AirFareDisplayPortTypeClient("AirFareDisplayPort", 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)); fareDisplayRsp = client.service(null, fareDisplayReq); return(fareDisplayRsp); } catch (Exception se) { Console.WriteLine("Error : " + se.Message); client.Abort(); return(null); } }
private Models.Responses.Leg GenerateLeg(Option option, List <typeBaseAirSegment> segments) { typeBaseAirSegment segment = new typeBaseAirSegment(); try { Models.Responses.Leg leg = new Models.Responses.Leg { Elapsed = ToElapsed(option.TravelTime), Segments = option.BookingInfo.ToList().Select(bi => { segment = segments.Where(s => s.Key == bi.SegmentRef).FirstOrDefault(); return(new SegmentRS { Key = segment.Key, Group = segment.Group, Origin = segment.Origin, Destination = segment.Destination, Departure = ConvertToTiming(segment.DepartureTime), Arrival = ConvertToTiming(segment.ArrivalTime), BookingCode = bi.BookingCode, CabinClass = bi.CabinClass, Elapsed = Convert.ToInt32(segment.FlightTime), MarketingFlight = new FlightNumber { Airline = segment.Carrier, Number = segment.FlightNumber }, OperatingFlight = new FlightNumber { Airline = segment.Carrier, Number = segment.FlightNumber } }); }).ToList() }; return(leg); } catch (Exception ex) { var currentMethod = System.Reflection.MethodBase.GetCurrentMethod(); var fullMethodName = currentMethod.DeclaringType.FullName + "." + currentMethod.Name; _LogService.LogInfo($"currentMethod.Name/Segment", segment); _LogService.LogException(ex, fullMethodName); throw; } }
internal static AirPriceRsp AirPrice(List <typeBaseAirSegment> pricingSegments) { AirPriceReq priceReq = new AirPriceReq(); AirPriceRsp priceRsp; AddPointOfSale(priceReq, "UAPI"); AirItinerary itinerary = new AirItinerary(); List <typeBaseAirSegment> itinerarySegments = new List <typeBaseAirSegment>(); IEnumerator airSegments = pricingSegments.GetEnumerator(); while (airSegments.MoveNext()) { typeBaseAirSegment seg = (typeBaseAirSegment)airSegments.Current; seg.ProviderCode = "1G"; seg.FlightDetailsRef = null; seg.ClassOfService = "Y"; itinerarySegments.Add(seg); } itinerary.AirSegment = itinerarySegments.ToArray(); priceReq.AirItinerary = itinerary; priceReq.SearchPassenger = AddSearchPassenger(); priceReq.AirPricingModifiers = new AirPricingModifiers() { PlatingCarrier = priceReq.AirItinerary.AirSegment[0].Carrier }; List <AirPricingCommand> pricingCommands = new List <AirPricingCommand>(); AirPricingCommand command = new AirPricingCommand() { CabinClass = "Economy"//You can use Economy,PremiumEconomy,Business etc. }; pricingCommands.Add(command); priceReq.AirPricingCommand = pricingCommands.ToArray(); priceReq.TargetBranch = CommonUtility.GetConfigValue(ProjectConstants.G_TARGET_BRANCH); AirPricePortTypeClient client = new AirPricePortTypeClient("AirPricePort", 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)); priceRsp = client.service(null, priceReq); return(priceRsp); } catch (Exception se) { Console.WriteLine("Error : " + se.Message); client.Abort(); return(null); } }
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); } }