public async Task <IActionResult> Test() { try { var result = new List <object>(); var sessionManager = new SessionManagerClient(); var logonResponse = await sessionManager.LogonAsync(new LogonRequest { //logonRequestData = new LogonRequestData //{ // DomainCode = "WWW", // AgentName = "awdta1", // Password = "******" //} logonRequestData = new LogonRequestData { DomainCode = "DEF", AgentName = "sculthorpe070884", Password = "******" } }); result.Add(logonResponse); IBookingManager bookingManager = new BookingManagerClient(); // { var bookingResponse = await bookingManager.GetBookingAsync(new GetBookingRequest { Signature = logonResponse.Signature, GetBookingReqData = new GetBookingRequestData { GetByRecordLocator = new GetByRecordLocator { RecordLocator = "V4HSFS"/// "EWRT45" } } }); var availRequest = new AvailabilityRequest { DepartureStation = "JED", ArrivalStation = "RUH", BeginDate = new DateTime(2017, 10, 01), // BeginTime = new Time(), EndDate = new DateTime(2017, 10, 01), // EndTime = new Time(), PaxPriceTypes = new[] { new PaxPriceType { PaxType = "ADT", PaxCount = 1 } }, InboundOutbound = InboundOutbound.Both, FareClassControl = FareClassControl.CompressByProductClass, AvailabilityFilter = AvailabilityFilter.ExcludeUnavailable, AvailabilityType = AvailabilityType.Default, FareRuleFilter = FareRuleFilter.Default, PaxCount = 1, CurrencyCode = "SAR", FareTypes = new[] { "R" }, FlightType = FlightType.All, Dow = DOW.Daily, IncludeAllotments = true, IncludeTaxesAndFees = true, SSRCollectionsMode = SSRCollectionsMode.All, LoyaltyFilter = Navitaire.NewSkies.WebServices.DataContracts.Common.Enumerations.LoyaltyFilter.PointsAndMonetary, JourneySortKeys = new[] { JourneySortKey.EarliestDeparture, JourneySortKey.LowestFare }, PaxResidentCountry = "SA" }; var availResponse = await bookingManager.GetAvailabilityAsync(new GetAvailabilityRequest { Signature = logonResponse.Signature, TripAvailabilityRequest = new TripAvailabilityRequest { LoyaltyFilter = Navitaire.NewSkies.WebServices.DataContracts.Common.Enumerations.LoyaltyFilter.PointsAndMonetary, AvailabilityRequests = new[] { availRequest } } }); dto.GetAvailabilityResponse dtoAvailResponse = _mapper.Map <GetAvailabilityResponse, dto.GetAvailabilityResponse>(availResponse); result.Add(dtoAvailResponse); var GetTripAvailabilityWithSSRAsyncResp = await bookingManager.GetTripAvailabilityWithSSRAsync(new GetTripAvailabilityWithSSRRequest { TripAvailabilityWithSSRRequest = new TripAvailabilityWithSSRRequest { AvailabilityRequests = new AvailabilityRequest[] { availRequest }, LoyaltyFilter = Navitaire.NewSkies.WebServices.DataContracts.Common.Enumerations.LoyaltyFilter.PointsAndMonetary, IncludeSSRList = new string[] { "INFT" } }, Signature = logonResponse.Signature }); result.Add(GetTripAvailabilityWithSSRAsyncResp); /* * var legKey = new System.Collections.Generic.List<LegKey>(); * foreach (var segment in availResponse.GetTripAvailabilityResponse.Schedules[0][0].Journeys[0].Segments) * { * legKey.Add(new LegKey { ArrivalStation = segment.ArrivalStation, DepartureStation = segment.DepartureStation, CarrierCode = segment.FlightDesignator.CarrierCode.Trim(), DepartureDate = segment.STD, FlightNumber = segment.FlightDesignator.FlightNumber.Trim(), OpSuffix = segment.FlightDesignator.OpSuffix.Trim() }); * } * GetSSRAvailabilityForBookingRequest getSSRAvailabilityForBookingRequest = new GetSSRAvailabilityForBookingRequest(); * SSRAvailabilityForBookingRequest SSRAvailRequest = new SSRAvailabilityForBookingRequest(); * SSRAvailRequest.SegmentKeyList = legKey.ToArray(); * // "20080303 1L1501 SLCLAX"; * // "20171001 0P 101 JEDRUH"; * // "20171001 0P 101 JEDRUH" * SSRAvailRequest.CurrencyCode = "SAR"; * SSRAvailRequest.PassengerNumberList = new short[] { 0 }; * SSRAvailRequest.InventoryControlled = true; * SSRAvailRequest.NonInventoryControlled = true; * SSRAvailRequest.SeatDependent = true; * SSRAvailRequest.NonSeatDependent = true; * getSSRAvailabilityForBookingRequest.SSRAvailabilityForBookingRequest = SSRAvailRequest; * getSSRAvailabilityForBookingRequest.Signature = logonResponse.Signature; * var getSSRAvailabilityForBookingresult = await bookingManager.GetSSRAvailabilityForBookingAsync(getSSRAvailabilityForBookingRequest); * result[2] = getSSRAvailabilityForBookingRequest; */ var legKeyList = new System.Collections.Generic.List <string>(); foreach (var segment in availResponse.GetTripAvailabilityResponse.Schedules[0][0].Journeys[0].Segments) { // "20080303 1L1501 SLCLAX"; var legKey = string.Format("{0}{1}{2}{3}{4}{5}", segment.STD.ToString("yyyyMMdd"), segment.FlightDesignator.CarrierCode.PadLeft(3, ' '), segment.FlightDesignator.FlightNumber.PadLeft(4, ' '), segment.FlightDesignator.OpSuffix, segment.DepartureStation, segment.ArrivalStation); legKeyList.Add(legKey); } GetSSRAvailabilityRequest getSSRAvailabilityRequest = new GetSSRAvailabilityRequest(); SSRAvailabilityRequest SSRAvailRequest = new SSRAvailabilityRequest(); SSRAvailRequest.InventoryLegKeys = legKeyList.ToArray(); SSRAvailRequest.SSRCollectionsMode = SSRCollectionsMode.All; getSSRAvailabilityRequest.Signature = logonResponse.Signature; getSSRAvailabilityRequest.SSRAvailabilityRequest = SSRAvailRequest; var getSSRAvailabilityresult = await bookingManager.GetSSRAvailabilityAsync(getSSRAvailabilityRequest); result.Add(getSSRAvailabilityresult); // } IUtilitiesManager utilities = new UtilitiesManagerClient(); var stationsResponse = await utilities.GetStationListAsync(new GetStationListRequest { Signature = logonResponse.Signature, EnableExceptionStackTrace = true, GetStationListRequestData = new GetStationListRequestData { CultureCode = "en-US" } }); result.Add(stationsResponse); IAgentManager agentManager = new AgentManagerClient(); var rolesResponse = await agentManager.GetRoleListAsync(new GetRoleListRequest { Signature = logonResponse.Signature }); result.Add(rolesResponse); var logoutResponse = await sessionManager.LogoutAsync(new LogoutRequest { Signature = logonResponse.Signature }); result.Add(logoutResponse); return(new OkObjectResult(result)); } catch (Exception e) { return(new BadRequestObjectResult(e)); } }
internal static void AddNewskiesServices(this IServiceCollection services) { ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; services.AddSingleton <IBookingManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new BookingManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.BookingManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.BookingManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); services.AddSingleton <IAgentManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new AgentManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.AgentManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.AgentManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); services.AddSingleton <IPersonManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new PersonManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.PersonManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.PersonManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); services.AddSingleton <IUtilitiesManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new UtilitiesManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.UtilitiesManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.UtilitiesManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); services.AddSingleton <IOperationManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new OperationManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.OperationManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.OperationManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); services.AddSingleton <IQueueManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new QueueManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.QueueManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.QueueManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); services.AddSingleton <IVoucherManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new VoucherManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.VoucherManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.VoucherManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); services.AddSingleton <IAccountManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new AccountManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.AccountManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.AccountManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); services.AddSingleton <ISessionManager>(service => { var options = service.GetService(typeof(IOptions <AppSettings>)) as IOptions <AppSettings>; var client = new SessionManagerClient(); if (!string.IsNullOrEmpty(options.Value.NewskiesSettings.ServiceEndpoints.SessionManagerUrl)) { client.Endpoint.Address = new EndpointAddress(options.Value.NewskiesSettings.ServiceEndpoints.SessionManagerUrl); var timeout = options.Value.NewskiesSettings.ServiceTimeoutSeconds; client.Endpoint.Binding.OpenTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.CloseTimeout = TimeSpan.FromSeconds(timeout); client.Endpoint.Binding.SendTimeout = TimeSpan.FromSeconds(timeout); } return(client); }); }