public override IMovilwayApiResponse PerformKinacuOperation(IMovilwayApiRequest requestObject, SaleInterface kinacuWS, String sessionID)
        {
            // GetBlockedAgenciesByInactivityReportRequest
            GetBlockedAgenciesByInactivityResponseBody response = new GetBlockedAgenciesByInactivityResponseBody()
            {
                ResponseCode    = 99,
                ResponseMessage = "",
                TransactionID   = 0
            };

            //GetBlockedAgenciesByInactivityReportResponse
            GetBlockedAgenciesByInactivityRequestBody request = requestObject as GetBlockedAgenciesByInactivityRequestBody;

            try
            {
                logger.InfoHigh(" GetBlockedAgenciesByInactivityReport data  DateMin=" + request.DateMin + ",DateMax =  " + request.DateMax + ", Agent =  " + request.Agent);

                //Ariel 2021-Ma-09 Comentado no devolmemos detalle

                //response.Details = Movilway.API.Service.ExtendedApi.Provider.Kinacu.Utils.GetBlockedAgenciesByInactivity(request);
                response.ResponseCode    = 0;
                response.ResponseMessage = "OK";
            }
            catch (Exception ex)
            {
                logger.ErrorLow(() => TagValue.New().Exception(ex).Message("Error GetBlockedAgenciesByInactivityReport provider"));
                response.ResponseCode    = 99;
                response.ResponseMessage = "Error inesperado.";
                response.TransactionID   = 0;
            }


            return(response);
        }
Пример #2
0
        public override IMovilwayApiResponse PerformKinacuOperation(IMovilwayApiRequest requestObject, KinacuWebService.SaleInterface kinacuWS, string sessionID)
        {
            GetTransactionsReportResponseBody response = new GetTransactionsReportResponseBody();

            try
            {
                if (sessionID.Equals("0"))
                {
                    return(new GetTransactionsReportResponseBody()
                    {
                        ResponseCode = 90,
                        ResponseMessage = "error session",
                        TransactionID = 0,
                    });
                }

                GetTransactionsReportRequestBody request = requestObject as GetTransactionsReportRequestBody;

                if (request.InitialDate > request.FinalDate)
                {
                    return(new GetTransactionsReportResponseBody()
                    {
                        ResponseCode = 90,
                        ResponseMessage = "RANGO DE FECHAS INVALIDO",
                        TransactionID = 0
                    });
                }

                logger.InfoLow(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[GetTransactionsReport]").Tag("[SEND-DATA] GetTransactionsReportParameters ").Value(request));

                switch (request.DeviceType)
                {
                case 3:
                    //Ariel 2021-Ma-09 Comentado
                    // response.reportData = Utils.TransactionsForReportH2H(request.Agent, request.InitialDate, request.FinalDate, request.TransactionType, request.Top);
                    break;

                default:
                    //Ariel 2021-Ma-09 Comentado
                    // response.reportData = Utils.TransactionsForReport(request.Agent, request.InitialDate, request.FinalDate, request.TransactionType, request.Top);
                    break;
                }

                response.ResponseMessage = "OK"; //string.Concat("OK ",COUNTER);
                response.ResponseCode    = 0;
                // COUNTER = ((COUNTER + 1) % 2);
                logger.InfoLow(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[GetTransactionsReport]").Tag(" GetTransactionsReportResult ").Value(response.reportData.Count));
            }
            catch (Exception ex)
            {
                response.ResponseCode    = 500;
                response.ResponseMessage = _GenericError;
                response.TransactionID   = 0;

                string mensaje = String.Concat("[API] " + base.LOG_PREFIX + "[UpdateAgentProvider] ", ". Exception: ", ex.Message, ". ", ex.StackTrace);
                logger.ErrorLow(mensaje);
            }

            return(response);
        }
Пример #3
0
        public IMovilwayApiResponse PerformOperation(IMovilwayApiRequest requestObject)
        {
            var request = requestObject as ValidateMoviPinRequestBody;

            Logger.BeginLow(() => TagValue.New().Tag("Request").Value(request));

            var response = new ValidateMoviPinResponseBody
            {
                ResponseCode    = 0,
                ResponseMessage = "Sus Movipins han sido validados correctamente",
                MoviPins        = new MoviPins()
            };

            if (request != null)
            {
                foreach (var details in request.MoviPins.Select(movipin => Utils.GetMoviPinDetails(movipin.Number)).Where(details => details != null))
                {
                    response.MoviPins.Add(details);
                }
            }

            Logger.CheckPointLow(() => TagValue.New().Tag("Response").Value(response));

            return(response);
        }
Пример #4
0
        /// <summary>
        /// Obtiene la información de una cuenta corriente
        /// </summary>
        /// <param name="agenciaId">ID de la agencia</param>
        /// <returns>Un objeto <c>InfoCuentaCorriente</c> que contiene la información de la cuenta corriente</returns>
        public InfoCuentaCorriente GetInfoCuentaCorriente(int agenciaId)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            InfoCuentaCorriente ret = null;

            try
            {
                ret = Dwh <InfoCuentaCorriente> .ExecuteSingle(
                    this.db,
                    Queries.Kinacu.GetInfoCuentaCorriente,
                    new Dictionary <string, object>()
                {
                    { "@id", agenciaId }
                },
                    this.databaseTransaction);
            }
            catch (Exception ex)
            {
                Logger.ExceptionLow(() => TagValue.New()
                                    .MethodName(methodName)
                                    .Exception(ex));
            }

            if (ret.Id == 0)
            {
                ret = null;
            }

            return(ret);
        }
Пример #5
0
        /// <summary>
        /// Actualiza la secuencia para el parametro dado
        /// </summary>
        /// <param name="idsecuencia">Tipo de secuencia a actualizar</param>
        /// <returns>ID de la secuencia generada</returns>
        public int UpdateSecuencia(string idsecuencia)
        {
            int    ret        = 0;
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            try
            {
                ret = Convert.ToInt32(Dwh <int> .ExecuteScalar(
                                          this.db,
                                          Queries.Kinacu.UpdateSequence,
                                          new Dictionary <string, object>()
                {
                    { "@paramValue", idsecuencia }
                },
                                          this.databaseTransaction));
            }
            catch (Exception ex)
            {
                Logger.ExceptionLow(() => TagValue.New()
                                    .MethodName(methodName)
                                    .Exception(ex));
            }

            return(ret);
        }
Пример #6
0
        /// <summary>
        /// Obtiene la información del depósito pendiente de BD
        /// </summary>
        /// <param name="id">ID del depósito</param>
        /// <returns>Un objeto <c>InfoDeposito</c> que contiene la información del depósito</returns>
        public InfoDeposito GetInfoDepositoPendiente(int id)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            InfoDeposito ret = null;

            try
            {
                ret = Dwh <InfoDeposito> .ExecuteSingle(
                    this.db,
                    Queries.Kinacu.GetInfoDeposito,
                    new Dictionary <string, object>()
                {
                    { "@id", id },
                    { "@estado", "PE" }
                },
                    this.databaseTransaction);
            }
            catch (Exception ex)
            {
                Logger.ExceptionLow(() => TagValue.New()
                                    .MethodName(methodName)
                                    .Exception(ex));
            }

            if (ret.Id == 0)
            {
                ret = null;
            }

            return(ret);
        }
