Esempio n. 1
0
        public void UpdateCplexParameterDescription()
        {
            string query = string.Format("UPDATE parametrosCplex " +
                                         "SET Descripcion = 'Number of CPU cores that CPLEX actually uses during a parallel optimization' " +
                                         "WHERE nombre = 'threads'");

            DataBaseManager.ExecuteQuery(query);
            log.Info(MessageUtil.FormatMessage("INFO.CplexParameterDescriptionUpdated"));
        }
Esempio n. 2
0
        public static void DeletePeriodicThermalPlant(PeriodicConventionalPlant periodicThermalPlant)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Nombre = '{1}' " +
                                         "AND Periodo = {2} ",
                                         table, periodicThermalPlant.Name, periodicThermalPlant.Period);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 3
0
        public static void DeleteRecursoPrecio(RecursoPrecio RecursoPrecio)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Precio = {2}",
                                         table, RecursoPrecio.Name, RecursoPrecio.Precio);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 4
0
        public static void DeleteAreaBarra(AreaBarra AreaBarra)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Periodo = {2}",
                                         table, AreaBarra.Name, AreaBarra.Periodo);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 5
0
        public static void DeleteZonaUnidad(ZonaUnidad ZonaUnidad)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Periodo = {2}",
                                         table, ZonaUnidad.Name, ZonaUnidad.Periodo);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 6
0
        public static void DeleteRecursoRampa(RecursoRampa RecursoRampa)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Configuracion = {2}",
                                         table, RecursoRampa.Name, RecursoRampa.Configuracion);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 7
0
        public static void DeleteCortePeriodo(CortePeriodo CortePeriodo)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Periodo = {2}",
                                         table, CortePeriodo.Name, CortePeriodo.Periodo);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 8
0
        public static void DeleteRecursoFactible(RecursoFactible RecursoFactible)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND indice = {2}",
                                         table, RecursoFactible.Name, RecursoFactible.indice);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 9
0
        public static void DeletePeriodicHydroSystem(PeriodicHydroSystem periodicHydroSystem)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE sistema = '{1}' " +
                                         "AND Periodo = {2} ",
                                         table, periodicHydroSystem.Name, periodicHydroSystem.Period);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 10
0
        public static void DeletePeriodicFuel(PeriodicFuel periodicFuel)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE CentroAbastecimiento = '{1}' " +
                                         "AND Periodo = {2} " +
                                         "AND Escenario = {3}",
                                         table, periodicFuel.Name, periodicFuel.Period, periodicFuel.Case);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 11
0
        public static void DeletePeriodicLoadBlock(PeriodicLoadBlock periodicBlock)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Bloque = {1} " +
                                         "AND Periodo = {2} " +
                                         "AND Escenario = {3}",
                                         table, periodicBlock.Block, periodicBlock.Period, periodicBlock.Case);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 12
0
        public static void DeletePeriodicInflow(PeriodicInflow periodicInflow)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = '{1}' " +
                                         "AND Periodo = {2} " +
                                         "AND Escenario = {3}",
                                         table, periodicInflow.Name, periodicInflow.Period, periodicInflow.Case);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 13
0
        public static void DeletePeriodicFuelContract(PeriodicFuelContract periodicFuelContract)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Nombre = '{1}' " +
                                         "AND Periodo = {2} " +
                                         "AND Escenario = {3}",
                                         table, periodicFuelContract.Name, periodicFuelContract.Period, periodicFuelContract.Case);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 14
0
        public static void DeleteElement(HydroTopology dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Sistema = '{1}' " +
                                         "AND Elemento = '{2}' " +
                                         "AND Tipo = '{3}'",
                                         table, dataObject.System, dataObject.Element, dataObject.Type);

            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 15
0
        public static void DeleteObject(HydroSystem dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Id = {1}", table, dataObject.Id);

            DataBaseManager.ExecuteQuery(query);

            query = string.Format("DELETE FROM topologiaHidraulica " +
                                  "WHERE Sistema = '{0}'", dataObject.Name);
            DataBaseManager.ExecuteQuery(query);
        }
