public SeriesList CreateSelectedSeries(string[] selectedScenarios, DataTable tblSelection) { TimeSeries.SeriesList rval = new TimeSeries.SeriesList(); if (tblSelection == null || tblSelection.Rows.Count == 0) { return(rval); } DataTable selected = EnumerateSelections(tblSelection, selectedScenarios); for (int i = 0; i < selected.Rows.Count; i++) { DataRow row = selected.Rows[i]; string dataSource = row["DataSource"].ToString().Trim(); if (dataSource == "") { continue; } int idx = DatabaseList.ScenarioNames.IndexOf(dataSource); if (idx < 0) { throw new NotSupportedException(dataSource + " is not defined in the config file.\nPlease check your tree.csv and connection strings in your config file"); } if (!DatabaseList[idx].ValidRow(row)) { continue; } TimeSeries.Series s = DatabaseList[idx].CreateSeries(row); s.ScenarioName = dataSource; //Console.WriteLine("s.ScenarioName "+ s.ScenarioName); rval.Add(s); } return(rval); }
internal SeriesList CreateSelectedSeries() { Logger.WriteLine("Begin CreateSelectedSeries()"); TimeSeries.SeriesList rval = new TimeSeries.SeriesList(); var selScenarios = m_db.GetSelectedScenarios(); Logger.WriteLine("There are " + m_selectedSeries.Length + " series selected"); Logger.WriteLine("There are " + selScenarios.Rows.Count + " scenarios selected"); for (int i = 0; i < m_selectedSeries.Length; i++) { Series s = m_selectedSeries[i]; Logger.WriteLine("Series [" + i + "] " + s.Name); Logger.WriteLine(" ScenarioName: " + s.ScenarioName); if (s.ScenarioName == "" || (selScenarios.Rows.Count == 0 && !IncludeBaseline)) { Logger.WriteLine("Not using Scenario. Either blank scenario name, or no scenarios (unless baseline selected)"); rval.Add(s); } else if (selScenarios.Rows.Count == 0 && IncludeBaseline) { // baseline only. Logger.WriteLine("Not using Scenario. baseline only"); var baseline = s.CreateBaseline(); if (!baseline.SiteID.Contains("reference")) { baseline.SiteID += " - reference"; } rval.Add(baseline); } else// Using Scenarios. { Logger.WriteLine("Using scenarios"); Series baseline = null; foreach (var sn in selScenarios) { Series scenario = s.CreateScenario(sn); Logger.WriteLine("Scenario: " + scenario.ScenarioName); if (baseline == null && (IncludeBaseline || SubtractFromBaseline)) { baseline = s.CreateBaseline(); } if (SubtractFromBaseline) { SubtractSeries impact = new SubtractSeries(scenario, baseline); impact.Name = scenario.Name + " - " + baseline.Name; impact.Appearance.LegendText = "(" + scenario.Appearance.LegendText + ") - (" + baseline.Appearance.LegendText + ")"; impact.SiteID = baseline.SiteID; rval.Add(impact); if (IncludeSelected) { rval.Add(scenario); } } else { rval.Add(scenario); } } if (IncludeBaseline && baseline != null) { rval.Add(baseline); } } } Logger.WriteLine("Finish CreateSelectedSeries()"); return(rval); }
internal SeriesList CreateSelectedSeries() { TimeSeries.SeriesList rval = new TimeSeries.SeriesList(); var selScenarios = m_db.GetSelectedScenarios(); for (int i = 0; i < m_selectedSeries.Length; i++) { Series s = m_selectedSeries[i]; if (s.ScenarioName == "" || (selScenarios.Rows.Count == 0 && !IncludeBaseline)) { rval.Add(s); } else if (selScenarios.Rows.Count == 0 && IncludeBaseline) { // baseline only. var baseline = s.CreateBaseline(); if (!baseline.SiteID.Contains("reference")) { baseline.SiteID += " - reference"; } rval.Add(baseline); } else// Using Scenarios. { Series baseline = null; foreach (var sn in selScenarios) { Series scenario = s.CreateScenario(sn); if (baseline == null && (IncludeBaseline || SubtractFromBaseline)) { baseline = s.CreateBaseline(); } if (SubtractFromBaseline) { SubtractSeries impact = new SubtractSeries(scenario, baseline); impact.Name = scenario.Name + " - " + baseline.Name; impact.Appearance.LegendText = "(" + scenario.Appearance.LegendText + ") - (" + baseline.Appearance.LegendText + ")"; impact.SiteID = baseline.SiteID; rval.Add(impact); if (IncludeSelected) { rval.Add(scenario); } } else { rval.Add(scenario); } } if (IncludeBaseline && baseline != null) { rval.Add(baseline); } } } return(rval); }
public SeriesList CreateSelectedSeries(string[] selectedScenarios, DataTable tblSelection) { TimeSeries.SeriesList rval = new TimeSeries.SeriesList(); if (tblSelection == null || tblSelection.Rows.Count == 0) { return rval; } DataTable selected = EnumerateSelections(tblSelection, selectedScenarios); for (int i = 0; i < selected.Rows.Count; i++) { DataRow row = selected.Rows[i]; string dataSource = row["DataSource"].ToString().Trim(); if (dataSource == "") { continue; } int idx = DatabaseList.ScenarioNames.IndexOf(dataSource); if (idx < 0) { throw new NotSupportedException(dataSource + " is not defined in the config file.\nPlease check your tree.csv and connection strings in your config file"); } if (!DatabaseList[idx].ValidRow(row)) { continue; } TimeSeries.Series s = DatabaseList[idx].CreateSeries(row); s.ScenarioName = dataSource; //Console.WriteLine("s.ScenarioName "+ s.ScenarioName); rval.Add(s); } return rval; }