Пример #1
0
        public static int insertarSeguimientoEnvio(string codEntidad, int estado)
        {
            dynamic aperturaActiva = AperturaController.getAperturaActiva();

            con.Execute(@"UPDATE seguimiento_envios SET activo = false 
                            WHERE activo AND cod_entidad = @cod_entidad AND 
                            id_apertura IN (SELECT id_apertura FROM aperturas WHERE fecha_corte = @fecha_corte )",
                        new { cod_entidad = codEntidad, fecha_corte = (DateTime)aperturaActiva.fecha_corte });
            con.Close();
            SeguimientoEnvio seg = new SeguimientoEnvio();

            seg.id_apertura          = aperturaActiva.id_apertura;
            seg.cod_entidad          = codEntidad;
            seg.fecha_envio          = DateTime.Now;
            seg.estado               = estado.ToString();
            seg.activo               = true;
            seg.valido               = estado > 2; // si es 3: advertencia o 4: valido
            seg.creado_por           = 999;
            seg.creado_en            = DateTime.Now;
            seg.id_seguimiento_envio = con.Query <int>(@"INSERT INTO seguimiento_envios(
                                                             id_apertura, cod_entidad, fecha_envio, estado, 
                                                            activo, valido, creado_por, creado_en)
                                                            VALUES ( @id_apertura, @cod_entidad, @fecha_envio, @estado,
                                                            @activo, @valido, @creado_por,  @creado_en) 
                                                            RETURNING id_seguimiento_envio", seg).Single();
            con.Close();
            return(seg.id_seguimiento_envio);
        }
Пример #2
0
        // end my code

        private void inicializaDatos(string codEntidad, DateTime?fechaCorte = null)
        {
            // AperturaController objAper = new AperturaController();
            this.aperturaDatos = AperturaController.getAperturaActiva();
            this.fechaCorte    = this.aperturaDatos.fecha_corte;
            this.anoControl    = this.fechaCorte.Year;
            this.mesControl    = this.fechaCorte.Month;
            this.diaControl    = this.fechaCorte.Day;
            this.nFechaCorte   = this.anoControl * 10000 + this.mesControl * 100 + this.diaControl;
            this.codigoEntidad = codEntidad;
        }
Пример #3
0
        public int insertConsolidacion([FromBody] string observaciones)
        {
            // AperturaController aper = new AperturaController();
            dynamic aperturaActiva = AperturaController.getAperturaActiva();
            object  consolidacion  = new
            {
                fecha_consolidacion = DateTime.Now,
                fecha_corte         = aperturaActiva.fecha_corte,
                estado        = "",
                procesando    = true,
                observaciones = observaciones,

                creado_por = 999,
                creado_en  = DateTime.Now
            };
            int id = con.Query <int>(@"INSERT INTO consolidaciones( fecha_consolidacion,
                                                        estado, fecha_corte, procesando, observaciones, creado_por, creado_en)
                                    VALUES (@fecha_consolidacion,
                                    @estado, @fecha_corte,  @procesando, @observaciones,  @creado_por, @creado_en) RETURNING id_consolidacion", consolidacion).Single();

            con.Close();
            return(id);
        }
        public int insertConsolidacion(string observaciones, Base helper)
        {
            // AperturaController aper = new AperturaController();
            dynamic aperturaActiva = AperturaController.getAperturaActiva();
            object  consolidacion  = new
            {
                fecha_consolidacion = DateTime.Now,
                fecha_corte         = aperturaActiva.fecha_corte,
                estado        = "",
                procesando    = true,
                observaciones = observaciones,

                creado_por = helper.UsuarioId,
                creado_en  = DateTime.Now
            };
            int id = con.Query <int>(@"INSERT INTO consolidaciones( fecha_consolidacion,
                                                       estado, fecha_corte, procesando, observaciones, creado_por, creado_en)
                                   VALUES (@fecha_consolidacion,
                                   @estado, @fecha_corte,  @procesando, @observaciones,  @creado_por, @creado_en) RETURNING id_consolidacion", consolidacion).Single();

            con.Close();
            helper.AddLog(Log.TipoOperaciones.Modificacion, typeof(ConsolidacionController), "insertar", consolidacion);
            return(id);
        }