Пример #7
0
        public override IMovilwayApiResponse PerformKinacuOperation(IMovilwayApiRequest requestObject, SaleInterface kinacuWS, String sessionID)
        {
            try
            {
                GetUsersAgentRequestBody request = requestObject as GetUsersAgentRequestBody;


                GetUsersAgentResponseBody response = null;

                logger.InfoLow(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[GetUsersAgentProvider] Start").Tag("User").Value(request.AuthenticationData.Username).Tag("Agent").Value(request.Agent));


                response = new GetUsersAgentResponseBody()
                {
                    ResponseCode    = 0,
                    ResponseMessage = "Exito",
                    TransactionID   = 0,
                    Users           = Utils.GetUsers(request.Agent, request.AuthenticationData.Username, request.DeviceType, request.Onlychildren, request.ShowAccess)
                };

                logger.InfoLow(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[GetUsersAgentProvider] End").Tag("User").Value(request.AuthenticationData.Username).Tag("Agent").Value(request.Agent));
                return(response);
            }
            catch (Exception e)
            {
                //logger.ExceptionHigh(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[GetUsersAgentProvider] Exception").Tag("User").Value(request.AuthenticationData.Username).Tag("Agent").Value(request.Agent));
                logger.ExceptionHigh(() => TagValue.New().Exception(e).MethodName("GetUsersAgentProvider").Tag("User").Value(requestObject.AuthenticationData.Username));


                throw e;
            }
        }
Пример #8
0
        /// <summary>
        /// Obtiene la información de un giro dado a partir de su ExternalId (ID Multipay 472)
        /// </summary>
        /// <param name="sessionId">Session ID que será escrito en los logs</param>
        /// <param name="id">ID Multipay 472 del giro</param>
        /// <param name="returnCode">Codigo de error en caso de que algo falle (-1 = OK, >-1 = Error)</param>
        /// <param name="connection">Objeto de conexión a base de datos</param>
        /// <returns>Un objeto <c>DwhModel.Giro</c> que contiene la información del giro</returns>
        private DwhModel.GiroUltimaTransaccion GetInfoGiroPorExternalId(
            string sessionId,
            long id,
            string pin,
            out ErrorMessagesMnemonics returnCode,
            SqlConnection connection = null)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            returnCode = ErrorMessagesMnemonics.None;
            DwhModel.GiroUltimaTransaccion ret = null;

            try
            {
                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Ejecutando query ..."));

                Dictionary <string, object> queryParams = new Dictionary <string, object>()
                {
                    { "@IdGiro", id.ToString() }
                };

                if (connection == null)
                {
                    using (connection = Movilway.API.Utils.Database.GetCash472DbConnection())
                    {
                        connection.Open();
                        ret = Movilway.API.Utils.Dwh <DwhModel.GiroUltimaTransaccion> .ExecuteSingle(
                            connection,
                            Queries.Cash.GetInfoGiroPorExternalId,
                            queryParams,
                            null);
                    }
                }
                else
                {
                    ret = Movilway.API.Utils.Dwh <DwhModel.GiroUltimaTransaccion> .ExecuteSingle(
                        connection,
                        Queries.Cash.GetInfoGiroPorExternalId,
                        queryParams,
                        null);
                }

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Query ejecutado"));
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error ejecutando query")
                                                 .Exception(ex));
                returnCode = ErrorMessagesMnemonics.InternalDatabaseError;
                ret        = new DwhModel.GiroUltimaTransaccion();
            }

            return(ret);
        }
Пример #9
0
        /// <summary>
        /// Escribe en log los datos de la peticion
        /// </summary>
        /// <param name="request">Base request object</param>
        protected void LogRequest(object request)
        {
            try
            {
                try
                {
                    this.ProviderLogger.BeginLow(() => TagValue.New().Tag("Client IP").Value(!string.IsNullOrEmpty(HttpContext.Current.Request.UserHostAddress) ? HttpContext.Current.Request.UserHostAddress : "NULL"));
                }
                catch (Exception)
                {
                    this.ProviderLogger.BeginLow(() => TagValue.New().Tag("Client IP").Value("NULL"));
                }

                this.ProviderLogger.BeginLow(() => TagValue.New().Tag("Request").Value(request));

                int timeOutSeconds = int.Parse(ConfigurationManager.AppSettings["DefaultTimeout"]);
                var to             = timeOutSeconds * 1000;

                this.ProviderLogger.BeginLow(() => TagValue.New().Tag("TimeOutProvider").Value(to));
            }
            catch (Exception e)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New().Message("Exception trying to log the Request").Exception(e));
            }
        }
        /// <summary>
        /// Realiza el proceso de notificación al oficial de cumplimento para un cliente en listas restrictivas
        /// </summary>
        /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario e información de la notificación</param>
        /// <returns>Respuesta de la notificación</returns>
        public NotificacionOficialCumplimientoResponse NotificacionOficialCumplimiento(NotificacionOficialCumplimientoRequest request)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            this.LogRequest(request);

            NotificacionOficialCumplimientoResponse response = new NotificacionOficialCumplimientoResponse();
            string sessionId = this.GetSessionId(request, response, out this.errorMessage);

            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.LogResponse(response);
                return(response);
            }

            if (!request.IsValidRequest())
            {
                this.SetResponseErrorCode(response, ErrorMessagesMnemonics.InvalidRequiredFields);
                this.LogResponse(response);
                return(response);
            }

            DwhModel.Cliente infoCliente = this.GetInfoCliente(sessionId, request.TipoIdentificacion, request.NumeroIdentificacion.Trim(), out this.errorMessage);
            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.SetResponseErrorCode(response, this.errorMessage);
                this.LogResponse(response);
                return(response);
            }

            try
            {
                string mail    = ConfigurationManager.AppSettings["MailOficialCumplimiento"].ToString();
                string subject = string.Format("Giros - {0} en Listas Restrictivas", request.TipoCliente.ToString());
                string body    = string.Concat(
                    "<div style='font-family: Tahoma, \"Arial\", Tahoma, sans-serif;'>",
                    "El usuario con Tipo Documento : ",
                    request.TipoIdentificacion.ToString(),
                    " Número: ",
                    request.NumeroIdentificacion,
                    request.TipoCliente == TipoCliente.Emisor ? " está emitiendo un giro" : " tiene giros para ser pagados",
                    " y se encontró una coincidencia en listas restrictivas (ONU, OFAC).",
                    "<br/><br/><p style='color:Gray'>PD: por favor no responda este mensaje</p></div>");

                Utils.Mailer.SendMail(mail, subject, body);
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error enviando correo")
                                                 .Exception(ex));
                return(response);
            }

            response.ResponseCode = 0;
            this.LogResponse(response);
            return(response);
        }
