Exemple #1
0
        public static FactorBE RegistraFactor(FactorBE entidad)
        {
            entidad = factorDA.RegistraFactor(entidad);
            if (entidad.OK)
            {
                if (entidad.ListaFactorParametro != null)
                {
                    entidad = factorDA.EliminaParametroFactor(entidad);
                    if (entidad.OK)
                    {
                        foreach (var item in entidad.ListaFactorParametro)
                        {
                            item.ID_FACTOR = entidad.ID_FACTOR;
                            FactorParametroBE resultado = factorDA.RegistraParametroFactor(item);
                            if (!resultado.OK)
                            {
                                entidad.OK      = resultado.OK;
                                entidad.message = resultado.message;
                                break;
                            }
                        }
                        factorDA.RegistraFactorValor(new FactorParametroBE {
                            ID_FACTOR = entidad.ID_FACTOR, ID_DETALLE = entidad.ID_DETALLE, NOMBRE_DETALLE = "FACTOR " + entidad.UNIDAD_MEDIDA
                        });                                                                                                                                                                         //add 29-03-20
                    }
                }
            }

            return(entidad);
        }
Exemple #2
0
        public List <FactorBE> ListaFactorPaginado(FactorBE entidad)
        {
            List <FactorBE> Lista = null;

            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage + "USP_SEL_FACTOR_PAGINADO";
                    var    p  = new OracleDynamicParameters();
                    p.Add("pRegistros", entidad.cantidad_registros);
                    p.Add("pPagina", entidad.pagina);
                    p.Add("pSortColumn", entidad.order_by);
                    p.Add("pSortOrder", entidad.order_orden);
                    p.Add("PO_CURSOR", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);
                    Lista = db.Query <FactorBE>(sp, p, commandType: CommandType.StoredProcedure).ToList();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(Lista);
        }
Exemple #3
0
        public FactorBE GuardarFactores(FactorParametroDataBE entidad)
        {
            FactorBE f = new FactorBE();

            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage3 + "USP_PRC_FACTOR_DATA";
                    var    p  = new OracleDynamicParameters();
                    p.Add("pID_FACTOR", entidad.ID_FACTOR);
                    p.Add("pID_DETALLE", entidad.ID_DETALLE);
                    p.Add("pID_PARAMETRO", entidad.ID_PARAMETRO);
                    p.Add("pVALOR", entidad.VALOR);
                    p.Add("pFACTOR", entidad.FACTOR);
                    db.Execute(sp, p, commandType: CommandType.StoredProcedure);
                    f.OK = true;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                f.OK = false;
            }

            return(f);
        }
Exemple #4
0
        public FactorBE RegistraFactor(FactorBE entidad)
        {
            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage + "USP_MNT_FACTOR";

                    var parametros = new OracleParameter[3];
                    parametros[0] = new OracleParameter("PI_ID_FACTOR", entidad.ID_FACTOR);
                    parametros[1] = new OracleParameter("PI_NOMBRE", entidad.NOMBRE_FACTOR);
                    parametros[2] = new OracleParameter("PO_ID_FACTOR", OracleDbType.Int32, ParameterDirection.Output);
                    OracleHelper.ExecuteNonQuery(CadenaConexion, CommandType.StoredProcedure, sp, parametros);
                    if (entidad.ID_FACTOR == 0)
                    {
                        entidad.ID_FACTOR = int.Parse(parametros[2].Value.ToString());
                    }
                }

                entidad.OK = true;
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                entidad.OK      = false;
                entidad.message = ex.Message;
            }
            return(entidad);
        }