Пример #5
0
        public object validacionConsultaPartesEF(string web_reporte, int idSeguimientoEnvio) //objetoRecibido = {id_seguimiento_envio }
        {
            try
            {
                // my code
                string token = HttpHelpers.GetTokenFromHeader(HttpContext);
                if (token == "")
                {
                    return(Unauthorized());
                }

                Base helper = new Base(AppSettings, token, HttpContext.Connection.RemoteIpAddress.ToString());

                List <Error> erroresLista            = ErroresController.getErroresDeSeguimiento(idSeguimientoEnvio);
                dynamic      seguimientoEntidadDatos = SgmntController.getSeguimientoEntidadDatos(idSeguimientoEnvio);
                this.codigoEntidad      = seguimientoEntidadDatos.cod_entidad.ToString();
                this.erroresDiccionario = ConstantesController.obtieneConstantesDeDimension("error");
                this.aperturaDatos      = AperturaController.getAperturaDeSeguimiento(idSeguimientoEnvio);

                this.fechaCorte = this.aperturaDatos.fecha_corte;
                this.anoControl = this.fechaCorte.Year;
                this.mesControl = this.fechaCorte.Month;
                this.diaControl = this.fechaCorte.Day;

                this.cambio_2 = this.aperturaDatos.mCompra;
                this.cambio_4 = this.aperturaDatos.mUFV;
                this.cambio_5 = this.aperturaDatos.mEuroBS;
                this.margenEF = this.aperturaDatos.margen_partes_ef;
                this.factorTC = this.aperturaDatos.factor_tc;

                this.archivosEntidadCadena = ArchivosController.encadenaArchivosDeEntidadMes(this.codigoEntidad, this.mesControl);

                ////////////////////// FORMATO ////////////////////////////////////////////////
                IEnumerable <Error> erroresF = erroresLista.Where(x => x.cod_error.Substring(0, 1) == "0").OrderBy(x => x.cod_error);
                bool validoF       = true;
                int  estadoValidez = 4;
                foreach (Error errorF in erroresF)
                {
                    errorF.desc_error    = descError(errorF.cod_error);
                    errorF.estadoValidez = estadoValidezDeError(errorF);
                    if (errorF.estadoValidez < estadoValidez)
                    {
                        estadoValidez = errorF.estadoValidez;
                    }
                }
                if (estadoValidez > 1) // si no hay EE
                {
                    // //////////////////////////////Validacion contenidos SIf y varios
                    dynamic valContenido   = this.realizarValidacionContenido();
                    int     estadoValidezC = valContenido.estadoValidez;
                    this.resultado.estadoValidezC = estadoValidezC;
                    this.resultado.validoC        = estadoValidezC > 2;
                    if (web_reporte == "web") //si es WEB se carga en una lista
                    {
                        this.resultado.datosC      = this.listaValCont;
                        this.resultado.validacionC = null;
                    }
                    else if (web_reporte == "reporte") //  sie es en para reporte se separa en objetos que tinen la misma estuctura
                    {
                        this.resultado.validacionC = valContenido;
                        this.resultado.datosC      = null;
                    }

                    /////////////////////////////// Validacion de Partes de Producción y Siniestros  con Estados Financieros ///////////////////////////////////////////
                    int estadoValidezEF = this.validaPartesEF();
                    this.resultado.estadoValidezEF = estadoValidezEF;
                    this.resultado.validoEF        = estadoValidezEF > 2;
                    this.resultado.datosEF         = listaValEF;

                    // del resultado gral
                    estadoValidez = Math.Min(estadoValidez, Math.Min(estadoValidezC, estadoValidezEF));
                }
                else
                {
                    validoF = false;
                }

                this.resultado.aperturaDatos           = this.aperturaDatos;
                this.resultado.seguimientoEntidadDatos = seguimientoEntidadDatos;


                List <dynamic> constantes = ConstantesController.obtieneConstantesDeDimension("estado_seguimiento");
                dynamic        estadoSeg  = constantes.Where(x => x.codigo == estadoValidez.ToString()).FirstOrDefault();

                this.con.Close();
                this.resultado.status             = "success";
                this.resultado.estadoValidez      = estadoValidez;
                this.resultado.estadoValidez_desc = estadoSeg.valor + " - " + estadoSeg.descripcion;

                this.resultado.validoF  = validoF;
                this.resultado.erroresF = erroresF;

                return(this.resultado);
            }
            catch (Exception ex)
            {
                return(new
                {
                    status = "error",
                    mensaje = ex.Message
                });
            }
        }