示例#1
0
        private static bool IsAuthorizedUser(string authToken)
        {
            var token = ConfigAccess.GetValueInAppSettings(SecurityKeys.Token);

            // In this method we can handle our database logic here...
            return(authToken.Equals(token));
        }
示例#2
0
        private string ObtieneLinkPago(int pIntIdWeb, int pIntIdPedido, int pIntIdCotSRV)
        {
            EncriptaCadena objNMEncriptaCadena = new EncriptaCadena();

            try
            {
                string strURLPago = "";
                if (pIntIdWeb == Webs_Cid.ID_WEB_NM_PERUTRIP)
                {
                    strURLPago = ConfigAccess.GetValueInAppSettings("URL_PAGO_SERVICIO_ONLINE_PERUTRIP");
                }
                else if (pIntIdWeb == Webs_Cid.DM_WEB_ID)
                {
                    strURLPago = ConfigAccess.GetValueInAppSettings("URL_PAGO_SERVICIO_ONLINE_DM");
                }
                else
                {
                    strURLPago = ConfigAccess.GetValueInAppSettings("URL_PAGO_SERVICIO_ONLINE");
                }

                string strIdEncrypt = objNMEncriptaCadena.DES_Encrypt(pIntIdPedido + ";" + pIntIdCotSRV, objNMEncriptaCadena.GetKEY(EncriptaCadena.TIPO_KEY.KEY_ENCRIPTA_NRO_PEDIDO_PAGO_ONLINE));

                return(strURLPago + "?id=" + strIdEncrypt);
            }
            catch (Exception ex)
            {
                return("Error");
            }
            finally
            {
                objNMEncriptaCadena = null;
            }
        }
示例#3
0
 private void SendToSalesforce(AgenciaPnr agenciaPnr, string token, string crmServer)
 {
     try
     {
         var agenciaPnrSf = ToSalesforceEntity(agenciaPnr);
         var responsePnr  = RestBase.ExecuteByKeyWithServer(crmServer, SalesforceKeys.PnrMethod, Method.POST, agenciaPnrSf, true, token);
         if (responsePnr.StatusCode.Equals(HttpStatusCode.OK))
         {
             dynamic jsonResponse = new JavaScriptSerializer().DeserializeObject(responsePnr.Content);
             try
             {
                 agenciaPnr.CodigoError   = jsonResponse[OutParameter.SF_CodigoError];
                 agenciaPnr.MensajeError  = jsonResponse[OutParameter.SF_MensajeError];
                 agenciaPnr.IdOportunidad = jsonResponse[OutParameter.SF_IdOportunidad];
                 agenciaPnr.LastMethod    = ConfigAccess.GetValueInAppSettings(SalesforceKeys.PnrMethod);
             }
             catch
             {
             }
         }
     }
     catch
     {
     }
 }