Exemple #5
0
        public List <FactorBE> ListarEnfoqueFactorExcel(FactorBE entidad)
        {
            List <FactorBE> lista = null;

            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage3 + "USP_SEL_EXCEL_ENF_FAC";
                    var    p  = new OracleDynamicParameters();
                    p.Add("pBuscar", entidad.buscar);
                    p.Add("pSortColumn", entidad.order_by);
                    p.Add("pSortOrder", entidad.order_orden);
                    p.Add("pRefcursor", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);
                    lista = db.Query <FactorBE>(sp, p, commandType: CommandType.StoredProcedure).ToList();

                    foreach (var item in lista)
                    {
                        item.listaFactor = ListaEnfoqueFactores(item);
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(lista);
        }
Exemple #6
0
        public static FactorBE RegistraFactor(FactorBE entidad)
        {
            entidad = factorDA.RegistraFactor(entidad);
            if (entidad.OK)
            {
                if (entidad.ListaFactorParametro != null)
                {
                    entidad = factorDA.EliminaParametroFactor(entidad);
                    if (entidad.OK)
                    {
                        foreach (var item in entidad.ListaFactorParametro)
                        {
                            item.ID_FACTOR = entidad.ID_FACTOR;
                            FactorParametroBE resultado = factorDA.RegistraParametroFactor(item);
                            if (!resultado.OK)
                            {
                                entidad.OK      = resultado.OK;
                                entidad.message = resultado.message;
                                break;
                            }
                        }
                    }
                }
            }

            return(entidad);
        }
Exemple #7
0
        public List <FactorBE> ListarFactoresVerificar(string factores)
        {
            List <FactorBE> lista = new List <FactorBE>();

            try
            {
                var lista_id = factores.Split(',');
                for (int i = 0; i < lista_id.Length; i++)
                {
                    FactorBE factor = new FactorBE();
                    factor.ID_FACTOR            = Convert.ToInt32(lista_id[i]);
                    factor.ListaFactorParametro = listarCabeceraFactor(new FactorParametroBE {
                        ID_FACTOR = Convert.ToInt32(lista_id[i])
                    });
                    factor.listaFactorData = ListarCuerpoFactor(new FactorParametroDataBE {
                        ID_FACTOR = Convert.ToInt32(lista_id[i])
                    });
                    lista.Add(factor);
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(lista);
        }
Exemple #8
0
 public static List <FactorBE> ListarEnfoqueFactorExcel(FactorBE entidad)
 {
     if (string.IsNullOrEmpty(entidad.buscar))
     {
         entidad.buscar = "";
     }
     return(factorDA.ListarEnfoqueFactorExcel(entidad));
 }
Exemple #9
0
        public static FactorBE GuardarFactores(FactorBE entidad)
        {
            FactorBE e = new FactorBE();

            foreach (var item in entidad.listaFactorData)
            {
                e = factorDA.GuardarFactores(item);
            }

            if (!string.IsNullOrEmpty(entidad.ID_ELIMINAR_FACTOR))
            {
                e = factorDA.EliminarFactores(entidad);
            }
            return(e);
        }
Exemple #10
0
        //////////////////////////////////////////////////
        public static List <FactorBE> ListaFactor(FactorBE entidad)
        {
            List <FactorBE> lista = factorDA.ListaFactor(entidad);

            if (lista != null)
            {
                foreach (var item in lista)
                {
                    FactorBE vEntidad = new FactorBE()
                    {
                        ID_FACTOR = item.ID_FACTOR
                    };
                    item.ListaFactorParametro = factorDA.ListaFactorParametro(vEntidad);
                }
            }

            return(lista);
        }
Exemple #11
0
        public static FactorBE GuardarMedidaFactor(FactorBE entidad)
        {
            FactorBE e = new FactorBE();

            foreach (var item in entidad.listaFactor)
            {
                e = factorDA.GuardarMedidaFactor(item);
                if (!e.OK)
                {
                    break;
                }
            }

            if (e.OK)
            {
                if (!string.IsNullOrEmpty(entidad.ID_ELIMINAR_FACTOR))
                {
                    e = factorDA.EliminarMedidaFactor(entidad);
                }
            }
            return(e);
        }
Exemple #12
0
        public static List <FactorBE> ListaFactorPaginado(FactorBE entidad)
        {
            if (string.IsNullOrEmpty(entidad.buscar))
            {
                entidad.buscar = "";
            }
            List <FactorBE> lista = factorDA.ListaFactorPaginado(entidad);

            if (lista != null)
            {
                foreach (var item in lista)
                {
                    FactorBE vEntidad = new FactorBE()
                    {
                        ID_FACTOR = item.ID_FACTOR
                    };
                    item.ListaFactorParametro = factorDA.ListaFactorParametro(vEntidad);
                }
            }

            return(lista);
        }
Exemple #13
0
        public FactorBE ValidarEnfoqueFactor(FactorBE entidad)
        {
            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage3 + "USP_UPD_VALIDAR_ENF_FACTOR";
                    var    p  = new OracleDynamicParameters();
                    p.Add("pID_ENFOQUE", entidad.ID_ENFOQUE);
                    p.Add("pRefcursor", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);
                    entidad    = db.Query <FactorBE>(sp, p, commandType: CommandType.StoredProcedure).FirstOrDefault();
                    entidad.OK = true;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                entidad.OK = false;
            }

            return(entidad);
        }
Exemple #14
0
        public FactorBE EliminarEnfoqueFactor(FactorBE entidad)
        {
            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage3 + "USP_UPD_ELIMINAR_ENF_FACTOR";
                    var    p  = new OracleDynamicParameters();
                    p.Add("pID_ENFOQUE", entidad.ID_MEDMIT);
                    p.Add("pID_ELIMINAR_FACTOR", entidad.ID_ELIMINAR_FACTOR);
                    db.Execute(sp, p, commandType: CommandType.StoredProcedure);
                    entidad.OK = true;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                entidad.OK = false;
            }

            return(entidad);
        }
Exemple #15
0
        public List <FactorParametroBE> ListaFactorParametro(FactorBE entidad)
        {
            List <FactorParametroBE> lista = null;

            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage + "USP_SEL_FACTOR_PARAMETRO";
                    var    p  = new OracleDynamicParameters();
                    p.Add("PI_ID_FACTOR", entidad.ID_FACTOR);
                    p.Add("PO_CURSOR", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);
                    lista = db.Query <FactorParametroBE>(sp, p, commandType: CommandType.StoredProcedure).ToList();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(lista);
        }
Exemple #16
0
        public List <FactorBE> ListaEnfoqueFactores(FactorBE entidad)
        {
            List <FactorBE> lista = null;

            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage3 + "USP_SEL_LISTA_ENFOQUE_FACTOR";
                    var    p  = new OracleDynamicParameters();
                    p.Add("pID_ENFOQUE", entidad.ID_ENFOQUE);
                    p.Add("pRefcursor", dbType: OracleDbType.RefCursor, direction: ParameterDirection.Output);
                    lista = db.Query <FactorBE>(sp, p, commandType: CommandType.StoredProcedure).ToList();
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
            }

            return(lista);
        }