Пример #11
0
        /// <summary>
        /// Obtiene la información de un cliente dado
        /// </summary>
        /// <param name="sessionId">Session ID que será escrito en los logs</param>
        /// <param name="tipoIdentificacion">Tipo de identificación del cliente</param>
        /// <param name="numeroIdentificacion">Número de identificación del cliente</param>
        /// <param name="returnCode">Codigo de error en caso de que algo falle (-1 = OK, >-1 = Error)</param>
        /// <param name="connection">Objeto de conexión a base de datos</param>
        /// <returns>Un objeto <c>DwhModel.Cliente</c> que contiene la información del cliente</returns>
        private List <Cash472.DwhModel.Ciudad> GetListCities(string sessionId, out ErrorMessagesMnemonics returnCode, SqlConnection connection = null)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            returnCode = ErrorMessagesMnemonics.None;
            List <Cash472.DwhModel.Ciudad> listCities = new List <DwhModel.Ciudad>();

            try
            {
                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Ejecutando query ..."));

                Dictionary <string, object> queryParams = null;
                if (connection == null)
                {
                    using (connection = Utils.Database.GetCash472DbConnection())
                    {
                        connection.Open();
                        listCities = Utils.Dwh <Cash472.DwhModel.Ciudad> .ExecuteReader(
                            connection,
                            Queries.Cash.ListCities,
                            queryParams,
                            null);
                    }
                }
                else
                {
                    listCities = Utils.Dwh <Cash472.DwhModel.Ciudad> .ExecuteReader(
                        connection,
                        Queries.Cash.ListCities,
                        queryParams,
                        null);
                }

                if (listCities == null || listCities.Count == 0)
                {
                    returnCode = ErrorMessagesMnemonics.ErrorGetCities;
                    listCities = null;
                }

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Query ejecutado"));
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error ejecutando query")
                                                 .Exception(ex));
                returnCode = ErrorMessagesMnemonics.InternalDatabaseError;
                listCities = null;
            }

            return(listCities);
        }
Пример #12
0
        /// <summary>
        /// Paso 1 emisión de un nuevo giro => Constitución del giro
        /// </summary>
        /// <param name="request">Objeto que contiene la información del giro</param>
        /// <param name="sessionId">ID de sesión para poner en los mensajes de log</param>
        /// <param name="exc">Excepción generada al llamar el servicio</param>
        /// <returns>Respuesta de la constitución del giro</returns>
        private MultiPay472.RespuestaValidacionConstitucionGiro EmitirPaso1Cash472(EmitirRequest request, string sessionId, out Exception exc)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            exc = null;

            MultiPay472.RespuestaValidacionConstitucionGiro resp = null;
            MultiPay472.Service1SoapClient client = this.GetSoapClient();
            string endpointName = "ValidacionConstitucionGiro";

            try
            {
                MultiPay472.ValidacionConstitucionGiro peticion = new MultiPay472.ValidacionConstitucionGiro();
                peticion.NitRed            = this.multipayNitRed;
                peticion.CodigoTerminal    = this.multipayTerminal;
                peticion.CodigoTransaccion = this.GenerarCodigoTransaccion(sessionId);

                peticion.CodigoPuntoVenta             = request.Pdv;
                peticion.ValorRecibido                = request.ValorRecibido;
                peticion.IncluyeFlete                 = request.IncluyeFlete;
                peticion.CodigoDaneCiudadPuntoVenta   = request.CiudadPdv;
                peticion.CodigoDaneCiudadPagoSugerido = request.CiudadDestino;

                peticion.Originador = new MultiPay472.Originador();
                this.EstablecerValoresCliente472(request.Emisor, peticion.Originador, null);

                peticion.Destinatario = new MultiPay472.Destinatario();
                this.EstablecerValoresCliente472(request.Receptor, null, peticion.Destinatario);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Llamando servicio \"" + endpointName + "\" ..."));

                resp = client.ValidacionConstitucionGiro(peticion, this.multipayUsuario);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Respuesta servicio \"" + endpointName + "\"")
                                            .Tag("Respuesta").Value(resp != null ? resp.CodigoRespuesta : "NULL"));

                if (resp == null || resp.CodigoRespuesta != CashProvider.CodigoRespuestaExitoso)
                {
                    this.errorMessage = resp == null ? ErrorMessagesMnemonics.WebServiceDoesNotRespond : ErrorMessagesMnemonics.Cash472WsError;
                }
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error llamando servicio \"" + endpointName + "\"")
                                                 .Exception(ex));
                this.errorMessage = ErrorMessagesMnemonics.WebServiceException;
                exc = ex;
            }

            return(resp);
        }