Esempio n. 16
0
        public void CreateElementTypeColumnInHydroTopologyTable()
        {
            string table  = "topologiaHidraulica";
            string column = "TipoElemento";

            string query = string.Format("ALTER TABLE {0} ADD {1} Text", table, column);

            using (OleDbCommand command = new OleDbCommand(query, DataBaseManager.DbConnection))
            {
                DataBaseManager.DbConnection.Open();
                try
                {
                    command.ExecuteNonQuery();
                }
                catch
                {
                    //TODO: Move to DBManager after testing
                }
                DataBaseManager.DbConnection.Close();
            }

            List <NameMapping> typeConversionMapping = new List <NameMapping>()
            {
                new NameMapping("'E', 'V', 'AV', 'A', 'AA'", "Embalse"),
                new NameMapping("'R'", "Rio"),
                new NameMapping("'TG'", "RecursoHidro"),
                new NameMapping("'T'", "ElementoHidro")
            };

            foreach (NameMapping mapping in typeConversionMapping)
            {
                query = string.Format("UPDATE {0} " +
                                      "SET TipoElemento = '{1}' " +
                                      "WHERE Tipo IN({2})", table, mapping.SDDPName, mapping.DHOGName);
                DataBaseManager.ExecuteQuery(query);
            }

            query = string.Format("UPDATE {0} " +
                                  "SET TipoElemento = 'RecursoHidro' " +
                                  "WHERE Tipo = 'AT' " +
                                  "AND topologiaHidraulica.Elemento IN (SELECT nombre " +
                                  "FROM RecursoHidroBasica " +
                                  "WHERE Escenario = 1)", table);
            DataBaseManager.ExecuteQuery(query);

            query = string.Format("UPDATE {0} " +
                                  "SET TipoElemento = 'ElementoHidro' " +
                                  "WHERE Tipo = 'AT' " +
                                  "AND topologiaHidraulica.Elemento IN (SELECT nombre " +
                                  "FROM elementoHidraulicoBasica)", table);
            DataBaseManager.ExecuteQuery(query);

            log.Info(MessageUtil.FormatMessage("INFO.ColumnCreatedInTable", column, table));
        }
Esempio n. 17
0
        public void CreateDBInfoTable()
        {
            string table = "InfoBD";
            string query = string.Format("CREATE TABLE {0} (Id Int NOT NULL, Descripcion Text, VersionDHOG Double, PRIMARY KEY (ID))", table);

            DataBaseManager.ExecuteQuery(query);

            query = string.Format("INSERT INTO {0}(Id, Descripcion, VersionDHOG) " +
                                  "VALUES (1, 'Descripción autogenerada por el sistema', 3.2)", table);
            DataBaseManager.ExecuteQuery(query);

            log.Info(MessageUtil.FormatMessage("INFO.TableCreated", table));
        }
Esempio n. 18
0
        public void CreateDBZonaEspecial()
        {
            string table = "zonaEspecial";
            string query = string.Format("CREATE TABLE {0} (Nombre LONGCHAR, IndiceIni SMALLINT, IndiceFin SMALLINT,Id autoincrement, PRIMARY KEY (ID))", table);

            DataBaseManager.ExecuteQuery(query);

            query = string.Format("INSERT INTO {0}(Nombre, IndiceIni, IndiceFin,Id) " +
                                  "VALUES ('Sogamoso',1,12,1)", table);
            DataBaseManager.ExecuteQuery(query);

            log.Info(MessageUtil.FormatMessage("INFO.TableCreated", table));
        }
Esempio n. 19
0
        public void CreateDBRutasDhog()
        {
            string table = "RutasDhog";
            string query = string.Format("CREATE TABLE {0} (Id autoincrement,  RutaModelo LONGCHAR, RutaEjecutable LONGCHAR, RutaBD LONGCHAR, RutaSalida LONGCHAR, RutaSolver LONGCHAR, PRIMARY KEY (ID))", table);

            DataBaseManager.ExecuteQuery(query);

            query = string.Format("INSERT INTO {0} (ID, RutaModelo, RutaEjecutable, RutaBD, RutaSalida, RutaSolver)" +
                                  "VALUES (1,'Modelo','Ejecutable','BD','Salida','Solver')", table);
            DataBaseManager.ExecuteQuery(query);

            log.Info(MessageUtil.FormatMessage("INFO.TableCreated", table));
        }