Exemple #17
0
        //===========================================================================
        public FactorBE GuardarMedidaFactor(FactorBE entidad)
        {
            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage3 + "USP_PRC_MEDIDA_FACTOR";
                    var    p  = new OracleDynamicParameters();
                    p.Add("pID_FACTOR", entidad.ID_FACTOR);
                    p.Add("pID_MEDMIT", entidad.ID_MEDMIT);
                    p.Add("pORDEN", entidad.ORDEN);
                    db.Execute(sp, p, commandType: CommandType.StoredProcedure);
                    entidad.OK = true;
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                entidad.OK = false;
            }

            return(entidad);
        }
Exemple #18
0
        public FactorBE EliminaParametroFactor(FactorBE entidad)
        {
            try
            {
                using (IDbConnection db = new OracleConnection(CadenaConexion))
                {
                    string sp = sPackage + "USP_DEL_FACTOR_PARAMETRO";
                    var    p  = new OracleDynamicParameters();
                    p.Add("PI_ID_FACTOR", entidad.ID_FACTOR);
                    db.Execute(sp, p, commandType: CommandType.StoredProcedure);
                }

                entidad.OK = true;
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                entidad.OK      = false;
                entidad.message = ex.Message;
            }

            return(entidad);
        }
Exemple #19
0
        private static string VerificaOperando(string istrOperando, List <IndicadorDataBE> listaEntidad)
        {
            string  ls_subformula   = "";
            decimal lde_importecida = 0;
            string  ls_cida         = "";

            switch (istrOperando.Substring(0, 1))
            {
            case "C":
                ls_cida       = istrOperando.Substring(1);
                ls_subformula = ls_cida.Trim();
                break;

            case "P":
                //'Captura del Operando el Codigo del Parametro
                ls_cida = istrOperando.Substring(1, istrOperando.Length - 1);
                //Captura Importe ingresado para el Parametro
                IndicadorDataBE item = listaEntidad.Find(A => A.ID_PARAMETRO.Equals(int.Parse(ls_cida)));
                if (item != null)
                {
                    lde_importecida = decimal.Parse(item.VALOR);
                }
                else
                {
                    lde_importecida = 0;
                }
                ls_subformula = lde_importecida.ToString();
                break;

            case "F":
                //Recupero información de factor
                ls_cida = istrOperando.Substring(1);
                FactorBE Fentidad = new FactorBE()
                {
                    ID_FACTOR = int.Parse(ls_cida)
                };

                //Consultamos en caso sea Factor de rendimiento
                if (ls_cida == WebConfigurationManager.AppSettings["FactorRendimiento"])
                {
                    IndicadorDataBE itemF = listaEntidad.Find(A => A.ID_PARAMETRO.Equals(int.Parse(WebConfigurationManager.AppSettings["ParametroFR"])));
                    if (itemF != null)
                    {
                        if (!string.IsNullOrEmpty(itemF.VALOR) && itemF.VALOR != "0.00" && itemF.VALOR != "0")
                        {
                            lde_importecida = decimal.Parse(itemF.VALOR);
                        }
                        else
                        {
                            List <FactorParametroBE> lFactorBE = new FactorDA().ListaFactorParametro(Fentidad);

                            if (lFactorBE != null)
                            {
                                string SQL           = "";
                                string SQL_PARAMETRO = "'";
                                string SQL_VALOR     = "'";
                                int    I             = 1;
                                foreach (FactorParametroBE param in lFactorBE)
                                {
                                    IndicadorDataBE data = listaEntidad.Find(A => A.ID_PARAMETRO.Equals(param.ID_PARAMETRO));
                                    SQL_PARAMETRO += param.ID_PARAMETRO.ToString() + (I == lFactorBE.Count ? "" : "|");
                                    SQL_VALOR     += data.VALOR + (I == lFactorBE.Count ? "" : "|");
                                    I++;
                                }
                                SQL_PARAMETRO += "'";
                                SQL_VALOR     += "'";
                                SQL           += "AND F.ID_PARAMETRO = " + SQL_PARAMETRO + " AND  F.VALOR = " + SQL_VALOR;

                                List <FactorParametroDataBE> lFactorDataBE = new FactorDA().ListaFactorParametroData(Fentidad, SQL);
                                if (lFactorDataBE != null)
                                {
                                    if (lFactorDataBE.Count > 0)
                                    {
                                        lde_importecida = lFactorDataBE[0].FACTOR;
                                    }
                                    else
                                    {
                                        lde_importecida = 0;
                                    }
                                }
                            }
                            else
                            {
                                lde_importecida = 0;
                            }
                            ls_subformula = lde_importecida.ToString();
                            itemF.VALOR   = ls_subformula;
                        }
                        ls_subformula = lde_importecida.ToString();
                    }
                    else
                    {
                        List <FactorParametroBE> lFactorBE = new FactorDA().ListaFactorParametro(Fentidad);

                        if (lFactorBE != null)
                        {
                            string SQL           = "";
                            string SQL_PARAMETRO = "'";
                            string SQL_VALOR     = "'";
                            int    I             = 1;
                            foreach (FactorParametroBE param in lFactorBE)
                            {
                                IndicadorDataBE data = listaEntidad.Find(A => A.ID_PARAMETRO.Equals(param.ID_PARAMETRO));
                                SQL_PARAMETRO += param.ID_PARAMETRO.ToString() + (I == lFactorBE.Count ? "" : "|");
                                SQL_VALOR     += data.VALOR + (I == lFactorBE.Count ? "" : "|");
                                I++;
                            }
                            SQL_PARAMETRO += "'";
                            SQL_VALOR     += "'";
                            SQL           += "AND F.ID_PARAMETRO = " + SQL_PARAMETRO + " AND  F.VALOR = " + SQL_VALOR;

                            List <FactorParametroDataBE> lFactorDataBE = new FactorDA().ListaFactorParametroData(Fentidad, SQL);
                            if (lFactorDataBE != null)
                            {
                                if (lFactorDataBE.Count > 0)
                                {
                                    lde_importecida = lFactorDataBE[0].FACTOR;
                                }
                                else
                                {
                                    lde_importecida = 0;
                                }
                            }
                        }
                        else
                        {
                            lde_importecida = 0;
                        }
                        ls_subformula = lde_importecida.ToString();
                    }
                }
                else
                {
                    List <FactorParametroBE> lFactorBE = new FactorDA().ListaFactorParametro(Fentidad);

                    if (lFactorBE != null)
                    {
                        string SQL           = "";
                        string SQL_PARAMETRO = "'";
                        string SQL_VALOR     = "'";
                        int    I             = 1;
                        foreach (FactorParametroBE param in lFactorBE)
                        {
                            IndicadorDataBE data = listaEntidad.Find(A => A.ID_PARAMETRO.Equals(param.ID_PARAMETRO));
                            SQL_PARAMETRO += param.ID_PARAMETRO.ToString() + (I == lFactorBE.Count ? "" : "|");
                            SQL_VALOR     += data.VALOR + (I == lFactorBE.Count ? "" : "|");
                            I++;
                        }
                        SQL_PARAMETRO += "'";
                        SQL_VALOR     += "'";
                        SQL           += "AND F.ID_PARAMETRO = " + SQL_PARAMETRO + " AND  F.VALOR = " + SQL_VALOR;

                        List <FactorParametroDataBE> lFactorDataBE = new FactorDA().ListaFactorParametroData(Fentidad, SQL);
                        if (lFactorDataBE != null)
                        {
                            if (lFactorDataBE.Count > 0)
                            {
                                lde_importecida = lFactorDataBE[0].FACTOR;
                            }
                            else
                            {
                                lde_importecida = 0;
                            }
                        }
                    }
                    else
                    {
                        lde_importecida = 0;
                    }
                    ls_subformula = lde_importecida.ToString();
                }

                break;

            case "V":
                ls_cida = istrOperando.Substring(1);
                VariableBE Ventidad = new VariableBE()
                {
                    ID_VARIABLE = int.Parse(ls_cida)
                };
                List <VariableBE> lVariable = new VariableDA().ListaVariables(Ventidad);

                switch (ls_cida)
                {
                case "1":         //Dias de funcionamiento desde la fecha de instalación

                    if (lVariable != null)
                    {
                        foreach (VariableBE vItem in lVariable)
                        {
                            IndicadorDataBE vIndicador = listaEntidad.Find(A => A.ID_PARAMETRO.Equals(vItem.ID_PARAMETRO));
                            if (vIndicador != null)
                            {
                                DateTime fechaInicial = DateTime.ParseExact(vIndicador.VALOR, "yyyy-MM-dd", CultureInfo.GetCultureInfo("es-PE"));
                                DateTime fechaFinal   = new DateTime(fechaInicial.Year, 12, 31);
                                TimeSpan diferencia   = fechaFinal - fechaInicial;
                                lde_importecida = diferencia.Days;
                            }
                            else
                            {
                                lde_importecida = 0;
                            }
                        }
                    }
                    else
                    {
                        lde_importecida = 0;
                    }
                    break;

                case "2":           //Sumatoria de reducciones GEI para periodos pasados al campo año del registro
                    if (lVariable != null)
                    {
                        foreach (VariableBE vItem in lVariable)
                        {
                            IndicadorDataBE vIndicador = listaEntidad.Find(A => A.ID_PARAMETRO.Equals(vItem.ID_PARAMETRO));

                            lde_importecida = new VariableDA().SumatoriaGeiReducido(int.Parse(vIndicador.VALOR), listaEntidad[0].ID_INICIATIVA);
                        }
                    }

                    break;
                }
                ls_subformula = lde_importecida.ToString();

                break;
            }


            return(ls_subformula);
        }
Exemple #20
0
 public static List <FactorParametroBE> ListaFactorParametro(FactorBE entidad)
 {
     return(factorDA.ListaFactorParametro(entidad));
 }
Exemple #21
0
 public static List <FactorBE> GetEnfoqueFactor(FactorBE entidad)
 {
     return(factorDA.ListaEnfoqueFactores(entidad));
 }
Exemple #22
0
 public static FactorBE ValidarEnfoqueFactor(FactorBE entidad)
 {
     return(factorDA.ValidarEnfoqueFactor(entidad));
 }
Exemple #23
0
 public static List <FactorBE> ListarEnfoqueFactorVerificar(FactorBE entidad)
 {
     return(factorDA.ListaEnfoqueFactores(entidad));
 }
Exemple #24
0
 public static List <FactorBE> ListarFormulaVerificar(FactorBE entidad)
 {
     return(factorDA.ListarFomulasVerificar(entidad));
 }
Exemple #25
0
 public static List <FactorBE> GetMedidaFactor(FactorBE entidad)
 {
     return(factorDA.ListaMedidaFactores(entidad));
 }
Exemple #26
0
 public static FactorBE ValidarMedidaFactor(FactorBE entidad)
 {
     return(factorDA.ValidarMedidaFactor(entidad));
 }