Ejemplo n.º 1
0
        private ValidacionOperacionResponse CapturaLecturaLuzFinDiaInternal(CapturaLuzRequest capturaLuzRequest)
        {
            String respuestaProxy = "Error al ejecutar el proceso";
            FechaOperacionResponse      fechaOperacionResponse      = new FechaOperacionResponse();
            ValidacionOperacionResponse validacionOperacionResponse = new ValidacionOperacionResponse();

            // Realizar Fin de día con WS Milano
            // -- Inicia Se valida si no está disponible el WS
            try
            {
                respuestaProxy = proxy.CapturaCierre(token.CodeStore, token.CodeEmployee, token.CodeBox, fechaOperacionResponse.FechaOperacion, capturaLuzRequest.ValorLecturaAdicional, capturaLuzRequest.ValorLectura);
                if (respuestaProxy == "100")
                {
                    // Respuesta Web Service Milano OK
                    fechaOperacionResponse = lecturaLuzRepository.CapturaLecturaLuzFinDia(token.CodeStore, token.CodeBox, token.CodeEmployee, capturaLuzRequest);
                    validacionOperacionResponse.CodeNumber      = fechaOperacionResponse.CodeNumber;
                    validacionOperacionResponse.CodeDescription = fechaOperacionResponse.CodeDescription;
                }
                else
                {
                    // Respuesta Web Service Milano ERROR
                    validacionOperacionResponse.CodeDescription = respuestaProxy;
                }
            }
            catch (Exception exeption)
            {
                // El Web Service no está disponible, mando un error por cualquier razón. Se ignora la captura de luz al final del día
                fechaOperacionResponse = lecturaLuzRepository.CapturaLecturaLuzFinDia(token.CodeStore, token.CodeBox, token.CodeEmployee, capturaLuzRequest);
                validacionOperacionResponse.CodeNumber      = fechaOperacionResponse.CodeNumber;
                validacionOperacionResponse.CodeDescription = fechaOperacionResponse.CodeDescription + ". Registro Offline";;
            }
            // -- Termina Se valida si no está disponible el WS
            return(validacionOperacionResponse);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Metodo que ejecuta la sincronización
        /// </summary>
        /// <param name="informacionCajaRequest"></param>
        /// <returns></returns>
        public ResponseBussiness <ValidacionOperacionResponse> EjecutarSincronizacion(InformacionCajaRequest informacionCajaRequest)
        {
            // TODO: Implementación
            ValidacionOperacionResponse validacionOperacionResponse = new ValidacionOperacionResponse();

            validacionOperacionResponse = inicioFinDiaRepository.EjecutarSincronizacion(informacionCajaRequest);
            return(validacionOperacionResponse);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Método para validar si se require Autenticación Offline o no
        /// </summary>
        /// <param name="token"></param>
        /// <returns></returns>
        public InicioDiaResponse InicioDia(TokenDto token)
        {
            InicioDiaResponse           inicioDiaResponse = new InicioDiaResponse();
            ValidacionOperacionResponse operacionResponse = new ValidacionOperacionResponse();
            var parametros = new Dictionary <string, object>();

            parametros.Add("@CodigoTienda", token.CodeStore);
            parametros.Add("@CodigoCaja", token.CodeBox);
            parametros.Add("@CodigoEmpleado", token.CodeEmployee);

            // Obtener la informacion de folio y fecha de operacion
            List <System.Data.SqlClient.SqlParameter> parametrosOutInfo = new List <System.Data.SqlClient.SqlParameter>();

            parametrosOutInfo.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@FechaOperacion", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Date
            });
            parametrosOutInfo.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@Folio", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
            });
            var resultadoInfo  = data.ExecuteProcedure("[dbo].[sp_vanti_Obtener_Informacion_LoginOffline]", parametros, parametrosOutInfo);
            var fechaOperacion = Convert.ToDateTime(resultadoInfo["@FechaOperacion"]);
            var folio          = Convert.ToInt32(resultadoInfo["@Folio"]);

            var parameters = new Dictionary <string, object>();

            parameters.Add("@CodigoTienda", token.CodeStore);
            List <System.Data.SqlClient.SqlParameter> parametersOut = new List <System.Data.SqlClient.SqlParameter>();

            parametersOut.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@InicioDiaPermitido", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Bit
            });
            parametersOut.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@RequiereCapturaLuz", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Bit
            });
            parametersOut.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@RequiereAutenticacionOffline", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Bit
            });
            parametersOut.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@MensajeAsociado", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.NVarChar, Size = 500
            });
            var result = data.ExecuteProcedure("[dbo].[sp_vanti_server_Obtener_Conexion_InicioDia]", parameters, parametersOut);

            inicioDiaResponse.InicioDiaPermitido           = Convert.ToBoolean(result["@InicioDiaPermitido"]);
            inicioDiaResponse.RequiereCapturarLuz          = Convert.ToBoolean(result["@RequiereCapturaLuz"]);
            inicioDiaResponse.RequiereAutenticacionOffline = Convert.ToBoolean(result["@RequiereAutenticacionOffline"]);
            inicioDiaResponse.MensajeAsociado = result["@MensajeAsociado"].ToString();
            inicioDiaResponse.FolioOperacion  = folio;
            inicioDiaResponse.FechaOperacion  = fechaOperacion.ToString("yyyy-MM-dd");
            return(inicioDiaResponse);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public ValidacionOperacionResponse LoginOffline(TokenDto token, AutenticacionOfflineRequest autenticacionOfflineRequest)
        {
            ValidacionOperacionResponse validacionOperacionResponse = new ValidacionOperacionResponse();
            var parametros = new Dictionary <string, object>();

            parametros.Add("@CodigoTienda", token.CodeStore);
            parametros.Add("@CodigoCaja", token.CodeBox);
            parametros.Add("@CodigoEmpleado", token.CodeEmployee);

            // Obtener la informacion de folio y fecha de operacion
            List <System.Data.SqlClient.SqlParameter> parametrosOutInfo = new List <System.Data.SqlClient.SqlParameter>();

            parametrosOutInfo.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@FechaOperacion", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Date
            });
            parametrosOutInfo.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@Folio", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
            });
            var resultadoInfo  = data.ExecuteProcedure("[dbo].[sp_vanti_Obtener_Informacion_LoginOffline]", parametros, parametrosOutInfo);
            var fechaOperacion = Convert.ToDateTime(resultadoInfo["@FechaOperacion"]);
            var folio          = Convert.ToInt32(resultadoInfo["@Folio"]);

            //Obtener cadena del algoritmo
            string cadenaAlgoritmo = this.getCodeAlgorithm(fechaOperacion.ToString("yyyyMMdd"), fechaOperacion.ToString("yyyy-MM-dd"), token.CodeStore, token.CodeBox, folio);

            //Validar cadena generada con el algoritmo vs la clave que nos envian desde cliente
            if (cadenaAlgoritmo == autenticacionOfflineRequest.Clave)
            {
                // Agegar fecha operacion
                parametros.Add("@FechaOperacion", fechaOperacion);
                List <System.Data.SqlClient.SqlParameter> parametrosOut = new List <System.Data.SqlClient.SqlParameter>();
                parametrosOut.Add(new System.Data.SqlClient.SqlParameter()
                {
                    ParameterName = "@CodigoResultado", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
                });
                parametrosOut.Add(new System.Data.SqlClient.SqlParameter()
                {
                    ParameterName = "@MensajeResultado", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.NVarChar, Size = 4000
                });
                var resultado = data.ExecuteProcedure("[dbo].[sp_vanti_LoginOffline_InicioDia]", parametros, parametrosOut);
                validacionOperacionResponse.CodeNumber      = resultado["@CodigoResultado"].ToString();
                validacionOperacionResponse.CodeDescription = resultado["@MensajeResultado"].ToString();
            }
            else
            {
                validacionOperacionResponse.CodeNumber      = "409";
                validacionOperacionResponse.CodeDescription = "No se ha podido iniciar sesion, verifique la clave de acceso";
            }
            return(validacionOperacionResponse);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Genera la lectura z offline
        /// </summary>
        /// <param name="informacionCajaRequest"></param>
        /// <returns></returns>
        public ValidacionOperacionResponse GenerarLecturaZOffline(InformacionCajaRequest informacionCajaRequest)
        {
            ValidacionOperacionResponse operacionResponse = new ValidacionOperacionResponse();
            var parameters = new Dictionary <string, object>();

            using (TransactionScope scope = new TransactionScope())
            {
                foreach (var item in data.GetDataReader("SP_A_Utilizar", parameters))
                {
                    operacionResponse.CodeNumber = item.GetValue(0).ToString();
                    operacionResponse.CodeNumber = item.GetValue(1).ToString();
                }
                scope.Complete();
            }
            return(operacionResponse);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Metodo para actualizar la relacion de caja al registrar el fin de día
        /// </summary>
        /// <param name="token">Token</param>
        /// <param name="relacionCaja">Objeto que contiene la Relación de Caja</param>
        /// <returns></returns>
        public ResponseBussiness <ValidacionOperacionResponse> PersistirRelacionCajaFinDia(TokenDto token, RelacionCaja relacionCaja)
        {
            return(tryCatch.SafeExecutor(() =>
            {
                ValidacionOperacionResponse validacionOperacionResponse = new ValidacionOperacionResponse();
                int idRelacionCaja = -1;
                using (TransactionScope scope = new TransactionScope())
                {
                    // Persistir relacion de caja
                    idRelacionCaja = inicioFinDiaRepository.AgregarRelacionCaja(relacionCaja.CodigoTienda, relacionCaja.TotalConIVA, relacionCaja.TotalSinIVA, relacionCaja.IVA);
                    // Persistir depositos
                    foreach (var deposito in relacionCaja.DepositosAsociados)
                    {
                        inicioFinDiaRepository.AgregarDepositoRelacionCaja(idRelacionCaja, deposito.TotalConIVA,
                                                                           deposito.InformacionAsociadaFormasPago.CodigoFormaPago, deposito.InformacionAsociadaFormasPago.DescripcionFormaPago);
                    }
                    // Persistir grupos
                    foreach (var grupo in relacionCaja.GruposRelacionCaja)
                    {
                        int idGrupo = inicioFinDiaRepository.AgregarGrupoRelacionCaja(idRelacionCaja, grupo.TotalConIVA, grupo.Encabezado);
                        // Persistir secciones
                        foreach (var seccion in grupo.SeccionesRelacionCaja)
                        {
                            int idSeccion = inicioFinDiaRepository.AgregarSeccionRelacionCaja(idGrupo, seccion.TotalConIVA, seccion.Encabezado, seccion.TotalSinIVA, seccion.IVA);
                            foreach (var desglose in seccion.DesgloseRelacionCaja)
                            {
                                inicioFinDiaRepository.AgregarDesgloseSeccionRelacionCaja(idSeccion, desglose.TotalConIVA, desglose.Descripcion);
                            }
                        }
                    }
                    // Registrar Fin de Día exitosamente
                    validacionOperacionResponse = inicioFinDiaRepository.RegistrarFinDia(token);
                    // Terminar la transacción
                    scope.Complete();
                }

                // Imprimir el Reporte de la Relación de Caja
                PrintRelacionCaja printRelacionCaja = new PrintRelacionCaja(token);
                printRelacionCaja.printReporte(idRelacionCaja);

                return validacionOperacionResponse;
            }));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Metodo que genera Lectura Z y Logout Offline
 /// </summary>
 /// <param name="token"></param>
 /// <param name="lecturaCaja"></param>
 /// <returns></returns>
 public ResponseBussiness <ValidacionOperacionResponse> GenerarLecturaZOffline(TokenDto token, LecturaCaja lecturaCaja)
 {
     return(tryCatch.SafeExecutor(() =>
     {
         ValidacionOperacionResponse validacionOperacionResponse = new ValidacionOperacionResponse();
         using (TransactionScope scope = new TransactionScope())
         {
             token.CodeBox = lecturaCaja.CodigoCaja;
             LecturaZGuardarResponse lecturaZGuardarResponse = new LecturaBusiness(token).LecturaZOffline(lecturaCaja);
             inicioFinDiaRepository.RegistrarLecturaZOffline(token.CodeStore, token.CodeBox, lecturaZGuardarResponse.FolioCorte);
             validacionOperacionResponse = inicioFinDiaRepository.RegistrarLogoutCaja(token);
             // Asignamos códigos de Lectura Z
             validacionOperacionResponse.CodeNumber = lecturaZGuardarResponse.CodeNumber;
             validacionOperacionResponse.CodeDescription = lecturaZGuardarResponse.CodeDescription;
             token.CodeBox = 0;
             scope.Complete();
         }
         return validacionOperacionResponse;
     }));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Método para hacer un Logout
        /// </summary>
        /// <param name="token">Token de la sesión</param>
        /// <param name="codigoCaja">Código de la caja sobre la cual se hará el Logout</param>
        /// <returns></returns>
        public ValidacionOperacionResponse RegistrarLogoutCaja(TokenDto token)
        {
            ValidacionOperacionResponse validacionOperacionResponse = new ValidacionOperacionResponse();
            var parametros = new Dictionary <string, object>();

            parametros.Add("@CodigoTienda", token.CodeStore);
            parametros.Add("@CodigoCaja", token.CodeBox);
            parametros.Add("@CodigoEmpleado", token.CodeEmployee);
            List <System.Data.SqlClient.SqlParameter> parametrosOut = new List <System.Data.SqlClient.SqlParameter>();

            parametrosOut.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@CodigoResultado", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
            });
            parametrosOut.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@MensajeResultado", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.NVarChar, Size = 4000
            });
            var resultado = data.ExecuteProcedure("[dbo].[sp_vanti_SegLogout]", parametros, parametrosOut);

            validacionOperacionResponse.CodeNumber      = resultado["@CodigoResultado"].ToString();
            validacionOperacionResponse.CodeDescription = resultado["@MensajeResultado"].ToString();
            return(validacionOperacionResponse);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Método para persistir un desglose de una sección de una Relación de Caja
        /// </summary>
        /// <param name="idSeccionRelacionCaja">Id de la sección de la relación de Caja asociada</param>
        /// <param name="totalConIva">Total con IVa de la relación de Caja</param>
        /// <param name="descripcion">Descripción del desglose de la sección</param>
        /// <returns></returns>
        public ValidacionOperacionResponse AgregarDesgloseSeccionRelacionCaja(int idSeccionRelacionCaja, decimal totalConIva, string descripcion)
        {
            ValidacionOperacionResponse validacionOperacionResponse = new ValidacionOperacionResponse();
            var parametros = new Dictionary <string, object>();

            parametros.Add("@IdSeccionRelacionCaja", idSeccionRelacionCaja);
            parametros.Add("@TotalConIva", totalConIva);
            parametros.Add("@Descripcion", descripcion);
            List <System.Data.SqlClient.SqlParameter> parametrosOut = new List <System.Data.SqlClient.SqlParameter>();

            parametrosOut.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@CodigoResultado", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.Int
            });
            parametrosOut.Add(new System.Data.SqlClient.SqlParameter()
            {
                ParameterName = "@MensajeResultado", Direction = ParameterDirection.Output, SqlDbType = SqlDbType.NVarChar, Size = 4000
            });
            var resultado = data.ExecuteProcedure("[dbo].[sp_vanti_server_AgregarDesgloseSeccionRelacionCaja]", parametros, parametrosOut);

            validacionOperacionResponse.CodeNumber      = resultado["@CodigoResultado"].ToString();
            validacionOperacionResponse.CodeDescription = resultado["@MensajeResultado"].ToString();
            return(validacionOperacionResponse);
        }