Exemplo n.º 1
0
        ////******** Navitaire API Integration ************************

        public static string Login()
        {
            ISessionManager sessionManager = new SessionManagerClient();
            LogonRequest    logonRequest   = new LogonRequest();
            string          username       = "******"; //ConfigurationManager.AppSettings["userid_fapi"].ToString();
            string          password       = "******"; //ConfigurationManager.AppSettings["password_fapi"].ToString();
            string          domain         = "WWW";

            logonRequest.logonRequestData            = new LogonRequestData();
            logonRequest.logonRequestData.DomainCode = domain;
            logonRequest.logonRequestData.AgentName  = username;
            logonRequest.logonRequestData.Password   = password;
            LogonResponse logonResponse = sessionManager.Logon(logonRequest);
            string        signature     = "";

            if (logonResponse != null && logonResponse.Signature != null && logonResponse.Signature != string.Empty)
            {
                signature = logonResponse.Signature;
            }
            else
            {
                //Response.Write("Agent Authentication Failed.");
                //ScriptManager.RegisterStartupScript(Page, GetType(), "ab", "alert('Agent Authentication Failed.');", true);
            }
            return(signature);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Itenta obtener la configuración del usuario (cliente) y pregunta por uno nuevo si no encuentra configuración previa
        /// </summary>
        /// <returns>True si el usuario se configuro exitosamente</returns>
        public bool ConfigureCustomer()
        {
            bool existCustomerConfiguration = CheckCustomerConfiguration();

            if (!existCustomerConfiguration)
            {
                try
                {
                    SessionManagerClient sessionManagerClient = new SessionManagerClient(SessionManagerClient.CreateDefaultBinding(), new EndpointAddress(UtnEmall.Client.SmartClientLayer.Connection.ServerUri + "SessionManager"));
                    sessionManagerClient.ValidateCustomer("", "");

                    CustomerConfigurationForm customerConfigurationForm = new CustomerConfigurationForm();
                    customerConfigurationForm.Owner = mainMenu;
                    customerConfigurationForm.ShowDialog();
                }
                catch (TargetInvocationException invocationException)
                {
                    Debug.WriteLine(invocationException.Message);
                    HelpForm helpForm = new HelpForm(global::PresentationLayer.GeneralResources.ServerNotFoundHelp);
                    helpForm.ShowDialog();
                    return(false);
                }
                catch (CommunicationException communicationError)
                {
                    Debug.WriteLine(communicationError.Message);
                    HelpForm helpForm = new HelpForm(global::PresentationLayer.GeneralResources.ServerNotFoundHelp);
                    helpForm.ShowDialog();
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Éste metodo valida si el cliente existe y retorna la entidad representando el cliente
        /// </summary>
        /// <param name="userName">
        /// Nombre de usuario del cliente
        /// </param>
        /// <param name="password">
        /// Clave del cliente
        /// </param>
        /// <returns>La entidad del Cliente</returns>
        public static CustomerEntity ValidateAndGetCustomer(string userName, string password)
        {
            if (String.IsNullOrEmpty(userName) || String.IsNullOrEmpty(password))
            {
                throw new ArgumentException(
                          global::PresentationLayer.GeneralResources.UserNameEmpty);
            }

            Collection <CustomerEntity> customers = new Collection <CustomerEntity>();

            SessionManagerClient sessionManagerClient = new SessionManagerClient(SessionManagerClient.CreateDefaultBinding(), new EndpointAddress(UtnEmall.Client.SmartClientLayer.Connection.ServerUri + "SessionManager"));
            string session = sessionManagerClient.ValidateCustomer(userName, Utilities.CalculateHashString(password));

            CustomerClient customerClient = new CustomerClient(CustomerClient.CreateDefaultBinding(), new EndpointAddress(UtnEmall.Client.SmartClientLayer.Connection.ServerUri + "Customer"));

            customers = customerClient.GetCustomerWhereEqual(CustomerEntity.DBUserName, userName, true, session);

            if (customers.Count == 0)
            {
                throw new UtnEmallBusinessLogicException(
                          global::PresentationLayer.GeneralResources.LoginFailedUserIncorrect);
            }

            string         passwordHash = Utilities.CalculateHashString(password);
            CustomerEntity customer     = customers[0];

            if (String.Compare(customer.Password, passwordHash, StringComparison.Ordinal) != 0)
            {
                throw new UtnEmallBusinessLogicException(
                          global::PresentationLayer.GeneralResources.LoginFailedPasswordIncorrect);
            }

            return(customer);
        }
Exemplo n.º 4
0
        public static void Logout(string signature)
        {
            ISessionManager sessionManager = new SessionManagerClient();
            LogoutRequest   logoutRequest  = new LogoutRequest();

            logoutRequest.Signature = signature;
            sessionManager.Logout(logoutRequest);
        }
Exemplo n.º 5
0
        public async Task <IActionResult> SellJourneys([FromBody] string[] journeyFareSellKeys)
        {
            var signature      = string.Empty;
            var sessionManager = new SessionManagerClient();
            var logonResponse  = await sessionManager.LogonAsync(new LogonRequest
            {
                logonRequestData = new LogonRequestData
                {
                    DomainCode = "DEF",
                    AgentName  = "sculthorpe070884",
                    Password   = "******"
                }
            });

            var client      = new BookingManagerClient();
            var sellKeyList = new SellKeyList[journeyFareSellKeys.Length];

            for (var i = 0; i < journeyFareSellKeys.Length; i++)
            {
                var split = journeyFareSellKeys[i].Split('|');
                sellKeyList[i] = new SellKeyList
                {
                    JourneySellKey = split[0],
                    FareSellKey    = split[1]
                };
            }

            var sellRequestData = new SellRequestData
            {
                SellBy = SellBy.JourneyBySellKey,
                SellJourneyByKeyRequest = new SellJourneyByKeyRequest
                {
                    SellJourneyByKeyRequestData = new SellJourneyByKeyRequestData
                    {
                        ActionStatusCode = "NN",
                        CurrencyCode     = "SAR",
                        JourneySellKeys  = sellKeyList,
                        PaxCount         = 1,
                        PaxPriceType     = new PaxPriceType[] { new PaxPriceType {
                                                                    PaxCount = 1, PaxType = "ADT"
                                                                } }
                    }
                }
            };
            var response = await client.SellAsync(348, false, "3.4.13", logonResponse.Signature, sellRequestData);

            return(new OkObjectResult(response));
        }
Exemplo n.º 6
0
        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));
            }
        }
Exemplo n.º 7
0
 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);
     });
 }