Esempio n. 20
0
        public static void UpdateObject(NameMapping dataObject)
        {
            string query = string.Format("SELECT Rio " +
                                         "FROM {0} " +
                                         "WHERE Rio = '{1}'", table, dataObject.DHOGName);

            OleDbDataReader reader = DataBaseManager.ReadData(query);

            if (!reader.Read())
            {
                query = string.Format("INSERT INTO {0}(Id, Rio) " +
                                      "VALUES(@SDDPNumber, @DHOGName)", table);
            }
            //query = string.Format("INSERT INTO {0}(Numero, Rio) " +
            //                          "VALUES(@SDDPNumber, @DHOGName)", table);

            else
            {
                query = string.Format("UPDATE {0} SET " +
                                      "Id = @SDDPNumber " +
                                      "WHERE Rio = @DHOGName", table);
            }

            //query = string.Format("UPDATE {0} SET " +
            //                            "Numero = @SDDPNumber " +
            //                            "WHERE Rio = @DHOGName", table);

            DataBaseManager.DbConnection.Close();

            using (OleDbCommand command = new OleDbCommand(query, DataBaseManager.DbConnection))
            {
                command.Parameters.Add("@SDDPNumber", OleDbType.VarChar);
                command.Parameters.Add("@DHOGName", OleDbType.VarChar);

                DataBaseManager.DbConnection.Open();

                command.Parameters["@SDDPNumber"].Value = dataObject.SDDPNumber;
                command.Parameters["@DHOGName"].Value   = dataObject.DHOGName;

                try
                {
                    int rowsAffected = command.ExecuteNonQuery();
                }
                catch
                {
                    DataBaseManager.DbConnection.Close();
                    throw;
                }
                DataBaseManager.DbConnection.Close();
            }
        }
Esempio n. 21
0
        public void AlterProblemConfigurationTable()
        {
            string table  = "configuracionProblema";
            string column = "PrioridadUI";

            string query = string.Format("ALTER TABLE {0} ADD {1} Int", table, column);

            DataBaseManager.ExecuteQuery(query);
            log.Info(MessageUtil.FormatMessage("INFO.ColumnCreatedInTable", column, table));

            column = "NombreUI";
            query  = string.Format("ALTER TABLE {0} ADD {1} Text", table, column);
            DataBaseManager.ExecuteQuery(query);
            log.Info(MessageUtil.FormatMessage("INFO.ColumnCreatedInTable", column, table));

            List <ConfigurationParameter> variables = new List <ConfigurationParameter>()
            {
                new ConfigurationParameter("AREAS", 1, "Areas Operativas"),
                new ConfigurationParameter("CAR", 1, "Curva CAR"),
                new ConfigurationParameter("VOLUMENFINAL", 1, "Volumen Final"),
                new ConfigurationParameter("VERTIMIENTOS", 1, "Control de Vertimientos"),
                new ConfigurationParameter("PENALIZACIONV", 1, "Penalización de Vertimientos"),
                new ConfigurationParameter("ZONAS", 1, "Zonas de Seguridad"),
                new ConfigurationParameter("DEMANDA", 1, "Demanda"),
                new ConfigurationParameter("FCVARIABLE", 1, "Factor de Conversión Variable"),
                new ConfigurationParameter("FTVARIABLE", 1, "Factor de Consumo Variable"),
                new ConfigurationParameter("CONTRATOSCOMBUSTIBLE", 1, "Contratos Combustible"),
                new ConfigurationParameter("UTILVARIABLE", 1, "Volumen Útil Variable"),
                new ConfigurationParameter("DH", 1, "Energía Hidraúlica"),
                new ConfigurationParameter("GAS", 1, "Energía Térmica"),
                new ConfigurationParameter("CONTRATOSBILATERALES", 1, "Generación Mínima por Empresa"),
                new ConfigurationParameter("PERFILPERIODICO", 2, "Perfiles Periódicos"),
                new ConfigurationParameter("WARMSTART", 2, "Warmstart"),
                new ConfigurationParameter("TASADESCUENTO", 2, "Tasa de Descuento"),
                new ConfigurationParameter("COSTO1", 2, "Costos Variables"),
                new ConfigurationParameter("COSTO2", 2, "Costos de Combustible"),
                new ConfigurationParameter("COSTO3", 2, "Costos de Contratos de Combustible"),
                new ConfigurationParameter("GENERARLP", 2, "Generar Archivo LP"),
                new ConfigurationParameter("RGON", 2, "Modelar Unidades"),
            };

            foreach (ConfigurationParameter variable in variables)
            {
                query = string.Format("UPDATE {0} " +
                                      "SET PrioridadUI = {1}, nombreUI = '{2}' " +
                                      "WHERE nombre = '{3}'", table, variable.Priority, variable.UIName, variable.Name);
                DataBaseManager.ExecuteQuery(query);
            }
        }