Пример #13
0
        /// <summary>
        /// Notifica a Notiway que un mensaje fue leido
        /// </summary>
        /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario y el Id del mensaje</param>
        public void NotiwayNewsReadNotification(NotiwayNewsReadNotificationRequest request)
        {
            String _methodName = String.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            LogRequest(request);

            var sessionId = GetSessionId(request, out errorMessage);

            if (errorMessage != ErrorMessagesMnemonics.None)
            {
                return;
            }

            var countryId  = Convert.ToInt32(ConfigurationManager.AppSettings["CountryId"]);
            var platformId = Convert.ToInt32(String.IsNullOrEmpty(request.Platform) ? ConfigurationManager.AppSettings["DefaultPlatform"] : request.Platform);

            if (countryId == 14 && platformId == 1)
            {
                countryId  = 1;
                platformId = 4;
            }

            try
            {
                using (var db = new Movilway.API.Data.Notiway.NotiwayEntities())
                {
                    ProviderLogger.InfoLow(() => TagValue.New()
                                           .MethodName(_methodName)
                                           .Message("[" + sessionId + "] " + "Actualizando registro ...")
                                           );

                    db.Database.ExecuteSqlCommand(
                        QUERY_AUDIT_READ,
                        new SqlParameter("@CountryP", countryId),
                        new SqlParameter("@PlatformP", platformId),
                        new SqlParameter("@LoginP", request.AuthenticationData.Username),
                        new SqlParameter("@ScheduleP", request.ScheduleId),
                        new SqlParameter("@DeviceTypeP", request.DeviceType)
                        );
                }

                ProviderLogger.InfoLow(() => TagValue.New()
                                       .MethodName(_methodName)
                                       .Message("[" + sessionId + "] " + "Hecho")
                                       );
            }
            catch (Exception e)
            {
                ProviderLogger.ExceptionLow(() => TagValue.New()
                                            .MethodName(_methodName)
                                            .Message("[AUDITORIA] [" + sessionId + "] " + "Error actualizando auditoria de mensaje")
                                            .Exception(e)
                                            );
            }
        }
        /// <summary>
        /// Actualiza la informacion de contacto de un agente en el sistema
        /// </summary>
        /// <param name="requestObject"></param>
        /// <param name="kinacuWS"></param>
        /// <param name="sessionID"></param>
        /// <returns></returns>
        /// <returns>Retorna el tipo IMovilwayApiResponse con el respectivo codigo de error y mensaje</returns>
        public override IMovilwayApiResponse PerformKinacuOperation(IMovilwayApiRequest requestObject, KinacuWebService.SaleInterface kinacuWS, string sessionID)
        {
            UpdateContactInfoAgentResponseBody response = new UpdateContactInfoAgentResponseBody();

            try
            {
                if (sessionID.Equals("0"))
                {
                    return new UpdateContactInfoAgentResponseBody()
                           {
                               ResponseCode    = 90,
                               ResponseMessage = "error session",
                               TransactionID   = 0
                           }
                }
                ;

                UpdateContactInfoAgentRequestBody request = requestObject as UpdateContactInfoAgentRequestBody;

                logger.InfoLow(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[UpdateContactInfoAgentProvider]").Tag("[RCV-DATA] UpdateContactInfoAgentProviderParameters ").Value(request));

                var result = Utils.ChangeBranchContactInfo(request.AgeId.ToString(), request.Email, request.Phone);

                if (result)
                {
                    response = new UpdateContactInfoAgentResponseBody
                    {
                        ResponseCode    = 0,
                        ResponseMessage = "Exito",
                        TransactionID   = new Random().Next(10000000, 99999999)
                    }
                }
                ;
                else
                {
                    response = new UpdateContactInfoAgentResponseBody
                    {
                        ResponseCode    = 99,
                        ResponseMessage = _GenericError
                    }
                };
            }
            catch (Exception ex)
            {
                //cambiar error general erro inesperado
                response.ResponseCode    = 500;
                response.ResponseMessage = _GenericError;
                response.TransactionID   = 0;
                string mensaje = String.Concat("[API] " + base.LOG_PREFIX + "[UpdateContactInfoAgentProvider] ", ". Exception: ", ex.Message, ". ", ex.StackTrace);
                logger.ErrorLow(mensaje);
            }

            logger.InfoLow(() => TagValue.New().Message("[API] " + base.LOG_PREFIX).Tag("[UpdateContactInfoAgentProviderResult]").Value(response));
            return(response);
        }
Пример #15
0
 /// <summary>
 /// Escribe en log los datos de la respuesta
 /// </summary>
 /// <param name="response">Base request object</param>
 protected void LogResponse(object response)
 {
     try
     {
         this.ProviderLogger.CheckPointLow(() => TagValue.New().Tag("Response").Value(response));
     }
     catch (Exception e)
     {
         this.ProviderLogger.ExceptionLow(() => TagValue.New().Message("Exception trying to log the Response").Exception(e));
     }
 }
Пример #16
0
        /// <summary>
        /// Obtiene la respuesta en base a la petición realizada por Http o Https
        /// </summary>
        /// <param name="request">Petición a realizar</param>
        /// <returns>Devuelve el contenido de la página</returns>
        public static string GetResponse(Request request)
        {
            string methodName  = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);
            string pageContent = string.Empty;

            HttpWebRequest baseRequest = HttpUtils.BuildHttpRequest(request);

            try
            {
                HttpWebResponse httpWebResponse = (HttpWebResponse)baseRequest.GetResponse();
                Stream          responseStream  = httpWebResponse.GetResponseStream();

                if (!request.AutomaticDecompression)
                {
                    if (httpWebResponse.ContentEncoding.ToLower().Contains("gzip"))
                    {
                        responseStream = new GZipStream(responseStream, CompressionMode.Decompress);
                    }
                    else if (httpWebResponse.ContentEncoding.ToLower().Contains("deflate"))
                    {
                        responseStream = new DeflateStream(responseStream, CompressionMode.Decompress);
                    }
                }

                StreamReader streamReader = new StreamReader(responseStream, Encoding.Default);
                pageContent = streamReader.ReadToEnd();
                streamReader.Close();
                responseStream.Close();
                httpWebResponse.Close();

                if (request.HandleAutomaticRedirect && (
                        httpWebResponse.StatusCode == HttpStatusCode.Redirect ||
                        httpWebResponse.StatusCode == HttpStatusCode.TemporaryRedirect ||
                        (httpWebResponse.StatusCode == HttpStatusCode.Found &&
                         httpWebResponse.Headers.AllKeys.Contains("Location"))))
                {
                    request.Url = httpWebResponse.Headers["Location"].Contains(request.Host) ? httpWebResponse.Headers["Location"]
                        : ((httpWebResponse.Headers["Location"].ToLower().StartsWith("http") || httpWebResponse.Headers["Location"].ToLower().StartsWith("https")) ? httpWebResponse.Headers["Location"] : request.Host + (string.IsNullOrEmpty(request.BasePath) ? string.Empty : request.BasePath) + httpWebResponse.Headers["Location"]);
                    request.Method      = HttpUtils.Get;
                    request.ContentType = String.Empty;

                    //request.Host = "www1.sucursalelectronica.com";
                    pageContent = GetResponse(request);
                }
            }
            catch (Exception ex)
            {
                Logger.ExceptionLow(() => TagValue.New()
                                    .MethodName(methodName)
                                    .Exception(ex));
            }

            return(pageContent);
        }
