示例#1
0
 void btnAdd_Click(object sender, EventArgs e)
 {
     Mersim mersim = new Mersim(fileDialog.FileName);
     mersim.readFile();
     Model tmpModel = new Model();
     tmpModel.addNewStudy(name, Convert.ToDateTime(date), mersim);
     this.Close();
     MessageBox.Show("Дослідженя успішно додано!","Додавання завершено",MessageBoxButton.OK,MessageBoxImage.Information);
 }
示例#2
0
 public Mersim getDataForHydrocondition(int idStudy, int year, int period, string hydrocondition)
 {
     Model model = new Model();
     int hydroconditionId = getHydroconditionId(hydrocondition);
     IDataReader dataTotal = model.getScenario(idStudy, year, period, hydroconditionId);
     IDataReader dataThermal = model.getThermalDataForScenario(idStudy, year, period, hydroconditionId);
     IDataReader dataHydro = model.getHydroDataForScenario(idStudy, year, period, hydroconditionId);
     Mersim mersimOne = new Mersim(dataTotal, dataThermal, dataHydro);
     return mersimOne;
 }
示例#3
0
        void btnAdd_Click(object sender, EventArgs e)
        {
            Mersim mersim = new Mersim(fileDialog.FileName);

            mersim.readFile();
            Model tmpModel = new Model();

            tmpModel.addNewStudy(name, Convert.ToDateTime(date), mersim);
            this.Close();
            MessageBox.Show("Дослідженя успішно додано!", "Додавання завершено", MessageBoxButton.OK, MessageBoxImage.Information);
        }
示例#4
0
文件: Model.cs 项目: almarkua/Wasp
        public void addNewStudy(string name, DateTime date,Mersim mersimObj)
        {
            try
            {
                string tmpDate = date.ToString("yyyy-M-d");
                string query = String.Format("insert into study (name,date) values('{0}','{1}');", name, date.ToString("yyyy-M-d"));
                DB.getInstance().executeNonQuery(query);

                IDataReader result = DB.getInstance().execute("select @@IDENTITY from study");
                result.Read();
                object tmp = result.GetValue(0);
                int identityStudy = int.Parse(tmp.ToString());

                for (int i = 0; i < mersimObj.thermalData.Count; i++) {
                    query = String.Format(@"insert into scenario (total_capacity,peak_load,minimum_load,maintenance_space,reserve_capacity,total_generation,energy_demand,unserved_energy,energy_balance,loss_of_load,energy_pumped,period,year,id_study,hydrocondition,probality) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", mersimObj.totalCapacity[i].ToString().Replace(',', '.'), mersimObj.peakLoad[i].ToString().Replace(',', '.'), mersimObj.minimumLoad[i].ToString().Replace(',', '.'), mersimObj.maintenanceSpace[i].ToString().Replace(',', '.'), mersimObj.reserveCapacity[i].ToString().Replace(',', '.'), mersimObj.totalGeneration[i].ToString().Replace(',', '.'), mersimObj.energyDemand[i].ToString().Replace(',', '.'), mersimObj.unservedEnergy[i].ToString().Replace(',', '.'), mersimObj.energyBalance[i].ToString().Replace(',', '.'), mersimObj.lossOfLoadProbability[i].ToString().Replace(',', '.'), mersimObj.energyPumped[i].ToString().Replace(',', '.'), mersimObj.period[i], mersimObj.year[i], identityStudy, mersimObj.hydrocondition[i].ToString().Replace(',', '.'), mersimObj.probality[i].ToString().Replace(',', '.'));
                    DB.getInstance().executeNonQuery(query);
                    result = DB.getInstance().execute("select @@IDENTITY from scenario");
                    result.Read();
                    int identityScenario = int.Parse(result.GetValue(0).ToString());
                    for (int j=0;j<mersimObj.thermalData[i].Rows.Count;j++) {
                        query = String.Format("insert into thermal_plants (id_scenario,plant_name,number_of_units,unit_base,total_capacity,plant_capacity,base_energy,peak_energy,total_energy,fuel_domestic,fuel_foreign,fuel_total,om_domestic,main_probality,for_cell,capacity_factor) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", identityScenario, mersimObj.thermalData[i].Rows[j].Field<string>(0), int.Parse(mersimObj.thermalData[i].Rows[j].Field<double>(1).ToString()), mersimObj.thermalData[i].Rows[j].Field<double>(2).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(3).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(4).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(5).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(6).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(7).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(8).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(9).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(10).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(11).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(12).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(13).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field<double>(14).ToString().Replace(',', '.'));
                        DB.getInstance().executeNonQuery(query);
                    }
                    for (int j = 0; j < mersimObj.hydroData[i].Rows.Count; j++)
                    {
                        query = String.Format("insert into hydro_plants (idscenario,name,number_of_units,lord_pos_pl,u,base_capacity,peak_capacity,total_capacity,base_energy,peak_energy,total_energy,peak_mineng,energy_spilled,energy_shortage,om_local,capacity_factor) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", identityScenario, mersimObj.hydroData[i].Rows[j].Field<string>(0), mersimObj.hydroData[i].Rows[j].Field<double>(1).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(2).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(3).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(4).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(5).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(6).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(7).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(8).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(9).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(10).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(11).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(12).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(13).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field<double>(14).ToString().Replace(',', '.'));
                        DB.getInstance().executeNonQuery(query);
                    }
                }

                result = DB.getInstance().execute("select count(*) from hydro_plants");
                result.Read();
                tmp = result.GetValue(0);

                return;
            }
            catch (Exception ex) {
                MessageBox.Show("Помилка додавання нового дослідження в базу даних!"+ex.Message);
            }
        }