Esempio n. 22
0
        public List <FuelContract> ReadFuelContracts()
        {
            List <FuelContract> fuelContracts = new List <FuelContract>();

            query  = "SELECT DISTINCT(Nombre), CapacidadHora, CostoContrato, EtapaInicial, EtapaFinal FROM ContratoCombustibleBasica";
            reader = DataBaseManager.ReadData(query);
            while (reader.Read())
            {
                fuelContracts.Add(new FuelContract(reader.GetString(0), Convert.ToDouble(reader.GetValue(1)), Convert.ToDouble(reader.GetValue(2)), Convert.ToInt32(reader.GetValue(3)), Convert.ToInt32(reader.GetValue(4))));
            }

            DataBaseManager.DbConnection.Close();

            return(fuelContracts);
        }
Esempio n. 23
0
        public List <Fuel> ReadFuels()
        {
            List <Fuel> fuels = new List <Fuel>();

            query  = "SELECT DISTINCT(CentroAbastecimiento), CapacidadHora, CostoCombustible FROM combustibleBasica";
            reader = DataBaseManager.ReadData(query);
            while (reader.Read())
            {
                fuels.Add(new Fuel(reader.GetString(0), Convert.ToDouble(reader.GetValue(1)), Convert.ToDouble(reader.GetValue(2))));
            }

            DataBaseManager.DbConnection.Close();

            return(fuels);
        }
Esempio n. 24
0
        public void CreateSubareaColumnInPlantsTables()
        {
            string        column = "Subarea";
            List <string> tables = new List <string>
            {
                "recursoHidroBasica",
                "recursoNoCoBasica",
                "recursoTermicoBasica",
            };

            string query;

            foreach (string table in tables)
            {
                query = string.Format("ALTER TABLE {0} ADD {1} Text", table, column);
                using (OleDbCommand command = new OleDbCommand(query, DataBaseManager.DbConnection))
                {
                    DataBaseManager.DbConnection.Open();
                    try
                    {
                        command.ExecuteNonQuery();
                    }
                    catch
                    {
                        //TODO: Move to DBManager after testing
                    }
                    DataBaseManager.DbConnection.Close();
                }

                query = string.Format("UPDATE {0} as r " +
                                      "INNER JOIN areaRecurso AS a " +
                                      "ON r.nombre = a.recurso " +
                                      "SET r.Subarea = a.nombre", table);
                DataBaseManager.ExecuteQuery(query);

                log.Info(MessageUtil.FormatMessage("INFO.ColumnCreatedInTable", column, table));
            }

            /*
             * query = "DROP TABLE areaRecurso";
             * using (OleDbCommand command = new OleDbCommand(query, DataBaseManager.DbConnection))
             * {
             *  DataBaseManager.DbConnection.Open();
             *  command.ExecuteNonQuery();
             *  DataBaseManager.DbConnection.Close();
             * }
             */
        }