Пример #17
0
        /// <summary>
        /// Paso llamado método TopUp con el producto de CashIn, para que el protocolo realice el llamado
        /// de constitución y emisión en el WS de MultiPay 472
        /// </summary>
        /// <param name="request">Objeto que contiene la información del giro</param>
        /// <param name="idGiro">ID del giro creado en base de datos MW</param>
        /// <param name="sessionId">ID de sesión para poner en los mensajes de log</param>
        /// <param name="exc">Excepción generada al llamar el método del API</param>
        /// <returns>Respuesta del TopUp</returns>
        private DataContract.TopUpResponseBody EmitirPaso2(EmitirRequest request, int idGiro, string sessionId, out Exception exc)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            exc = null;

            DataContract.TopUpResponseBody resp = null;
            string endpointName = "TopUp";

            try
            {
                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Llamando método \"" + endpointName + "\" ..."));

                resp = new ServiceExecutionDelegator <DataContract.TopUpResponseBody, DataContract.TopUpRequestBody>().ResolveRequest(
                    new DataContract.TopUpRequestBody()
                {
                    AuthenticationData = new AuthenticationData()
                    {
                        Username = request.AuthenticationData.Username,
                        Password = request.AuthenticationData.Password
                    },
                    DeviceType = request.DeviceType,
                    Platform   = request.Platform,
                    WalletType = DataContract.WalletType.Stock,
                    ExternalTransactionReference = sessionId,
                    Amount     = request.ValorRecibido,
                    TerminalID = request.Pdv,
                    Recipient  = idGiro.ToString(),
                    MNO        = this.multipayTopUpMno
                },
                    ApiTargetPlatform.Kinacu,
                    ApiServiceName.TopUp);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Respuesta método \"" + endpointName + "\"")
                                            .Tag("ResponseCode").Value(resp != null && resp.ResponseCode.HasValue ? resp.ResponseCode.Value.ToString() : "NULL")
                                            .Tag("ResponseMessage").Value(resp != null && !string.IsNullOrEmpty(resp.ResponseMessage) ? resp.ResponseMessage : "vacío"));
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error llamando método \"" + endpointName + "\"")
                                                 .Exception(ex));
                this.errorMessage = ErrorMessagesMnemonics.ApiMethodException;
                exc = ex;
            }

            return(resp);
        }
Пример #18
0
        /// <summary>
        /// Inserta un movimiento de auditoria en las tablas de Kinacu
        /// </summary>
        /// <param name="idUsuario">ID usuario</param>
        /// <param name="idUsuarioSup">ID usuario superior</param>
        /// <param name="comentario">Comentario auditoria</param>
        /// <param name="codigo">Código que relaciona la auditoria con el registro</param>
        /// <param name="dominio">Tipo de auditoria</param>
        /// <param name="subdominio">Subtipo de auditoria</param>
        /// <param name="code">Codigo error de retorno</param>
        /// <returns>ID del registro de auditoria creado</returns>
        public int InsertarMovimientoAuditoria(int idUsuario, int?idUsuarioSup, string comentario, int codigo, string dominio, string subdominio)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            int ret = 0;

            int idMovimiento = this.UpdateSecuencia(Core.cons.SecuenciaAuditoria);

            if (idMovimiento == 0)
            {
                Logger.ExceptionLow(() => TagValue.New()
                                    .MethodName(methodName));
                return(ret);
            }

            Logger.CheckPointHigh(() => TagValue.New().MethodName(methodName).Message("INSERT INTO KcrTransaccion Start"));

            try
            {
                object usrIdSuperior = DBNull.Value;
                if (idUsuarioSup.HasValue)
                {
                    usrIdSuperior = idUsuarioSup.Value;
                }

                Dwh <int> .ExecuteNonQuery(
                    this.db,
                    Queries.Kinacu.InsertAuditoria,
                    new Dictionary <string, object>()
                {
                    { "@traId", idMovimiento },
                    { "@usrId", idUsuario },
                    { "@traComentario", comentario },
                    { "@usrIdSuperior", usrIdSuperior },
                    { "@iCodigo", codigo },
                    { "@traDominio", dominio },
                    { "@traSubdominio", subdominio }
                },
                    this.databaseTransaction);

                ret = idMovimiento;
            }
            catch (Exception ex)
            {
                Logger.ExceptionLow(() => TagValue.New()
                                    .MethodName(methodName)
                                    .Exception(ex));
            }

            Logger.CheckPointHigh(() => TagValue.New().MethodName(methodName).Message("INSERT INTO KcrTransaccion End"));
            return(ret);
        }
