예제 #1
0
        /// <summary>
        /// Realiza el proceso de generación de factura
        /// </summary>
        /// <param name="request">Objeto que contiene todos los datos de autenticacion del usuario e información del giro</param>
        /// <returns>Factura generada</returns>
        public GenerarFacturaResponse GenerarFactura(GenerarFacturaRequest request)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            this.LogRequest(request);

            GenerarFacturaResponse response = new GenerarFacturaResponse();
            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);
            }

            Movilway.API.Service.ExtendedApi.DataContract.Cash472.Factura infoFactura = this.GetInfoFactura(sessionId, request.Id, request.ExternalId, out this.errorMessage);
            if (this.errorMessage != ErrorMessagesMnemonics.None)
            {
                this.SetResponseErrorCode(response, this.errorMessage);
                this.LogResponse(response);
                return(response);
            }

            response.ResponseCode = 0;
            this.LogResponse(response);

            infoFactura.Pin          = Core.Security.Multipay472TripleDes.Decrypt(this.multipayTripleDesKey, infoFactura.Pin);
            response.ResponseMessage = this.ConstruirFactura(request.TipoPos, infoFactura);
            if (request.IncludeData)
            {
                response.Factura = infoFactura;
            }

            return(response);
        }
예제 #2
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="id">ID interno del giro</param>
        /// <param name="externalId">ID externo 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.Cliente</c> que contiene la información del cliente</returns>
        private Movilway.API.Service.ExtendedApi.DataContract.Cash472.Factura GetInfoFactura(string sessionId, long id, long externalId, out ErrorMessagesMnemonics returnCode, SqlConnection connection = null)
        {
            string methodName = string.Format("{0}", System.Reflection.MethodBase.GetCurrentMethod().Name);

            returnCode = ErrorMessagesMnemonics.None;
            Movilway.API.Service.ExtendedApi.DataContract.Cash472.Factura ret = null;

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

                string query = id != 0 ? Queries.Cash.GetInfoFacturaById : Queries.Cash.GetInfoFacturaByExternalId;
                Dictionary <string, object> queryParams = new Dictionary <string, object>()
                {
                    { "@Id", id != 0 ? id : externalId }
                };

                if (connection == null)
                {
                    using (connection = Utils.Database.GetCash472DbConnection())
                    {
                        connection.Open();
                        ret = Utils.Dwh <Movilway.API.Service.ExtendedApi.DataContract.Cash472.Factura> .ExecuteSingle(
                            connection,
                            query,
                            queryParams,
                            null);
                    }
                }
                else
                {
                    ret = Utils.Dwh <Movilway.API.Service.ExtendedApi.DataContract.Cash472.Factura> .ExecuteSingle(
                        connection,
                        query,
                        queryParams,
                        null);
                }

                if (ret == null || ret.Id == 0)
                {
                    returnCode = ErrorMessagesMnemonics.UnableToFindOrderRecordInLocalDatabase;
                    ret        = 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        = null;
            }

            return(ret);
        }