Esempio n. 25
0
        public static List <Block> GetObjects()
        {
            List <Block> blocks = new List <Block>();

            string query = string.Format("SELECT nombre, FactorDuracion, FactorDemanda, Id " +
                                         "FROM {0} ORDER BY Nombre", table);
            OleDbDataReader reader = DataBaseManager.ReadData(query);

            while (reader.Read())
            {
                blocks.Add(new Block(Convert.ToInt32(reader.GetValue(0)), Convert.ToDouble(reader.GetValue(1)), Convert.ToDouble(reader.GetValue(2)), Convert.ToInt32(reader.GetValue(3))));
            }

            DataBaseManager.DbConnection.Close();
            return(blocks);
        }
Esempio n. 26
0
        public Dictionary <int, string> ReadRiversMapping()
        {
            Dictionary <int, string> mappingTable = new Dictionary <int, string>();

            query = "SELECT Numero, Rio " +
                    "FROM MapeoRios";
            reader = DataBaseManager.ReadData(query);
            while (reader.Read())
            {
                mappingTable.Add(Convert.ToInt32(reader.GetValue(0)), reader.GetString(1));
            }

            DataBaseManager.DbConnection.Close();

            return(mappingTable);
        }
Esempio n. 27
0
        public static List <NameMapping> GetObjects()
        {
            List <NameMapping> namesMapping = new List <NameMapping>();

            string query = string.Format("SELECT Recurso, Planta " +
                                         "FROM {0} " +
                                         "ORDER BY Recurso", table);
            OleDbDataReader reader = DataBaseManager.ReadData(query);

            while (reader.Read())
            {
                namesMapping.Add(new NameMapping(reader.GetString(0), reader.GetString(1)));
            }

            DataBaseManager.DbConnection.Close();
            return(namesMapping);
        }
Esempio n. 28
0
        public static List <PeriodicInflow> GetPeriodicInflows()
        {
            List <PeriodicInflow> periodicInflows = new List <PeriodicInflow>();

            string query = string.Format("SELECT Nombre, Periodo, Valor, Escenario " +
                                         "FROM {0}", table);
            OleDbDataReader reader = DataBaseManager.ReadData(query);

            while (reader.Read())
            {
                periodicInflows.Add(new PeriodicInflow(reader.GetString(0), Convert.ToInt32(reader.GetValue(1)), Convert.ToDouble(reader.GetValue(2)), Convert.ToInt32(reader.GetValue(3))));
            }

            DataBaseManager.DbConnection.Close();

            return(periodicInflows);
        }
Esempio n. 29
0
        public static List <ExcludingPlants> GetObjects()
        {
            List <ExcludingPlants> excludingPlants = new List <ExcludingPlants>();

            string query = string.Format("SELECT Recurso1, Recurso2 " +
                                         "FROM {0} " +
                                         "ORDER BY Recurso1", table);
            OleDbDataReader reader = DataBaseManager.ReadData(query);

            while (reader.Read())
            {
                excludingPlants.Add(new ExcludingPlants(reader.GetString(0), reader.GetString(1)));
            }

            DataBaseManager.DbConnection.Close();
            return(excludingPlants);
        }
Esempio n. 30
0
        public static List <LineaBarra> GetObjects()
        {
            List <LineaBarra> LineaBarra = new List <LineaBarra>();

            string query = string.Format("SELECT nombre, barraInicial, barraFinal, reactancia, nMenos1, FlujoMaximo, activa " +
                                         "FROM {0} ORDER BY nombre", table);
            OleDbDataReader reader = DataBaseManager.ReadData(query);

            while (reader.Read())
            {
                LineaBarra.Add(new LineaBarra(Convert.ToString(reader.GetValue(0)), Convert.ToString(reader.GetValue(1)), Convert.ToString(reader.GetValue(2)),
                                              Convert.ToDouble(reader.GetValue(3)), Convert.ToDouble(reader.GetValue(4)), Convert.ToInt32(reader.GetValue(5)), Convert.ToInt32(reader.GetValue(6))));
            }
            DataBaseManager.DbConnection.Close();

            return(LineaBarra);
        }