Пример #19
0
        /// <summary>
        /// Retorna una lista de IPNetwork con local host y la ip del servidor
        /// </summary>
        /// <param name="FILE_IPS_PATH"></param>
        /// <returns></returns>
        private static HashSet <IPNetWork> FactoryMethod(string FILE_IPS_PATH)
        {
            HashSet <IPNetWork> result = new HashSet <IPNetWork>();

            try
            {
                IPNetWork network = IPNetWork.Parse("127.0.0.1");
                result.Add(network);

                IPHostEntry ipEntry = Dns.GetHostEntry(Dns.GetHostName());
                if (ipEntry.AddressList.Length > 0)
                {
                    IPAddress IP = ipEntry.AddressList[ipEntry.AddressList.Length - 1];
                    result.Add(IPNetWork.Parse(IP.ToString()));
                }



                // Read the file and display it line by line.
                using (System.IO.StreamReader file = new System.IO.StreamReader(FILE_IPS_PATH, System.Text.Encoding.Default))
                {
                    string line = null;
                    while ((line = file.ReadLine()) != null)
                    {
                        try
                        {
                            line = line.Trim().Replace(" ", "");
                            if (line[0] != '!' && line[0] != '-')
                            {
                                network = IPNetWork.Parse(line);
                                result.Add(network);
                            }
                        }
                        catch (ArgumentException ex)
                        {
                            logger.InfoHigh(() => TagValue.New().Tag("[ERROR IP ARCHIVO H2H]").Value(line));
                        }
                        catch (Exception ex)
                        {
                            logger.InfoHigh(() => TagValue.New().Tag("[ERROR INESPERADO IP DE ARCHIVO]").Value(line));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                //MANEJO DE ERROR SI NO SE PUDO CARGAR LA LISTA DE IPS
                logger.InfoHigh(() => TagValue.New().Tag("ERROR INESPERADO CARGANDO IP'S H2H").Exception(ex));
            }

            return(result);
        }
Пример #20
0
        /// <summary>
        /// Obtiene la información del depósito pendiente de BD
        /// </summary>
        /// <param name="id">ID del depósito</param>
        /// <returns>Un objeto <c>InfoDeposito</c> que contiene la información del depósito</returns>
        public InfoAgente GetInfoAgente(int?id, string login = null)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            InfoAgente ret = null;

            try
            {
                string query      = string.Empty;
                object idParam    = DBNull.Value;
                object loginParam = DBNull.Value;

                if (id != null && id.HasValue)
                {
                    query   = Queries.Kinacu.GetInfoAgenteById;
                    idParam = id.Value;
                }
                else
                {
                    query = Queries.Kinacu.GetInfoAgenteByLogin;
                }

                if (!string.IsNullOrEmpty(login))
                {
                    loginParam = login;
                }

                ret = Dwh <InfoAgente> .ExecuteSingle(
                    this.db,
                    query,
                    new Dictionary <string, object>()
                {
                    { "@id", idParam },
                    { "@login", loginParam }
                },
                    this.databaseTransaction);
            }
            catch (Exception ex)
            {
                Logger.ExceptionLow(() => TagValue.New()
                                    .MethodName(methodName)
                                    .Exception(ex));
            }

            if (ret.BranchId == 0)
            {
                ret = null;
            }

            return(ret);
        }
Пример #21
0
        /// <summary>
        /// Retorna los Hijos de un agente dado el ID del agente padre
        /// Precondición:
        /// - Se han validado los permisos en el sistema
        /// Postcondición:
        /// Retorna la lista de BasicAgentInfo con los agentes Hijos
        /// </summary>
        /// <param name="requestObject"></param>
        /// <param name="kinacuWS"></param>
        /// <param name="sessionID"></param>
        /// <returns>retorna IMovilwayApiResponse con los datos del agente</returns>
        public override IMovilwayApiResponse PerformKinacuOperation(IMovilwayApiRequest requestObject, SaleInterface kinacuWS, String sessionID)
        {
            GetChildListResponseBody response = new GetChildListResponseBody();

            if (sessionID.Equals("0"))
            {
                response.ResponseCode    = 90;
                response.ResponseMessage = "error session";
                response.TransactionID   = 0;


                return(response);
            }


            try
            {
                GetChildListRequestByIdBody request = requestObject as GetChildListRequestByIdBody;

                /*
                 * dynamic data = new { AgeId = request.AgeId, Login = request.AuthenticationData.Username };
                 * if (!Utils.IsValidEditAgent(data))
                 * {
                 *  response.ResponseCode = 90;
                 *  response.ResponseMessage = "ERROR DE PERMISOS -  NO TIENE PERMISOS PARA ACCEDER A LOS HIJOS DE ESTE AGENTE";
                 *  response.TransactionID = 0;
                 *  return response;
                 * }*/


                logger.InfoLow(() => TagValue.New().Message("[KIN] " + base.LOG_PREFIX + "[GetChildListProviderById]").Tag("[SEND-DATA] getChildRetailersParameters ").Value(request));

                bool extendedValues           = request.ExtendedValues ?? false;
                List <BasicAgentInfo> results = Utils.GetChildsById(request.AgeId, extendedValues);

                response.ChildList.AddRange(results);

                response.ResponseCode    = 0;
                response.ResponseMessage = "OK";
                response.TransactionID   = 0;
            }
            catch (Exception ex)
            {
                response.ResponseCode    = 500;
                response.ResponseMessage = "ERROR INESPERADO " + ex.Message;
                response.TransactionID   = 0;
            }

            return(response);
        }
Пример #22
0
        public ActualizarTransaccionResponse ActualizarTransaccion(ActualizarTransaccionRequest actualizarTransaccion)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            this.ProviderLogger.InfoLow(() => TagValue.New().MethodName(methodName)
                                        .Message("Started"));

            ActualizarTransaccionResponse response = new ActualizarTransaccionResponse();

            string sessionId = this.GetSessionId(actualizarTransaccion, response, out this.errorMessage);

            this.ProviderLogger.InfoLow(() => TagValue.New().MethodName(methodName)
                                        .Message("[" + sessionId + "] " + "Actualizando transaccion. " +
                                                 String.Concat(
                                                     "CodigoTransaccionExterno: ", actualizarTransaccion.CodigoTransaccionExterno,
                                                     ", CodigoTransaccion: ", actualizarTransaccion.CodigoTransaccion,
                                                     ", Estado: ", actualizarTransaccion.Estado,
                                                     ", Mensaje: ", actualizarTransaccion.Mensaje
                                                     )
                                                 ));
            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.LogResponse(response);
                return(response);
            }


            try
            {
                int r = new TransactionDB().UpdateTransaction(actualizarTransaccion);



                return(new ActualizarTransaccionResponse {
                    ResponseMessage = "Ok", ResponseCode = 0, TransactionID = r
                });
            }
            catch (Exception e)
            {
                this.ProviderLogger.ExceptionHigh(() => TagValue.New().MethodName(methodName).Message("[" + sessionId + "]")
                                                  .Exception(e));
                return(new ActualizarTransaccionResponse {
                    ResponseMessage = e.Message
                });
            }
            finally {
                this.ProviderLogger.InfoLow(() => TagValue.New().MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Fin Actualización"));
            }
        }
Пример #23
0
        /// <summary>
        /// Validacion privada
        /// </summary>
        /// <param name="request"></param>
        private void SecureValidation(IMovilwayApiRequest request)
        {
            switch (request.DeviceType)
            {
            case cons.ACCESS_H2H:
                if (!NetWorkSecurity.IpIsWithinRangeH2H(HttpContext.Current.Request.UserHostAddress))
                {
                    string message = String.Concat("[LA IP NO ESTA REGISTRADA EN EL RANGO PERMITIDO H2H (", HttpContext.Current.Request.UserHostAddress, ")]");
                    logger.ErrorHigh(() => TagValue.New().Message("[ERROR DE PERMISOS H2H]").Message(message).Tag("[PARA ACCESO]").Value(request.AuthenticationData));
                    throw new Exception(message);
                }

                break;
            }
        }
Пример #24
0
        private void LogRequest(object request)
        {
            try
            {
                ProviderLogger.BeginLow(() => TagValue.New().Tag("Client IP").Value(HttpContext.Current.Request.UserHostAddress));
                ProviderLogger.BeginLow(() => TagValue.New().Tag("Request").Value(request));

                int timeOutSeconds = int.Parse(ConfigurationManager.AppSettings["DefaultTimeout"]);
                var to             = timeOutSeconds * 1000;

                ProviderLogger.BeginLow(() => TagValue.New().Tag("TimeOutProvider").Value(to));
            }
            catch (Exception e)
            {
                ProviderLogger.ExceptionLow(() => TagValue.New().Message("Exception trying to log the Request").Exception(e));
            }
        }
Пример #25
0
        /// <summary>
        /// Paso 2 emisión de un nuevo giro => Confirmación del giro
        /// </summary>
        /// <param name="request">Objeto que contiene la información del giro</param>
        /// <param name="sessionId">ID de sesión para poner en los mensajes de log</param>
        /// <param name="constitution">Mensaje de respuesta de la constitución del giro</param>
        /// <param name="exc">Excepción generada al llamar el servicio</param>
        /// <returns>Respuesta de la constitución del giro</returns>
        private MultiPay472.RespuestaEmisionGiro EmitirPaso2Cash472(EmitirRequest request, string sessionId, MultiPay472.RespuestaValidacionConstitucionGiro constitution, out Exception exc)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            exc = null;

            MultiPay472.RespuestaEmisionGiro resp   = null;
            MultiPay472.Service1SoapClient   client = this.GetSoapClient();
            string endpointName = "EmisionGiro";

            try
            {
                MultiPay472.EmisionGiro peticion = new MultiPay472.EmisionGiro();
                peticion.Token             = constitution.Token;
                peticion.CodigoTransaccion = this.GenerarCodigoTransaccion(sessionId);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Llamando servicio \"" + endpointName + "\" ..."));

                resp = client.EmisionGiro(peticion, this.multipayUsuario);

                this.ProviderLogger.InfoLow(() => TagValue.New()
                                            .MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Respuesta servicio \"" + endpointName + "\"")
                                            .Tag("Respuesta").Value(resp != null ? resp.CodigoRespuesta : "NULL"));

                if (resp == null || resp.CodigoRespuesta != CashProvider.CodigoRespuestaExitoso)
                {
                    this.errorMessage = resp == null ? ErrorMessagesMnemonics.WebServiceDoesNotRespond : ErrorMessagesMnemonics.Cash472WsError;
                }
            }
            catch (Exception ex)
            {
                this.ProviderLogger.ExceptionLow(() => TagValue.New()
                                                 .MethodName(methodName)
                                                 .Message("[" + sessionId + "] " + "Error llamando servicio \"" + endpointName + "\"")
                                                 .Exception(ex));
                this.errorMessage = ErrorMessagesMnemonics.WebServiceException;
                exc = ex;
            }

            return(resp);
        }
Пример #26
0
        /// <summary>
        /// Escribe en base de datos la auditoria para cada mensaje enviado
        /// </summary>
        /// <param name="SessionId">ID de la sesion que genero los mensajes (solo para log)</param>
        /// <param name="CountryId">ID del pais al que pertenece el usuario</param>
        /// <param name="PlatformId">ID de la plataforma al que pertenece el usuario</param>
        /// <param name="Login">Login del usuario</param>
        /// <param name="DeviceType">ID del tipo de acceso</param>
        /// <param name="MarkAsReaded">Incrementar el contador de lecturas para el mensaje automaticamente</param>
        /// <param name="messages">Lista de mensajes enviados que se escribiran en los datos de auditoria</param>
        private void writeAudit(String SessionId, int CountryId, int PlatformId, String Login, int DeviceType, bool MarkAsReaded, List <NotiwayNews> messages)
        {
            String _methodName = String.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            if (messages != null && messages.Count > 0)
            {
                ProviderLogger.InfoLow(() => TagValue.New()
                                       .MethodName(_methodName)
                                       .Message("[AUDITORIA] [" + SessionId + "] " + "Total mensajes a ser actualizados en auditoria: " + messages.Count)
                                       );

                try
                {
                    using (var db = new Movilway.API.Data.Notiway.NotiwayEntities())
                    {
                        db.Database.ExecuteSqlCommand(
                            QUERY_AUDIT_BULK,
                            new SqlParameter("@CountryP", CountryId),
                            new SqlParameter("@PlatformP", PlatformId),
                            new SqlParameter("@LoginP", Login),
                            new SqlParameter("@ScheduleListP", String.Join(",", messages.Select(s => s.ScheduleId).ToList())),
                            new SqlParameter("@DeviceTypeP", DeviceType),
                            new SqlParameter("@MarkAsReadP", MarkAsReaded ? "1" : "0")
                            );
                    }

                    ProviderLogger.InfoLow(() => TagValue.New()
                                           .MethodName(_methodName)
                                           .Message("[AUDITORIA] [" + SessionId + "] " + "Hecho")
                                           );
                }
                catch (Exception e)
                {
                    ProviderLogger.ExceptionLow(() => TagValue.New()
                                                .MethodName(_methodName)
                                                .Message("[AUDITORIA] [" + SessionId + "] " + "Error actualizando auditoria de mensajes")
                                                .Exception(e)
                                                );
                }
            }
        }
