public GetLowFareAvailabilityResponse getlowfareavailability(String dstation, String astation, DateTime startdate, DateTime endate, int numadt, int numchd, String currency, String faretype, String sourceorg, int nightstay) { GetLowFareAvailabilityRequest getlowfareavailrequest = new GetLowFareAvailabilityRequest(); getlowfareavailrequest.Signature = signature; //getlowfareavailrequest.AvailabilityRequest = new AvailabilityRequest();//instantiate a new object AvailabilityRequest availabilityrequest = new AvailabilityRequest(); getlowfareavailrequest.AvailabilityRequest = availabilityrequest;// to instantiate an obj if (sourceorg.Length > 0) { availabilityrequest.SourceOrganization = sourceorg; } availabilityrequest.PaxCount = (short)(numadt + numchd); PaxPriceType[] pricetypes = new PaxPriceType[numadt + numchd]; for (int i = 0; i < pricetypes.Length; i++) { pricetypes[i] = new PaxPriceType(); if (i < numadt) { pricetypes[i].PaxType = "ADT"; } else { pricetypes[i].PaxType = "CHD"; } } availabilityrequest.PaxPriceTypes = pricetypes;//equate it back to the array declared availabilityrequest.AvailabilityType = AvailabilityType.Default; availabilityrequest.AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable; availabilityrequest.DepartureStation = dstation; availabilityrequest.ArrivalStation = astation; availabilityrequest.BeginDate = startdate; availabilityrequest.EndDate = endate; availabilityrequest.FlightType = FlightType.All; availabilityrequest.Dow = DOW.Daily; availabilityrequest.MaximumConnectingFlights = 5; availabilityrequest.FareTypes = new string[1]; availabilityrequest.FareTypes[0] = faretype; // pass it back to the method parameter availabilityrequest.FareClassControl = FareClassControl.CompressByProductClass; availabilityrequest.IncludeTaxesAndFees = true; getlowfareavailrequest.AvailabilityRequest = availabilityrequest;// cache availability data back to the getlowfareavailrequest obj GetLowFareAvailabilityResponse getlowfareavailresponse = clientapi.GetLowFareAvailability(getlowfareavailrequest); if (getlowfareavailresponse.GetAvailabilityResponse.Schedule.Length > 0) { Console.WriteLine("{0} journeys returned by availabilty", getlowfareavailresponse.GetAvailabilityResponse.Schedule.Length); } else { Console.WriteLine("No journey found"); getlowfareavailresponse = null; } return getlowfareavailresponse; }
public BookingManager.GetAvailabilityResponse GetAvailability(String dstation, String astation, DateTime startdate, DateTime endate, int numadt, int numchd, String currency, String faretype, String sourceorg,int nightstay) { BookingManager.GetAvailabilityRequest gar = new GetAvailabilityRequest();//this is from service contracts gar.Signature = signature;//i need to use the signature property to sign in gar.TripAvailabilityRequest = new TripAvailabilityRequest(); // call the method TripAvailabilityRequest from the GetAvaialbilityRequest class // gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array PaxPriceType[] priceTypes; // 9- not passed in method but i have to do this step because it is a required parameter priceTypes = new PaxPriceType[2];//this is to define the type of passenger travelling, whether adt or chd. But to check how many of each then i need to use the Pax Count or passenger info for (int j = 0; j < priceTypes.Length; j++) { priceTypes[j] = new PaxPriceType(); if (j < 1) // this sets the first item of array to an adult { priceTypes[j].PaxType = "ADT"; } else // this sets the second item to child { priceTypes[j].PaxType = "CHD"; } } if (nightstay == 0) { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array } else { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[2]; } for (int i = 0; i < gar.TripAvailabilityRequest.AvailabilityRequests.Length; i++) { BookingManager.AvailabilityRequest ar = new AvailabilityRequest();//this is from data contracts //AvailabilityRequest []ar = new AvailabilityRequest[2]; //ar[0] = new AvailabilityRequest(); //ar[1] = new AvailabilityRequest(); if (sourceorg.Length > 0)// if this value is passed in then ar.SourceOrganization (parameter) will be the next line { ar.SourceOrganization = sourceorg; //1 } ar.PaxCount = (short)(numadt + numchd); //2 ar.CurrencyCode = currency;//7 ar.PaxPriceTypes = priceTypes; if (faretype.Equals("ST")) { ar.AvailabilityType = AvailabilityType.Standby; } else { ar.AvailabilityType = AvailabilityType.Default; } ar.AvailabilityFilter = AvailabilityFilter.Default; if (i == 0)//check if it is a one way trip or return trip { ar.DepartureStation = dstation; ar.ArrivalStation = astation; ar.BeginDate = startdate; ar.EndDate = endate; } else { ar.DepartureStation = astation; ar.ArrivalStation = dstation; ar.BeginDate = endate; ar.EndDate = endate; //ar.DepartureStations = new string[1];// for return //ar.DepartureStations[0] = astation; //ar.ArrivalStations = new string[1]; //ar.ArrivalStations[0] = dstation; } ar.FlightType = FlightType.All;//10 ar.Dow = DOW.Daily;//11 ar.MaximumConnectingFlights = 5;//14--since flight type is direct ar.AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable;//13..this will still return me a result set if my currency is set to null although the function demands i pass a value in as the filter is based on flights ar.IncludeTaxesAndFees = true; ar.SSRCollectionsMode = SSRCollectionsMode.Leg;//this i sto tell me the list of SSR avaialble for purchase ar.FareClassControl = FareClassControl.CompressByProductClass; ar.InboundOutbound = InboundOutbound.None; ar.FareTypes = new String[1];// must be RE-regular or ST for standby fares ar.FareTypes[0] = faretype; gar.TripAvailabilityRequest.AvailabilityRequests[i] = ar;//get all the parameters from getavailability field and put it back to ar. } DateTime startTiming = DateTime.Now; BookingManager.GetAvailabilityResponse garesponse = clientapi.GetAvailability(gar); DateTime endTiming = DateTime.Now; Console.WriteLine("Timing: " + endTiming.Subtract(startTiming).Seconds + "Seconds"); if (garesponse.GetTripAvailabilityResponse.Schedules.Length > 0 && garesponse.GetTripAvailabilityResponse.Schedules[0].Length > 0)//schedules refer to the journey markets returned from the search { Console.WriteLine("{0} journey by availability", garesponse.GetTripAvailabilityResponse.Schedules[0][0].Journeys.Length);// return response is always in a 2 dimensional array } else { Console.WriteLine("No journey found"); garesponse = null; } return garesponse; }
public static void GetPriceReturn(string signature, GetAvailabilityResponse response, string noofPassenger) { IBookingManager bookingManager = new BookingManagerClient(); DataTable flights = Table_Flights(); DataTable fare = Table_Fare(); foreach (JourneyDateMarket[] jdmArray in response.GetTripAvailabilityResponse.Schedules) { foreach (JourneyDateMarket jdm in jdmArray) { foreach (Journey journey in jdm.Journeys) { PriceItineraryRequest pir = new PriceItineraryRequest(); ItineraryPriceRequest ipr = new ItineraryPriceRequest(); ipr.PriceItineraryBy = PriceItineraryBy.JourneyBySellKey; ipr.SellByKeyRequest = new SellJourneyByKeyRequestData(); ipr.SellByKeyRequest.ActionStatusCode = "NN"; SellKeyList[] list = new SellKeyList[1]; list[0] = new SellKeyList(); list[0].JourneySellKey = journey.JourneySellKey; foreach (Segment segment in journey.Segments) { DataRow dr = flights.NewRow(); if (segment.Fares.Length > 0) { list[0].FareSellKey = segment.Fares[0].FareSellKey; dr["ShortDate"] = segment.STD.ToString("ddd MMM d yyyy"); dr["Date"] = segment.STD.ToShortDateString(); dr["From"] = segment.DepartureStation; dr["To"] = segment.ArrivalStation; dr["FlightNo"] = segment.FlightDesignator.FlightNumber; dr["STD"] = segment.STD.ToString("dd/MM/yyy hh:mm tt"); dr["STA"] = segment.STA.ToString("dd/MM/yyy hh:mm tt"); dr["BaseFare"] = segment.Fares[0].PaxFares[0].ServiceCharges[0].Amount; dr["TimeDuration"] = TimeDuration(segment.STD.ToString(), segment.STA.ToString()); flights.Rows.Add(dr); } } ipr.SellByKeyRequest.JourneySellKeys = list; int pax = Convert.ToInt16(noofPassenger);//+ Convert.ToInt16(page.child); ipr.SellByKeyRequest.PaxCount = Convert.ToSByte(pax); PaxPriceType[] priceTypes = new PaxPriceType[ipr.SellByKeyRequest.PaxCount]; for (int i = 0; i < ipr.SellByKeyRequest.PaxCount; i++) { priceTypes[i] = new PaxPriceType(); priceTypes[i].PaxType = "ADT"; priceTypes[i].PaxDiscountCode = string.Empty; } ipr.SellByKeyRequest.PaxPriceType = priceTypes; ipr.SellByKeyRequest.CurrencyCode = "INR"; ipr.SellByKeyRequest.LoyaltyFilter = LoyaltyFilter.MonetaryOnly; ipr.SellByKeyRequest.IsAllotmentMarketFare = false; pir.ItineraryPriceRequest = ipr; pir.Signature = signature; PriceItineraryResponse pire = bookingManager.GetItineraryPrice(pir); foreach (Journey j in pire.Booking.Journeys) { foreach (Segment segment in j.Segments) { foreach (BookingServiceCharge bsc in segment.Fares[0].PaxFares[0].ServiceCharges) { DataRow drr = fare.NewRow(); drr["FlightNo"] = segment.FlightDesignator.FlightNumber; drr["Heads"] = bsc.ChargeType.ToString() + bsc.ChargeCode.ToString(); drr["Amount"] = bsc.Amount; fare.Rows.Add(drr); } } } } } } foreach (DataRow dr in flights.Rows) { dr["TotalFare"] = TotalFare(fare, dr["FlightNo"].ToString()) * (Convert.ToDouble(noofPassenger.ToString())); } HttpContext.Current.Session["Rflights"] = flights; HttpContext.Current.Session["Rfare"] = fare; Logout(signature); }
public static void GetAvailability1(string source, string destination, string ddate, string returndate, string waytype, string noofPassenger) { IBookingManager bookingManager = new BookingManagerClient(); string signature = Login(); GetAvailabilityRequest gar = new GetAvailabilityRequest(); TripAvailabilityRequest tar = new TripAvailabilityRequest(); AvailabilityRequest ar = new AvailabilityRequest(); ar.DepartureStation = source; // "DEL";// HttpContext.Current.Session["origin"].ToString(); ar.ArrivalStation = destination; // "BOM";// HttpContext.Current.Session["destination"].ToString(); //string[] date = ddate.Split('/');// HttpContext.Current.Session["ddate"].ToString().Split('/'); //int year = int.Parse(date[2]), month = int.Parse(date[1]), day = int.Parse(date[0]); int year = int.Parse(ddate.Substring(0, 4)), month = int.Parse(ddate.Substring(4, 2)), day = int.Parse(ddate.Substring(6)); ar.BeginDate = new DateTime(year, month, day); //Convert.ToDateTime("2015-07-07"); ar.EndDate = new DateTime(year, month, day); ar.FlightType = FlightType.Direct; //ar.FlightNumber = b.FlightNo.Length == 3 ? " " + b.FlightNo : b.FlightNo; int pax = Convert.ToInt16(noofPassenger);//+ Convert.ToInt16(page.child); ar.PaxCount = Convert.ToSByte(pax); ar.Dow = DOW.Daily; ar.CurrencyCode = "INR"; ar.AvailabilityType = AvailabilityType.Default; //change 15 oct 2015 ar.MaximumConnectingFlights = 5; ar.AvailabilityFilter = AvailabilityFilter.Default; //change ar.FareClassControl = FareClassControl.LowestFareClass; ar.MinimumFarePrice = 0; ar.MaximumFarePrice = 0; ar.SSRCollectionsMode = SSRCollectionsMode.None; ar.InboundOutbound = InboundOutbound.None; ar.NightsStay = 0; ar.IncludeAllotments = false; ar.FareTypes = new string[1];// change ar.FareTypes[0] = "R"; //ar.FareTypes = new string[1];// change //ar.FareTypes[0] = "BD"; //ar.ProductClasses = new string[1]; //ar.ProductClasses[0] = "BD"; PaxPriceType[] priceTypes = new PaxPriceType[ar.PaxCount]; for (int i = 0; i < ar.PaxCount; i++) { priceTypes[i] = new PaxPriceType(); priceTypes[i].PaxType = "ADT"; priceTypes[i].PaxDiscountCode = String.Empty; } ar.PaxPriceTypes = priceTypes; ar.IncludeTaxesAndFees = false; ar.FareRuleFilter = FareRuleFilter.Default; ar.LoyaltyFilter = LoyaltyFilter.MonetaryOnly; if (!string.IsNullOrEmpty(returndate))// for round trip { AvailabilityRequest rar = new AvailabilityRequest(); rar.DepartureStation = destination; // "DEL";// HttpContext.Current.Session["origin"].ToString(); rar.ArrivalStation = source; // "BOM";// HttpContext.Current.Session["destination"].ToString(); //string[] date = ddate.Split('/');// HttpContext.Current.Session["ddate"].ToString().Split('/'); //int year = int.Parse(date[2]), month = int.Parse(date[1]), day = int.Parse(date[0]); int ryear = int.Parse(returndate.Substring(0, 4)), rmonth = int.Parse(returndate.Substring(4, 2)), rday = int.Parse(returndate.Substring(6)); rar.BeginDate = new DateTime(ryear, rmonth, rday); //Convert.ToDateTime("2015-07-07"); rar.EndDate = new DateTime(ryear, rmonth, rday); rar.FlightType = FlightType.Direct; //ar.FlightNumber = b.FlightNo.Length == 3 ? " " + b.FlightNo : b.FlightNo; int rpax = Convert.ToInt16(noofPassenger);//+ Convert.ToInt16(page.child); rar.PaxCount = Convert.ToSByte(rpax); rar.Dow = DOW.Daily; rar.CurrencyCode = "INR"; rar.AvailabilityType = AvailabilityType.Default; //change 15 oct 2015 rar.MaximumConnectingFlights = 5; rar.AvailabilityFilter = AvailabilityFilter.Default; //change rar.FareClassControl = FareClassControl.LowestFareClass; rar.MinimumFarePrice = 0; rar.MaximumFarePrice = 0; rar.SSRCollectionsMode = SSRCollectionsMode.None; rar.InboundOutbound = InboundOutbound.None; rar.NightsStay = 0; rar.IncludeAllotments = false; rar.FareTypes = new string[1];// change rar.FareTypes[0] = "R"; //ar.FareTypes = new string[1];// change //ar.FareTypes[0] = "BD"; //ar.ProductClasses = new string[1]; //ar.ProductClasses[0] = "BD"; PaxPriceType[] rpriceTypes = new PaxPriceType[ar.PaxCount]; for (int i = 0; i < ar.PaxCount; i++) { rpriceTypes[i] = new PaxPriceType(); rpriceTypes[i].PaxType = "ADT"; rpriceTypes[i].PaxDiscountCode = String.Empty; } rar.PaxPriceTypes = rpriceTypes; rar.IncludeTaxesAndFees = false; rar.FareRuleFilter = FareRuleFilter.Default; rar.LoyaltyFilter = LoyaltyFilter.MonetaryOnly; tar.AvailabilityRequests = new AvailabilityRequest[2]; tar.AvailabilityRequests[0] = ar; tar.AvailabilityRequests[1] = rar; } else { tar.AvailabilityRequests = new AvailabilityRequest[1]; tar.AvailabilityRequests[0] = ar; } tar.LoyaltyFilter = LoyaltyFilter.MonetaryOnly; gar.TripAvailabilityRequest = tar; gar.Signature = signature; gar.ContractVersion = 0; GetAvailabilityResponse gare = bookingManager.GetAvailability(gar); //if (waytype == "1") GetPrice(signature, gare, noofPassenger); //if (waytype == "2") // GetPriceReturn(signature, gare,page); }
public GetAvailabilityResponse GetAvailability(String dstation, String astation, DateTime startdate, DateTime endate, int numadt, int numchd, String currency, String faretype, String sourceorg, int nightstay) { GetAvailabilityRequest gar = new GetAvailabilityRequest(); gar.Signature = signature; gar.TripAvailabilityRequest = new TripAvailabilityRequest(); PaxPriceType[] priceTypes; // 9- not passed in method but i have to do this step because it is a required parameter priceTypes = new PaxPriceType[2];// this is to define type of passenger travelling, must be adt and chd-also in sell request for (int j = 0; j < priceTypes.Length; j++) { priceTypes[j] = new PaxPriceType(); if (j < 1) { priceTypes[j].PaxType = "ADT"; } else { priceTypes[j].PaxType = "CHD"; } } if (nightstay == 0) { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[1];// this is per the quick start guide for 1 way trip only, if 2 way, i need to put in array } else { gar.TripAvailabilityRequest.AvailabilityRequests = new AvailabilityRequest[2]; } for (int i = 0; i < gar.TripAvailabilityRequest.AvailabilityRequests.Length; i++) { BookingManager.AvailabilityRequest ar = new AvailabilityRequest(); if (sourceorg.Length > 0)// if this value is passed in then ar.SourceOrganization (parameter) will be the next line { ar.SourceOrganization = sourceorg; //1 } gar.TripAvailabilityRequest.AvailabilityRequests[i] = ar; ar.PaxCount = (short)(numadt + numchd); //2 ar.CurrencyCode = currency;//7 ar.PaxPriceTypes = priceTypes; ar.AvailabilityType = AvailabilityType.Default;// if i do not put anything, it is defaulted as Availability Type can be a enum list ar.AvailabilityFilter = AvailabilityFilter.Default;// if i do not put if (i == 0)//check if it is a one way trip or return trip { ar.DepartureStation = dstation; ar.ArrivalStation = astation; ar.BeginDate = startdate; ar.EndDate = endate; } else { ar.DepartureStation = astation; ar.ArrivalStation = dstation; ar.BeginDate = endate; ar.EndDate = endate; } ar.FlightType = FlightType.All; ar.Dow = DOW.Daily; ar.MaximumConnectingFlights = 5;//if direct, then default the value to 0; ar.AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable; ar.IncludeTaxesAndFees = true; ar.SSRCollectionsMode = SSRCollectionsMode.Leg;//return the SSR available by segment ar.FareClassControl = FareClassControl.CompressByProductClass; ar.InboundOutbound = InboundOutbound.None; ar.FareTypes = new String[1];//either RE-regular fare or JP for japan wholesaler ar.FareTypes[0] = faretype;// put this back to the parameter in Get Availability Response } GetAvailabilityResponse garesponse = clientapi.GetAvailability(gar); if (garesponse.GetTripAvailabilityResponse.Schedules.Length > 0 && garesponse.GetTripAvailabilityResponse.Schedules[0].Length > 0)//schedules refer to the journey markets returned from the search { Console.WriteLine("{0} journey by availability", garesponse.GetTripAvailabilityResponse.Schedules[0][0].Journeys.Length);// return response is always in a 2 dimensional array } else { Console.WriteLine("No journey found"); garesponse = null; } return garesponse; }