Exemple #1
0
        public void CreateFuelColumnInThermalPlantTable()
        {
            string table  = "recursoTermicoBasica";
            string column = "Combustible";

            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();
            }

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

            log.Info(MessageUtil.FormatMessage("INFO.ColumnCreatedInTable", column, table));
        }
Exemple #2
0
        public void CreatePeriodicHydroElementTable()
        {
            bool   alterTable = false;
            string table      = "elementoHidraulicoPeriodo";
            string query      = string.Format("SELECT * FROM {0}", table);

            using (OleDbCommand command = new OleDbCommand(query, DataBaseManager.DbConnection))
            {
                DataBaseManager.DbConnection.Open();
                try
                {
                    command.ExecuteNonQuery();
                    query      = string.Format("ALTER TABLE {0} DROP CONSTRAINT PrimaryKey", table);
                    alterTable = true;
                }
                catch
                {
                    query = string.Format("CREATE TABLE {0} (Nombre Text NOT NULL, Periodo Integer NOT NULL, TurMinimo Double, TurMaximo Double, Filtracion Double, FactorRecuperacion Double, PRIMARY KEY (Nombre, Periodo))", table);
                }
                DataBaseManager.DbConnection.Close();
            }

            DataBaseManager.ExecuteQuery(query);

            if (alterTable)
            {
                query = string.Format("ALTER TABLE {0} ADD PRIMARY KEY (Nombre, Periodo)", table);
                DataBaseManager.ExecuteQuery(query);
                log.Info(MessageUtil.FormatMessage("INFO.PrimaryKeyAddedToTable", table));
            }
            else
            {
                log.Info(MessageUtil.FormatMessage("INFO.TableCreated", table));
            }
        }
Exemple #3
0
        public void CreatePlantsMappingTables()
        {
            List <string> tables = new List <string>()
            {
                "MapeoRecursosHidro",
                "MapeoRecursosTermicos"
            };

            foreach (string table in tables)
            {
                string query = string.Format("SELECT TOP 1 Planta FROM {0}", table);
                try
                {
                    OleDbDataReader reader = DataBaseManager.ReadData(query);
                }
                catch
                {
                    query = string.Format("CREATE TABLE {0} (Planta Text, Recurso Text)", table);
                    DataBaseManager.ExecuteQuery(query);
                    log.Info(MessageUtil.FormatMessage("INFO.TableCreated", table));
                }

                DataBaseManager.DbConnection.Close();
            }
        }
Exemple #4
0
        public static void DeleteRecursoBasica(RecursoBasica RecursoBasica)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} ", table, RecursoBasica.Name);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #5
0
        public void AddPrimaryKeyToPeriodsTable()
        {
            string table = "periodoBasica";

            string query = string.Format("ALTER TABLE {0} DROP CONSTRAINT PRIMARYKEY", table);

            DataBaseManager.ExecuteQuery(query);

            query = string.Format("ALTER TABLE {0} ADD PRIMARY KEY (nombre, escenario)", table);
            DataBaseManager.ExecuteQuery(query);

            /*
             * using (OleDbCommand command = new OleDbCommand(query, DataBaseManager.DbConnection))
             * {
             *  DataBaseManager.DbConnection.Open();
             *  try
             *  {
             *      command.ExecuteNonQuery();
             *  }
             *  catch
             *  {
             *      //TODO: Move to DBManager after testing
             *  }
             *  DataBaseManager.DbConnection.Close();
             * }
             */
            log.Info(MessageUtil.FormatMessage("INFO.PrimaryKeyAddedToTable", table));
        }
Exemple #6
0
        public static void DeleteZone(Zone dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Id = {1}", table, dataObject.Id);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #7
0
        public static void UpdateObject(ExcludingPlants dataObject)
        {
            string query = string.Format("INSERT INTO {0}(Recurso1, Recurso2) " +
                                         "VALUES('{1}', '{2}')", table, dataObject.Plant1, dataObject.Plant2);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #8
0
        public static void DeleteObject(NameMapping dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = '{1}'", table, dataObject.DHOGName);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #9
0
        public static void DeleteObject(ExcludingPlants dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Recurso1 = '{1}' AND Recurso2 = '{2}' ", table, dataObject.Plant1, dataObject.Plant2);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #10
0
        public static void DeleteObject(NonConventionalPlant dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Id = {1}", table, dataObject.Id);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #11
0
        public static void DeleteObject(RecursoFuelContract dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Id = {1}", table, dataObject.Id);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #12
0
        public static void DeleteObject(LineaBarra dataObject)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Nombre = {1}", table, dataObject.Nombre);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #13
0
        public static void DeleteAllPlantsFromZone(string zone)
        {
            string query = "DELETE FROM ZonaRecurso " +
                           "WHERE nombre = '" + zone + "' ";

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #14
0
        public static void UpdateObject(RutasDhogParameter dataObject)
        {
            string query = string.Format("UPDATE {0} SET " +
                                         "RutaModelo =  '{1}' " + ", RutaBD = '{3}'" + ", RutaEjecutable = '{4}'" + ", RutaSalida = '{5}'" + ", RutaSolver = '{6}'" +
                                         " WHERE ID = {2}", table, dataObject.RutaModelo, dataObject.Id, dataObject.RutaBD, dataObject.RutaEjecutable, dataObject.RutaSalida, dataObject.RutaSolver);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #15
0
        public static void UpdateObjectiveFuncion(int value)
        {
            string query = string.Format("UPDATE configuracionProblema " +
                                         "SET valor = {0} " +
                                         "WHERE nombre = 'MODELO'", value);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #16
0
        public static void UpdateIsIterative(int value)
        {
            string query = string.Format("UPDATE configuracionProblema " +
                                         "SET valor = {0} " +
                                         "WHERE nombre = 'ITERATIVO'", value);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #17
0
        public static void UpdateCaseDescription(string description)
        {
            string query = string.Format("UPDATE {0} " +
                                         "SET Descripcion = '{1}' " +
                                         "WHERE Id = 1", table, description);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #18
0
        public static void UpdateObject(ProblemConfigurationParameter dataObject)
        {
            string query = string.Format("UPDATE {0} SET " +
                                         "valor = {1} " +
                                         "WHERE nombre = '{2}'", table, dataObject.Value, dataObject.Name);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #19
0
        public static void DeletePlantFromZone(string zone, string plant)
        {
            string query = "DELETE FROM ZonaRecurso " +
                           "WHERE nombre = '" + zone + "' " +
                           "AND recurso = '" + plant + "' ";

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #20
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);
        }
Exemple #21
0
        public static void DeleteCorteLinea(CorteLinea CorteLinea)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Sentido = {2}",
                                         table, CorteLinea.Name, CorteLinea.Sentido);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #22
0
        public static void DeletePeriodicBlock(PeriodicBlock periodicBlock)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Periodo = {2}",
                                         table, periodicBlock.Block, periodicBlock.Period);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #23
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);
        }
Exemple #24
0
        public static void DeleteUnidadBarra(UnidadBarra UnidadBarra)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Barra = {2}",
                                         table, UnidadBarra.Nombre, UnidadBarra.Barra);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #25
0
        public static void DeleteRecursoUnidad(RecursoUnidad RecursoUnidad)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = {1} " +
                                         "AND Unidad = {2}",
                                         table, RecursoUnidad.Name, RecursoUnidad.Unidad);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #26
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);
        }
Exemple #27
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);
        }
Exemple #28
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);
        }
Exemple #29
0
        public static void DeletePeriodicArea(PeriodicArea periodicArea)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE nombre = '{1}' " +
                                         "AND Periodo = {2}",
                                         table, periodicArea.Name, periodicArea.Period);

            DataBaseManager.ExecuteQuery(query);
        }
Exemple #30
0
        public static void DeletePeriodicHydroElement(PeriodicHydroElement periodicHydroElement)
        {
            string query = string.Format("DELETE FROM {0} " +
                                         "WHERE Nombre = '{1}' " +
                                         "AND Periodo = {2} ",
                                         table, periodicHydroElement.Name, periodicHydroElement.Period);

            DataBaseManager.ExecuteQuery(query);
        }