Пример #27
0
        /// <summary>
        /// Consume el API SOS IT
        /// </summary>
        protected bool ConsumeService(XmlDocument ParamXMLData, int ParamWorkorderid, int ParamDetailId, Request Request, string TechnicianKey, string ParamUrlApi, string ParamTimeOutApi, out string PageContent)
        {
            bool   ISOK           = true;
            string _methodFulName = String.Format("{0}.{1}", System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName, System.Reflection.MethodBase.GetCurrentMethod().Name);

            _logger.CheckPointHigh(() => TagValue.New()
                                   .MethodName(_methodFulName)
                                   .Message("Start")
                                   );

            Request = getRequest(ParamXMLData, ParamWorkorderid, ParamDetailId, Request, TechnicianKey, ParamUrlApi);

            PageContent = getResponse(Request, ParamTimeOutApi);

            _logger.CheckPointHigh(() => TagValue.New()
                                   .MethodName(_methodFulName)
                                   .Message("End")

                                   );
            return(ISOK);
        }
Пример #28
0
        public CrearTransaccionResponse CrearTransaccion(CrearTransaccionRequest crearTransactionRequest)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            this.ProviderLogger.InfoLow(() => TagValue.New().MethodName(methodName)
                                        .Message("Started"));

            CrearTransaccionResponse response = new CrearTransaccionResponse();

            string sessionId = this.GetSessionId(crearTransactionRequest, response, out this.errorMessage);

            this.ProviderLogger.InfoLow(() => TagValue.New().MethodName(methodName)
                                        .Message("[" + sessionId + "] " + "Creando Transaccion"));
            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.LogResponse(response);
                return(response);
            }

            try
            {
                int id = new TransactionDB().GetTransaction(crearTransactionRequest);
                this.ProviderLogger.InfoLow(() => TagValue.New().MethodName(methodName)
                                            .Message("[" + sessionId + "] " + "Creada ").Tag("id").Value(id));
                return(new CrearTransaccionResponse {
                    TransactionID = id, ResponseMessage = "Ok", ResponseCode = 0
                });
            }
            catch (Exception e)
            {
                this.ProviderLogger.ExceptionHigh(() => TagValue.New().MethodName(methodName).Exception(e));
                return(new CrearTransaccionResponse {
                    TransactionID = 0, ResponseMessage = e.Message, ResponseCode = 99
                });
            }
            finally {
                this.ProviderLogger.InfoLow(() => TagValue.New().MethodName(methodName)
                                            .Message("[" + sessionId + "] End"));
            }
        }
Пример #29
0
        /// <summary>
        /// Obtiene una imagen a partir de una petición Web
        /// </summary>
        /// <param name="request">Petición a realizar</param>
        /// <returns>Devuelve la imagen en su formato de bytes, listo para ser escrito en un archivo</returns>
        public static byte[] GetImage(Request request)
        {
            string         methodName  = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);
            HttpWebRequest baseRequest = HttpUtils.BuildHttpRequest(request);

            byte[] ret = null;

            try
            {
                using (HttpWebResponse response = (HttpWebResponse)baseRequest.GetResponse())
                {
                    using (BinaryReader imageBinary = new BinaryReader(response.GetResponseStream()))
                    {
                        using (MemoryStream imageMemoryStream = new MemoryStream())
                        {
                            byte[] aux = imageBinary.ReadBytes(1024);
                            while (aux.Length > 0)
                            {
                                imageMemoryStream.Write(aux, 0, aux.Length);
                                aux = imageBinary.ReadBytes(1024);
                            }

                            ret = new byte[(int)imageMemoryStream.Length];
                            imageMemoryStream.Position = 0;
                            imageMemoryStream.Read(ret, 0, ret.Length);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.ExceptionLow(() => TagValue.New()
                                    .MethodName(methodName)
                                    .Exception(ex));
            }

            return(ret);
        }
Пример #30
0
        public override IMovilwayApiResponse PerformKinacuOperation(IMovilwayApiRequest requestObject, SaleInterface kinacuWS, String sessionID)
        {
            try
            {
                ChangePasswodRequestBody request = requestObject as ChangePasswodRequestBody;


                ChangePasswordResponseBody response = null;

                logger.InfoLow(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[ChangePasswordProvider] Start").Tag("User").Value(request.AuthenticationData.Username).Tag("UserId").Value(request.UserId).Tag("AccessTypeId").Value(request.AccessTypeId));


                response = new ChangePasswordResponseBody()
                {
                    ResponseCode    = 0,
                    ResponseMessage = "Exito",
                    TransactionID   = 0,
                    Result          = Utils.ChangePassword(request.AuthenticationData.Username, request.DeviceType, request.UserId, request.AccessTypeId, request.NewPassword)
                };

                if (response.Result == false)
                {
                    response.ResponseMessage = "Contraseña no actualizada";
                    response.ResponseCode    = 99;
                }
                logger.InfoLow(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[ChangePasswordProvider] End").Tag("User").Value(request.AuthenticationData.Username).Tag("UserId").Value(request.UserId).Tag("AccessTypeId").Value(request.AccessTypeId));
                return(response);
            }
            catch (Exception e)
            {
                //logger.ExceptionHigh(() => TagValue.New().Message("[API] " + base.LOG_PREFIX + "[GetUsersAgentProvider] Exception").Tag("User").Value(request.AuthenticationData.Username).Tag("Agent").Value(request.Agent));
                logger.ExceptionHigh(() => TagValue.New().Exception(e).MethodName("ChangePassword").Tag("User").Value(requestObject.AuthenticationData.Username));


                throw e;
            }
        }