示例#4
0
        public static Operation GetToken()
        {
            try
            {
                var operation = new Operation();

                var serverName = ConfigAccess.GetValueInAppSettings(SalesforceKeys.AuthServer);
                var methodName = ConfigAccess.GetValueInAppSettings(SalesforceKeys.AuthMethod);
                var methodType = Method.POST;

                if (!int.TryParse(ConfigAccess.GetValueInAppSettings(SecurityKeys.AuthTimeoutKey), out int authTimeout))
                {
                    authTimeout = 0;
                }
                var client = new RestClient(serverName)
                {
                    Timeout = authTimeout
                };
                ServicePointManager.Expect100Continue      = true;
                ServicePointManager.DefaultConnectionLimit = 9999;
                ServicePointManager.SecurityProtocol       = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
                var request              = new RestRequest(methodName, methodType);
                var sf_authgranttype     = ConfigAccess.GetValueInAppSettings("AUTH_GRANT_TYPE");
                var sf_authclientid      = ConfigAccess.GetValueInAppSettings("AUTH_CLIENT_ID");
                var sf_auth_clientsecret = ConfigAccess.GetValueInAppSettings("AUTH_CLIENT_SECRET");
                var sf_authusername      = ConfigAccess.GetValueInAppSettings("AUTH_USERNAME");
                var sf_authpassword      = ConfigAccess.GetValueInAppSettings("AUTH_PASSWORD");

                request.AddParameter("grant_type", sf_authgranttype);
                request.AddParameter("client_id", sf_authclientid);
                request.AddParameter("client_secret", sf_auth_clientsecret);
                request.AddParameter("username", sf_authusername);
                request.AddParameter("password", sf_authpassword);

                var response = client.Execute(request);
                if (response.StatusCode != HttpStatusCode.OK && response.ErrorMessage != null)
                {
                    throw new Exception(response.ErrorMessage);
                }

                var content = response.Content;
                JsonManager.LoadText(content);                                               // Obtiene el json de response

                operation[OutParameter.SF_Token]   = JsonManager.GetSetting("access_token"); // Obtiene el Token
                operation[OutParameter.SF_UrlAuth] = JsonManager.GetSetting("instance_url"); // Obtiene el URL de la API de Salesforce

                return(operation);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#5
0
        private void SendToSalesforce(Boleto boleto, string token, string crmServer)
        {
            var boletoSf       = ToSalesforceEntity(boleto);
            var responseBoleto = RestBase.ExecuteByKeyWithServer(crmServer, SalesforceKeys.BoletoMethod, Method.POST, boletoSf, true, token);

            if (responseBoleto.StatusCode.Equals(HttpStatusCode.OK))
            {
                JsonManager.LoadText(responseBoleto.Content);
                boleto.CodigoError  = JsonManager.GetSetting(OutParameter.SF_CodigoError);
                boleto.MensajeError = JsonManager.GetSetting(OutParameter.SF_MensajeError);
                boleto.LastMethod   = ConfigAccess.GetValueInAppSettings(SalesforceKeys.BoletoMethod);
            }
        }
示例#6
0
        public static IRestResponse ExecuteByKeyWithServer(string serverName, string methodNameKey, Method methodType = Method.POST, object body = null, bool isAuth = false, string token = "")
        {
            var methodName = ConfigAccess.GetValueInAppSettings(methodNameKey);

            return(Execute(
                       serverName,
                       methodName,
                       methodType,
                       body,
                       isAuth,
                       token,
                       int.Parse(ConfigAccess.GetValueInAppSettings(SecurityKeys.CrmTimeoutKey))));
        }
示例#7
0
 private void SendToSalesforce(File file, string token, string crmServer)
 {
     try
     {
         var fileSf       = ToSalesforceEntity(file);
         var responseFile = RestBase.ExecuteByKeyWithServer(crmServer, SalesforceKeys.FileMethod, Method.POST, fileSf, true, token);
         if (responseFile.StatusCode.Equals(HttpStatusCode.OK))
         {
             dynamic jsonResponse = new JavaScriptSerializer().DeserializeObject(responseFile.Content);
             file.CodigoError  = jsonResponse[OutParameter.SF_CodigoError];
             file.MensajeError = jsonResponse[OutParameter.SF_MensajeError];
             file.LastMethod   = ConfigAccess.GetValueInAppSettings(SalesforceKeys.FileMethod);
         }
     }
     catch
     {
     }
 }
示例#8
0
        public UnidadNegocioKeys?GetUnidadNegocioKey()
        {
            string unidadNegocioName = Descripcion; // Ejm. "CONDOR TRAVEL"

            if (ConfigAccess.GetValueInAppSettings(UnidadNegocioKeys.CondorTravel.GetKeyValues()).ToUpper().Split(Utils.Auxiliar.ListSeparator).ToList().Contains(unidadNegocioName.ToUpper()))
            {
                return(UnidadNegocioKeys.CondorTravel);
            }
            else if (ConfigAccess.GetValueInAppSettings(UnidadNegocioKeys.DestinosMundiales.GetKeyValues()).ToUpper().Split(Utils.Auxiliar.ListSeparator).ToList().Contains(unidadNegocioName.ToUpper()))
            {
                return(UnidadNegocioKeys.DestinosMundiales);
            }
            else if (ConfigAccess.GetValueInAppSettings(UnidadNegocioKeys.Interagencias.GetKeyValues()).ToUpper().Split(Utils.Auxiliar.ListSeparator).ToList().Contains(unidadNegocioName.ToUpper()))
            {
                return(UnidadNegocioKeys.Interagencias);
            }

            return(null);
        }
示例#9
0
        private LoginResponse GenerateToken()
        {
            var expirationInMinutes = ConfigAccess.GetValueInAppSettings(SecurityKeys.ExpirationInMin);
            var now = DateTime.Now; var limitTime = now.AddMinutes(Convert.ToInt32(expirationInMinutes));

            byte[] time = BitConverter.GetBytes(DateTime.UtcNow.ToBinary());
            byte[] key            = Guid.NewGuid().ToByteArray();
            string tokenGenerated = Convert.ToBase64String(time.Concat(key).ToArray());

            #region TESTING
            tokenGenerated = "ECPG35cP10iLFqUONN9IRK2VLweBriPx"; // ¡SÓLO PRUEBAS!
            #endregion

            var token = new LoginResponse()
            {
                Token = tokenGenerated,
                ExpirationInMinutes = limitTime.ToString(FormatTemplate.LongDate) // Agrega media hora por default
            };

            return(token);
        }
示例#10
0
        // Método de Pago: PE
        private void GenerarPedido_Pago_Efectivo(DatosPedido pedido,
                                                 Models.PedidoRS resultPedido,
                                                 UsuarioLogin DtsUsuarioLogin)
        {
            DateTime datFechaActual     = DateTime.Now;
            var      ddlHoraExpiraCIP   = pedido.TiempoExpiracionCIP ?? 0;
            var      datFechaExpiraPago = datFechaActual.AddHours(ddlHoraExpiraCIP);

            resultPedido.FechaExpiracion = datFechaExpiraPago;

            var intIdFormaPago = Constantes_FileRetail.INT_ID_FORMA_PAGO_PAGOEFECTIVO_EC;

            try
            {
                var strEmailsCliPE = pedido.Email;
                var dblMontoPagar  = pedido.MontoPagar;
                var intIdPedido    = resultPedido.IdPedido;

                var intIdWeb    = pedido.IdWeb;
                var intIdLang   = pedido.IdLang;
                var intIdCotVta = pedido.IdCotVta;

                // Dim paymentRequest As New BEGenRequest
                var paymentRequest = new ws_pagoefectivo.BEGenRequest();

                paymentRequest.IdMoneda       = ConfigAccess.GetValueInAppSettings("PE_MONEDA");
                paymentRequest.Total          = dblMontoPagar.ToString("0.00");
                paymentRequest.MetodosPago    = ConfigAccess.GetValueInAppSettings("PE_MEDIO_PAGO");
                paymentRequest.Codtransaccion = intIdPedido.ToString("");
                paymentRequest.ConceptoPago   = string.Format("{0}: Orden {1}",
                                                              ConfigAccess.GetValueInAppSettings("PE_COMERCIO_CONCEPTO_PAGO"),
                                                              paymentRequest.Codtransaccion);
                paymentRequest.EmailComercio    = strEmailsCliPE;
                paymentRequest.FechaAExpirar    = datFechaExpiraPago.ToString("yyyy-MM-dd");
                paymentRequest.UsuarioNombre    = DtsUsuarioLogin.LoginUsuario;
                paymentRequest.UsuarioApellidos = DtsUsuarioLogin.ApePatUsuario;
                paymentRequest.UsuarioEmail     = DtsUsuarioLogin.EmailUsuario;
                paymentRequest.IdDepartamento   = DtsUsuarioLogin.IdDep;
                paymentRequest.IdOficina        = DtsUsuarioLogin.IdOfi;

                var paymentResponse = (new ws_pagoefectivo.ws_PagoEfectivo()).GenerarCIP(paymentRequest);

                // Reintento de GENERACIÓN DE CIP
                if (paymentResponse == null || paymentResponse.Estado != "1" || paymentResponse.Token == null)
                {
                    paymentResponse = (new ws_pagoefectivo.ws_PagoEfectivo()).GenerarCIP(paymentRequest);
                }

                var strCIP = resultPedido.CodigoCIP = paymentResponse.NumeroCip;

                //  Enviar correo
                var objEnviarCorreo = new EnviarCorreo();
                var strEmailsCli    = pedido.Email;

                if (Enviar_SolicitudPagoServicioPagoEfectivo(
                        intIdWeb ?? 0,
                        intIdLang ?? 0,
                        intIdCotVta,
                        strEmailsCli,
                        null,
                        pedido.NombreClienteCot,
                        pedido.ApellidoClienteCot,
                        null,
                        DtsUsuarioLogin.NomCompletoUsuario,
                        DtsUsuarioLogin.EmailUsuario,
                        short.Parse(pedido.FormaPago),
                        strCIP,
                        string.Empty,
                        intIdPedido,
                        dblMontoPagar,
                        datFechaExpiraPago))
                {
                    resultPedido.CorreoEnviado = true;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }