public static DataTable ReadSINGeneration(int scenario, SINGenerationType generationType) { string table = null; switch (generationType) { case SINGenerationType.Daily: table = "zz_ReporteGeneracion_dia"; break; case SINGenerationType.Hourly: table = "zz_ReporteGeneracion_hora"; break; case SINGenerationType.Period: table = "zz_ReporteGeneracion"; break; } DataTable dataTable = new DataTable(); string formato = string.Format((Char)(34) + "##.00" + (Char)(34)); string query = string.Format("SELECT Periodo, racionamiento, GMenor, GEolica, GGeotermia, GSolar, GBiomasa, GCarbon, GGas, GFuel, GHidro, Demanda " + "FROM {0} " + "WHERE Escenario = {1}", table, scenario); OleDbDataAdapter adapter = new OleDbDataAdapter(query, DataBaseManager.OutputDbConnection); try { adapter.Fill(dataTable); } catch (Exception e) { Console.WriteLine(e.StackTrace); } return(dataTable); }
public SINGenerationChart(SINGenerationType generationType, int tipo) { this.generationType = generationType; tipografico = tipo; seriesColors = new List <Color> { Colors.Red, Colors.Gray, Colors.PapayaWhip, Colors.Purple, Colors.Yellow, Colors.HotPink, Colors.Black, Colors.LimeGreen, Colors.Orange, Color.FromRgb(138, 186, 212), Colors.Black, Colors.Red }; switch (generationType) { case SINGenerationType.Daily: VerticalAxis.Title = "GWh-día"; break; case SINGenerationType.Hourly: VerticalAxis.Title = "MWh-hora"; break; case SINGenerationType.Period: VerticalAxis.Title = "GWh / Etapa"; break; } }
public static List <DataSeriesViewModel> GetSINGenerationDataSeries(int scenario, SINGenerationType generationType) { ObservableCollection <ChartDataPoint> dataPoints; DataSeriesViewModel dataSeries; List <DataSeriesViewModel> dataSeriesList = new List <DataSeriesViewModel>(); DataTable dataTable = ResultsReader.ReadSINGeneration(scenario, generationType); for (int i = 1; i < dataTable.Columns.Count; i++) { DataColumn column = dataTable.Columns[i]; dataPoints = new ObservableCollection <ChartDataPoint>(); foreach (DataRow row in dataTable.Rows) { int period = Convert.ToInt32(row[0]); string periodDate = ""; if (period <= DHOGDataBaseViewModel.PeriodsDate.GetLength(0)) { periodDate = DHOGDataBaseViewModel.PeriodsDate[period - 1]; } else { throw new Exception(MessageUtil.FormatMessage("ERROR.ChartDateNotFound", "Generación SIN", period)); } dataPoints.Add(new ChartDataPoint(periodDate, Convert.ToDouble(row[column]))); } dataSeries = new DataSeriesViewModel(column.ColumnName, dataPoints); dataSeriesList.Add(dataSeries); } dataTable = ResultsReader.ReadMarginalCost(scenario); dataPoints = new ObservableCollection <ChartDataPoint>(); foreach (DataRow row in dataTable.Rows) { int period = Convert.ToInt32(row[0]); string periodDate = ""; if (period <= DHOGDataBaseViewModel.PeriodsDate.GetLength(0)) { periodDate = DHOGDataBaseViewModel.PeriodsDate[period - 1]; } else { throw new Exception(MessageUtil.FormatMessage("ERROR.ChartDateNotFound", "Generación SIN", period)); } dataPoints.Add(new ChartDataPoint(periodDate, Convert.ToDouble(row[1]))); } dataSeries = new DataSeriesViewModel(dataTable.Columns[1].ColumnName, dataPoints); dataSeriesList.Add(dataSeries); return(dataSeriesList); }