diff --git a/HEC.FDA.Model/alternatives/Alternative.cs b/HEC.FDA.Model/alternatives/Alternative.cs index fc9e3d94a..d70d1be61 100644 --- a/HEC.FDA.Model/alternatives/Alternative.cs +++ b/HEC.FDA.Model/alternatives/Alternative.cs @@ -84,7 +84,7 @@ private AlternativeResults RunAnnualizationCompute(List analysisYears, doub { //To keep track of which results have yet to be processed //I think this allows us to handle situations where we have uneven numbers of results - List futureYearResultsList = new(); + List futureYearResultsList = new(); foreach (ImpactAreaScenarioResults futureYearImpactAreaScenarioResults in computedResultsFutureYear.ResultsList.Cast()) { futureYearResultsList.Add(futureYearImpactAreaScenarioResults); @@ -114,7 +114,7 @@ private AlternativeResults RunAnnualizationCompute(List analysisYears, doub return alternativeResults; } - private double ProcessBaseAndFutureYearScenarioResults(List analysisYears, double discountRate, int periodOfAnalysis, ScenarioResults computedResultsBaseYear, ScenarioResults computedResultsFutureYear, AlternativeResults alternativeResults, List futureYearResultsList, double quantityOFDamCatAssetCatImpactAreaCombos) + private double ProcessBaseAndFutureYearScenarioResults(List analysisYears, double discountRate, int periodOfAnalysis, ScenarioResults computedResultsBaseYear, ScenarioResults computedResultsFutureYear, AlternativeResults alternativeResults, List futureYearResultsList, double quantityOFDamCatAssetCatImpactAreaCombos) { double progressTicker = 0; foreach (ImpactAreaScenarioResults baseYearResults in computedResultsBaseYear.ResultsList.Cast()) @@ -190,7 +190,7 @@ private double ProcessBaseAndFutureYearScenarioResults(List analysisYears, private void ProcessUnmatchedFutureResults(List analysisYears, double discountRate, int periodOfAnalysis, ScenarioResults computedResultsBaseYear, AlternativeResults alternativeResults, - List futureYearResultsList, CancellationToken cancellationToken) + List futureYearResultsList, CancellationToken cancellationToken) { foreach (ImpactAreaScenarioResults futureYearResults in futureYearResultsList.Cast()) { diff --git a/HEC.FDA.Model/compute/ImpactAreaScenarioSimulation.cs b/HEC.FDA.Model/compute/ImpactAreaScenarioSimulation.cs index 33cebb882..1ad3adc67 100644 --- a/HEC.FDA.Model/compute/ImpactAreaScenarioSimulation.cs +++ b/HEC.FDA.Model/compute/ImpactAreaScenarioSimulation.cs @@ -981,7 +981,7 @@ public static ImpactAreaScenarioSimulation ReadFromXML(XElement xElement) GraphicalUncertainPairedData frequencyStage = GraphicalUncertainPairedData.ReadFromXML(xElement.Element(FREQUENCY_STAGE_ELEMENT_NAME)); UncertainPairedData interiorExterior = UncertainPairedData.ReadFromXML(xElement.Element(INTERIOR_EXTERIOR_ELEMENT_NAME)); UncertainPairedData systemResponse = UncertainPairedData.ReadFromXML(xElement.Element(SYSTEM_RESPONSE_ELEMENT_NAME)); - IContainImpactAreaScenarioResults impactAreaScenarioResults = ImpactAreaScenarioResults.ReadFromXML(xElement.Element(IMPACT_AREA_SCENARIO_RESULTS_ELEMENT_NAME)); + ImpactAreaScenarioResults impactAreaScenarioResults = ImpactAreaScenarioResults.ReadFromXML(xElement.Element(IMPACT_AREA_SCENARIO_RESULTS_ELEMENT_NAME)); List stageDamageList = new(); foreach (XElement stageDamageElement in xElement.Element(STAGE_DAMAGE_LIST_ELEMENT_NAME).Elements()) { diff --git a/HEC.FDA.Model/metrics/IContainImpactAreaScenarioResults.cs b/HEC.FDA.Model/metrics/IContainImpactAreaScenarioResults.cs deleted file mode 100644 index 12501e27b..000000000 --- a/HEC.FDA.Model/metrics/IContainImpactAreaScenarioResults.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace HEC.FDA.Model.metrics -{ - public interface IContainImpactAreaScenarioResults - { - PerformanceByThresholds PerformanceByThresholds { get; } - StudyAreaConsequencesBinned ConsequenceResults { get; } - int ImpactAreaID { get; } - bool Equals(ImpactAreaScenarioResults incomingIContainResults); - } -} \ No newline at end of file diff --git a/HEC.FDA.Model/metrics/ImpactAreaScenarioResults.cs b/HEC.FDA.Model/metrics/ImpactAreaScenarioResults.cs index 6e076a1e6..4b3e1c973 100644 --- a/HEC.FDA.Model/metrics/ImpactAreaScenarioResults.cs +++ b/HEC.FDA.Model/metrics/ImpactAreaScenarioResults.cs @@ -8,7 +8,7 @@ namespace HEC.FDA.Model.metrics { - public class ImpactAreaScenarioResults : IContainImpactAreaScenarioResults + public class ImpactAreaScenarioResults { #region Properties public PerformanceByThresholds PerformanceByThresholds { get; set; } //exposed publicly for testing @@ -40,7 +40,6 @@ private ImpactAreaScenarioResults(PerformanceByThresholds performanceByThreshold IsNull = false; } #endregion - #region Methods public double MeanAEP(int thresholdID) { diff --git a/HEC.FDA.Model/metrics/ScenarioResults.cs b/HEC.FDA.Model/metrics/ScenarioResults.cs index 6b8580348..a5c2530b3 100644 --- a/HEC.FDA.Model/metrics/ScenarioResults.cs +++ b/HEC.FDA.Model/metrics/ScenarioResults.cs @@ -21,7 +21,7 @@ public class ScenarioResults : ValidationErrorLogger public string ComputeDate { get; set; } public string SoftwareVersion { get; set; } - public List ResultsList { get; } = new List(); + public List ResultsList { get; } = new List(); #endregion @@ -38,7 +38,7 @@ public List GetImpactAreaIDs() List impactAreaIDs = new(); if (ResultsList.Count != 0) { - foreach (IContainImpactAreaScenarioResults containImpactAreaScenarioResults in ResultsList) + foreach (ImpactAreaScenarioResults containImpactAreaScenarioResults in ResultsList) { foreach (AggregatedConsequencesBinned consequenceResult in containImpactAreaScenarioResults.ConsequenceResults.ConsequenceResultList) { @@ -57,7 +57,7 @@ public List GetAssetCategories() List assetCats = new(); if (ResultsList.Count != 0) { - foreach (IContainImpactAreaScenarioResults containImpactAreaScenarioResults in ResultsList) + foreach (ImpactAreaScenarioResults containImpactAreaScenarioResults in ResultsList) { foreach (AggregatedConsequencesBinned consequenceResult in containImpactAreaScenarioResults.ConsequenceResults.ConsequenceResultList) { @@ -77,7 +77,7 @@ public List GetDamageCategories() List damCats = new(); if (ResultsList.Count != 0) { - foreach (IContainImpactAreaScenarioResults containImpactAreaScenarioResults in ResultsList) + foreach (ImpactAreaScenarioResults containImpactAreaScenarioResults in ResultsList) { foreach (AggregatedConsequencesBinned consequenceResult in containImpactAreaScenarioResults.ConsequenceResults.ConsequenceResultList) { @@ -356,7 +356,7 @@ public Empirical GetConsequencesDistribution(int impactAreaID = utilities.Intege return Empirical.StackEmpiricalDistributions(empiricalDistsToStack, Empirical.Sum); } } - public void AddResults(IContainImpactAreaScenarioResults resultsToAdd) + public void AddResults(ImpactAreaScenarioResults resultsToAdd) { ResultsList.Add(resultsToAdd); } @@ -423,7 +423,7 @@ public static ScenarioResults ReadFromXML(XElement xElement) foreach (XElement element in xElement.Elements()) { - IContainImpactAreaScenarioResults impactAreaScenarioResults = ImpactAreaScenarioResults.ReadFromXML(element); + ImpactAreaScenarioResults impactAreaScenarioResults = ImpactAreaScenarioResults.ReadFromXML(element); scenarioResults.AddResults(impactAreaScenarioResults); } diff --git a/HEC.FDA.Model/utilities/IntegerGlobalConstants.cs b/HEC.FDA.Model/utilities/IntegerGlobalConstants.cs index 073b737ee..3b88e098f 100644 --- a/HEC.FDA.Model/utilities/IntegerGlobalConstants.cs +++ b/HEC.FDA.Model/utilities/IntegerGlobalConstants.cs @@ -1,6 +1,6 @@ namespace HEC.FDA.Model.utilities { - internal class IntegerGlobalConstants + public class IntegerGlobalConstants { public const int DEFAULT_MISSING_VALUE = -999; } diff --git a/HEC.FDA.View/AlternativeComparisonReport/Results/SummaryResults.xaml b/HEC.FDA.View/AlternativeComparisonReport/Results/SummaryResults.xaml index a4f6a0672..0c5430c13 100644 --- a/HEC.FDA.View/AlternativeComparisonReport/Results/SummaryResults.xaml +++ b/HEC.FDA.View/AlternativeComparisonReport/Results/SummaryResults.xaml @@ -1,191 +1,192 @@  - + xmlns:results="clr-namespace:HEC.FDA.ViewModel.AlternativeComparisonReport.Results;assembly=HEC.FDA.ViewModel" + d:DataContext="{d:DesignInstance Type=results:SummaryVM}" + d:DesignHeight="450" + d:DesignWidth="800"> + + + - - - - - - - + + + + + + + - - + + + + + diff --git a/HEC.FDA.View/AlternativeComparisonReport/Results/SummaryResults.xaml.cs b/HEC.FDA.View/AlternativeComparisonReport/Results/SummaryResults.xaml.cs index 1d36f85f4..958671142 100644 --- a/HEC.FDA.View/AlternativeComparisonReport/Results/SummaryResults.xaml.cs +++ b/HEC.FDA.View/AlternativeComparisonReport/Results/SummaryResults.xaml.cs @@ -24,5 +24,14 @@ public SummaryResults() { InitializeComponent(); } + + private void FdaDataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) + { + if (e.PropertyType == typeof(double) || e.PropertyType == typeof(double?)) + { + (e.Column as DataGridTextColumn).Binding.StringFormat = "C2"; + } + + } } } diff --git a/HEC.FDA.View/Alternatives/Results/BatchCompute/AlternativeSummaryTable.xaml b/HEC.FDA.View/Alternatives/Results/BatchCompute/AlternativeSummaryTable.xaml index 99093b31b..9c33417fb 100644 --- a/HEC.FDA.View/Alternatives/Results/BatchCompute/AlternativeSummaryTable.xaml +++ b/HEC.FDA.View/Alternatives/Results/BatchCompute/AlternativeSummaryTable.xaml @@ -1,112 +1,74 @@  - + xmlns:twp="clr-namespace:HEC.FDA.View.TableWithPlot" + xmlns:batchcompute="clr-namespace:HEC.FDA.ViewModel.Alternatives.Results.BatchCompute;assembly=HEC.FDA.ViewModel" + d:DataContext="{d:DesignInstance Type=batchcompute:AlternativeSummaryVM}" + mc:Ignorable="d" + d:DesignHeight="450" + d:DesignWidth="800"> + + + + - - - + + + - - - - - - - - - - - - - - - + + + + + + + - - - - - - - - - - - + + + + + + + + - - - - - - - - + + - - - - Q1 - - - - - - - Q2 - - - - - - - Q3 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/HEC.FDA.View/Alternatives/Results/BatchCompute/AlternativeSummaryTable.xaml.cs b/HEC.FDA.View/Alternatives/Results/BatchCompute/AlternativeSummaryTable.xaml.cs index 5f721c61c..cbdc5c983 100644 --- a/HEC.FDA.View/Alternatives/Results/BatchCompute/AlternativeSummaryTable.xaml.cs +++ b/HEC.FDA.View/Alternatives/Results/BatchCompute/AlternativeSummaryTable.xaml.cs @@ -24,5 +24,13 @@ public AlternativeSummaryTable() { InitializeComponent(); } + + private void FdaDataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) + { + if (e.PropertyType == typeof(double) || e.PropertyType == typeof(double?)) + { + (e.Column as DataGridTextColumn).Binding.StringFormat = "C2"; + } + } } } diff --git a/HEC.FDA.View/Results/ScenarioDamageSummary.xaml b/HEC.FDA.View/Results/ScenarioDamageSummary.xaml index 1a0173ef2..c5be8c363 100644 --- a/HEC.FDA.View/Results/ScenarioDamageSummary.xaml +++ b/HEC.FDA.View/Results/ScenarioDamageSummary.xaml @@ -1,279 +1,400 @@  - - - - - - - - - + xmlns:results="clr-namespace:HEC.FDA.ViewModel.Results;assembly=HEC.FDA.ViewModel" + d:DataContext="{d:DesignInstance Type=results:ScenarioDamageSummaryVM}" + mc:Ignorable="d" + d:DesignHeight="450" + d:DesignWidth="800"> + + + + + + + + + + + + - - - - - + + + + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Q1 - - - - - - - Q2 - - - - - - - Q3 - - - - - - - + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + diff --git a/HEC.FDA.View/Results/ScenarioDamageSummary.xaml.cs b/HEC.FDA.View/Results/ScenarioDamageSummary.xaml.cs index dfebc23ba..e50fd381d 100644 --- a/HEC.FDA.View/Results/ScenarioDamageSummary.xaml.cs +++ b/HEC.FDA.View/Results/ScenarioDamageSummary.xaml.cs @@ -11,5 +11,14 @@ public ScenarioDamageSummary() { InitializeComponent(); } + + private void FdaDataGrid_AutoGeneratingColumn(object sender, DataGridAutoGeneratingColumnEventArgs e) + { + if (e.PropertyType == typeof(double) || e.PropertyType == typeof(double?)) + { + (e.Column as DataGridTextColumn).Binding.StringFormat = "C2"; + } + + } } } diff --git a/HEC.FDA.View/TableWithPlot/FdaDataGrid.cs b/HEC.FDA.View/TableWithPlot/FdaDataGrid.cs index 9fcef4826..164868801 100644 --- a/HEC.FDA.View/TableWithPlot/FdaDataGrid.cs +++ b/HEC.FDA.View/TableWithPlot/FdaDataGrid.cs @@ -212,7 +212,7 @@ private void InsertRowItemsBelow(object sender, RoutedEventArgs e) PreviewAddRows?.Invoke(this, EventArgs.Empty); List UniqueRows = GetSelectedRows(); Int32 InsertAtRow = UniqueRows.Min(); - RowsAdded?.Invoke(this,new RowsAddedEventArgs(InsertAtRow + 1, UniqueRows.Count)); + RowsAdded?.Invoke(this, new RowsAddedEventArgs(InsertAtRow + 1, UniqueRows.Count)); } public Int32 GetSelectedIndex() @@ -359,7 +359,8 @@ public void PasteClipboard() var newVal = Convert.ChangeType(clipboardData[i][j], y.PropertyType); ((SequentialRow)Items[RowIndex + i]).UpdateRow(ColumnIndex + j, (double)newVal); } - catch { + catch + { //ignore } } @@ -434,40 +435,42 @@ private void myDataGrid_AutoGeneratingColumn(object sender, DataGridAutoGenerati e.Cancel = true; if (e.Column.GetType() == typeof(DataGridTextColumn)) { - DataGridTextColumn dgtc = (DataGridTextColumn)e.Column; - FdaDataGrid sndr = sender as FdaDataGrid; + DataGridTextColumn dataGridtextColumn = (DataGridTextColumn)e.Column; + FdaDataGrid dataGrid = sender as FdaDataGrid; bool cancel = true; - if (sndr != null) + if (dataGrid != null) { - PropertyInfo[] pilist = sndr.Items.CurrentItem.GetType().GetProperties(); + PropertyInfo[] pilist = dataGrid.Items.CurrentItem.GetType().GetProperties(); foreach (PropertyInfo pi in pilist) { - if ( pi.Name == e.PropertyName) + if (pi.Name == e.PropertyName) { - DisplayAsColumnAttribute dna = (DisplayAsColumnAttribute)pi.GetCustomAttribute(typeof(DisplayAsColumnAttribute)); - if (dna != null) + DisplayAsColumnAttribute DisplayAsColAttribute = (DisplayAsColumnAttribute)pi.GetCustomAttribute(typeof(DisplayAsColumnAttribute)); + if (DisplayAsColAttribute != null) { - Console.WriteLine(dna.DisplayName); - dgtc.Header = dna.DisplayName; + dataGridtextColumn.Header = DisplayAsColAttribute.DisplayName; cancel = false; } } - + } } e.Cancel = cancel; - if (cancel) {return;} + if (cancel) { return; } - dgtc.Width = new DataGridLength(1, DataGridLengthUnitType.Star); + dataGridtextColumn.Width = new DataGridLength(1, DataGridLengthUnitType.Auto); Style ers = (Style)Resources["errorStyle"]; Style ersG = (Style)Resources["errorStyleGrid"]; - dgtc.EditingElementStyle = ers; - dgtc.ElementStyle = ersG; - Binding b = (Binding)dgtc.Binding; - b.UpdateSourceTrigger = UpdateSourceTrigger.LostFocus; - b.ValidatesOnNotifyDataErrors = true; + dataGridtextColumn.EditingElementStyle = ers; + dataGridtextColumn.ElementStyle = ersG; + Binding binding = (Binding)dataGridtextColumn.Binding; + binding.UpdateSourceTrigger = UpdateSourceTrigger.LostFocus; + binding.ValidatesOnNotifyDataErrors = true; //TODO: This approach fixes all of the data grid columns to the same format. I think we could use a way to access the format of certain columns. - b.StringFormat = ViewModel.Utilities.StringConstants.DETAILED_DECIMAL_FORMAT; + if (e.PropertyType == typeof(double) || e.PropertyType == typeof(double?)) + { + binding.StringFormat = ViewModel.Utilities.StringConstants.DETAILED_DECIMAL_FORMAT; + } } } } diff --git a/HEC.FDA.ViewModel/AlternativeComparisonReport/AlternativeComparisonReportElement.cs b/HEC.FDA.ViewModel/AlternativeComparisonReport/AlternativeComparisonReportElement.cs index e870e042c..727062ba5 100644 --- a/HEC.FDA.ViewModel/AlternativeComparisonReport/AlternativeComparisonReportElement.cs +++ b/HEC.FDA.ViewModel/AlternativeComparisonReport/AlternativeComparisonReportElement.cs @@ -4,10 +4,12 @@ using HEC.FDA.ViewModel.Alternatives.Results; using HEC.FDA.ViewModel.Alternatives.Results.ResultObject; using HEC.FDA.ViewModel.Compute; +using HEC.FDA.ViewModel.ImpactAreaScenario; using HEC.FDA.ViewModel.Study; using HEC.FDA.ViewModel.Utilities; using System; using System.Collections.Generic; +using System.Data.Entity.Core.Common.CommandTrees.ExpressionBuilder; using System.Linq; using System.Windows; using System.Xml.Linq; @@ -30,7 +32,7 @@ public class AlternativeComparisonReportElement : ChildElement #endregion - public AlternativeComparisonReportElement(string name, string desc, string creationDate, int withoutProjectAltId, List withProjAlternativeIds, int id) + public AlternativeComparisonReportElement(string name, string desc, string creationDate, int withoutProjectAltId, List withProjAlternativeIds, int id) : base(name, creationDate, desc, id) { WithoutProjAltID = withoutProjectAltId; @@ -67,7 +69,7 @@ public AlternativeComparisonReportElement(XElement altElement, int id) : base(al viewResults.Action = ComputeAltCompReport; Actions.Insert(1, viewResults); - } + } public override XElement ToXML() { @@ -127,7 +129,7 @@ public void ComputeAltCompReport(object arg1, EventArgs arg2) string header = "Compute Log For Alternative Comp Report: " + Name; DynamicTabVM tab = new DynamicTabVM(header, compVM, "ComputeLogAltCompReport" + Name); Navigate(tab, false, false); - } + } } private void ComputeCompleted(AlternativeComparisonReportResults results) @@ -157,111 +159,197 @@ public void ViewResults() private List CreateResults() { - List < SpecificAltCompReportResultsVM > results = new List < SpecificAltCompReportResultsVM >(); + List results = new(); List aAEQSummaryRowItems = CreateAAEQSummaryTable(_Results); List eADBaseSummaryRowItems = CreateEADBaseYearSummaryTable(_Results); List eADFutureSummaryRowItems = CreateEADFutureYearSummaryTable(_Results); + + List aAEQAggregatedSummaryRowItems = CreateAggregatedAAEQSummaryTable(_Results); + List eADAggregatedSummaryRowItems = CreateAggregatedEADFutureYearSummaryTable(_Results); + List eADAggregatedBaseSummaryRowItems = CreateAggregatedEADBaseYearSummaryTable(_Results); foreach (int altID in WithProjAltIDs) { - SpecificAltCompReportResultsVM specificAltCompReportResultsVM = CreateAlternativeComparisonResult(altID, GetAlternativeElementFromID(altID).Name, eADBaseSummaryRowItems, eADFutureSummaryRowItems, aAEQSummaryRowItems); + SpecificAltCompReportResultsVM specificAltCompReportResultsVM = CreateAlternativeComparisonResult(altID, GetAlternativeElementFromID(altID).Name); results.Add(specificAltCompReportResultsVM); } - SpecificAltCompReportResultsVM summaryOption = new SummaryVM(eADBaseSummaryRowItems, eADFutureSummaryRowItems, aAEQSummaryRowItems, _Results.Years); + SpecificAltCompReportResultsVM summaryOption = new SummaryVM(eADBaseSummaryRowItems, eADFutureSummaryRowItems, aAEQSummaryRowItems, eADAggregatedBaseSummaryRowItems, eADAggregatedSummaryRowItems, aAEQAggregatedSummaryRowItems, _Results.Years); results.Add(summaryOption); return results; + } - + private List CreateEADFutureYearSummaryTable(AlternativeComparisonReportResults results) { - List eadSummaryRowItems = new List(); - + List eadSummaryRowItems = new(); + Dictionary impactAreaNames = IASElement.GetImpactAreaNamesFromIDs(); string withoutProjName = GetAlternativeElementFromID(WithoutProjAltID).Name; - - double eadWithoutProjDamage = results.MeanWithoutProjectFutureYearEAD(); + foreach (int altID in WithProjAltIDs) { string withProjName = GetAlternativeElementFromID(altID).Name; + foreach (int impactAreaID in results.GetImpactAreaIDs()) + { + foreach (string damcat in results.GetDamageCategories()) + { + foreach (string assetType in results.GetAssetCategories()) + { + double withProjEAD = results.MeanWithProjectFutureYearEAD(altID, impactAreaID, damcat, assetType); + double eadReduced = results.MeanFutureYearEADReduced(altID, impactAreaID, damcat, assetType); + double point75 = results.FutureYearEADReducedExceededWithProbabilityQ(.75, altID, impactAreaID, damcat, assetType); + double point5 = results.FutureYearEADReducedExceededWithProbabilityQ(.5, altID, impactAreaID, damcat, assetType); + double point25 = results.FutureYearEADReducedExceededWithProbabilityQ(.25, altID, impactAreaID, damcat, assetType); + double eadWithoutProjDamage = results.MeanWithoutProjectFutureYearEAD(impactAreaID, damcat, assetType); + EADSummaryRowItem row = new(impactAreaNames[impactAreaID], damcat, assetType, withoutProjName, eadWithoutProjDamage, withProjName, withProjEAD, eadReduced, point75, point5, point25); + eadSummaryRowItems.Add(row); + } + } + } + } + return eadSummaryRowItems; + } + private List CreateAggregatedEADFutureYearSummaryTable(AlternativeComparisonReportResults results) + { + List eadSummaryRowItems = new(); + Dictionary impactAreaNames = IASElement.GetImpactAreaNamesFromIDs(); + string withoutProjName = GetAlternativeElementFromID(WithoutProjAltID).Name; - double withProjEAD = results.MeanWithProjectFutureYearEAD(altID); - - double eadReduced = results.MeanFutureYearEADReduced(altID); - - - double point75 = results.FutureYearEADReducedExceededWithProbabilityQ( .75, altID); - double point5 = results.FutureYearEADReducedExceededWithProbabilityQ(.5, altID); - double point25 = results.FutureYearEADReducedExceededWithProbabilityQ(.25, altID); - - EADSummaryRowItem row = new EADSummaryRowItem(withoutProjName, eadWithoutProjDamage, withProjName, withProjEAD, eadReduced, point75, point5, point25); - - eadSummaryRowItems.Add(row); + foreach (int altID in WithProjAltIDs) + { + string withProjName = GetAlternativeElementFromID(altID).Name; + foreach (int impactAreaID in results.GetImpactAreaIDs()) + { + double withProjEAD = results.MeanWithProjectFutureYearEAD(altID, impactAreaID); + double eadReduced = results.MeanFutureYearEADReduced(altID, impactAreaID); + double point75 = results.FutureYearEADReducedExceededWithProbabilityQ(.75, altID, impactAreaID); + double point5 = results.FutureYearEADReducedExceededWithProbabilityQ(.5, altID, impactAreaID); + double point25 = results.FutureYearEADReducedExceededWithProbabilityQ(.25, altID, impactAreaID); + double eadWithoutProjDamage = results.MeanWithoutProjectFutureYearEAD(impactAreaID); + AggregatedEADSummaryRowItem row = new(impactAreaNames[impactAreaID], withoutProjName, eadWithoutProjDamage, withProjName, withProjEAD, eadReduced, point75, point5, point25); + eadSummaryRowItems.Add(row); + } } return eadSummaryRowItems; } + private List CreateEADBaseYearSummaryTable(AlternativeComparisonReportResults results) { - List eadSummaryRowItems = new List(); - + List eadSummaryRowItems = new(); + Dictionary impactAreaNames = IASElement.GetImpactAreaNamesFromIDs(); string withoutProjName = GetAlternativeElementFromID(WithoutProjAltID).Name; - double eadWithoutProjDamage = results.MeanWithoutProjectBaseYearEAD(); + foreach (int altID in WithProjAltIDs) { string withProjName = GetAlternativeElementFromID(altID).Name; + foreach (int impactAreaID in results.GetImpactAreaIDs()) + { + foreach (string damcat in results.GetDamageCategories()) + { + foreach (string assetType in results.GetAssetCategories()) + { + double withProjEAD = results.MeanWithProjectBaseYearEAD(altID, impactAreaID, damcat, assetType); + double eadReduced = results.MeanBaseYearEADReduced(altID, impactAreaID, damcat, assetType); + double point75 = results.BaseYearEADReducedExceededWithProbabilityQ(.75, altID, impactAreaID, damcat, assetType); + double point5 = results.BaseYearEADReducedExceededWithProbabilityQ(.5, altID, impactAreaID, damcat, assetType); + double point25 = results.BaseYearEADReducedExceededWithProbabilityQ(.25, altID, impactAreaID, damcat, assetType); + double eadWithoutProjDamage = results.MeanWithoutProjectBaseYearEAD(impactAreaID, damcat, assetType); + EADSummaryRowItem row = new(impactAreaNames[impactAreaID],damcat, assetType, withoutProjName, eadWithoutProjDamage, withProjName, withProjEAD, eadReduced, point75, point5, point25); + eadSummaryRowItems.Add(row); + } + } + } + } + return eadSummaryRowItems; + } + private List CreateAggregatedEADBaseYearSummaryTable(AlternativeComparisonReportResults results) + { + List eadSummaryRowItems = new(); + Dictionary impactAreaNames = IASElement.GetImpactAreaNamesFromIDs(); + string withoutProjName = GetAlternativeElementFromID(WithoutProjAltID).Name; - double withProjEAD = results.MeanWithProjectBaseYearEAD(altID); - - double eadReduced = results.MeanBaseYearEADReduced(altID); - - - double point75 = results.BaseYearEADReducedExceededWithProbabilityQ(.75, altID); - double point5 = results.BaseYearEADReducedExceededWithProbabilityQ(.5, altID); - double point25 = results.BaseYearEADReducedExceededWithProbabilityQ(.25, altID); - - EADSummaryRowItem row = new EADSummaryRowItem(withoutProjName, eadWithoutProjDamage, withProjName, withProjEAD, eadReduced, point75, point5, point25); - - eadSummaryRowItems.Add(row); - + foreach (int altID in WithProjAltIDs) + { + string withProjName = GetAlternativeElementFromID(altID).Name; + foreach (int impactAreaID in results.GetImpactAreaIDs()) + { + double withProjEAD = results.MeanWithProjectBaseYearEAD(altID, impactAreaID); + double eadReduced = results.MeanBaseYearEADReduced(altID, impactAreaID); + double point75 = results.BaseYearEADReducedExceededWithProbabilityQ(.75, altID, impactAreaID); + double point5 = results.BaseYearEADReducedExceededWithProbabilityQ(.5, altID, impactAreaID); + double point25 = results.BaseYearEADReducedExceededWithProbabilityQ(.25, altID, impactAreaID); + double eadWithoutProjDamage = results.MeanWithoutProjectBaseYearEAD(impactAreaID); + AggregatedEADSummaryRowItem row = new(impactAreaNames[impactAreaID], withoutProjName, eadWithoutProjDamage, withProjName, withProjEAD, eadReduced, point75, point5, point25); + eadSummaryRowItems.Add(row); + } } return eadSummaryRowItems; } private List CreateAAEQSummaryTable(AlternativeComparisonReportResults results) { - List aaeqSummaryRowItems = new List(); - + List aaeqSummaryRowItems = []; + Dictionary impactAreaNames = IASElement.GetImpactAreaNamesFromIDs(); string withoutProjName = GetAlternativeElementFromID(WithoutProjAltID).Name; - - double aaeqWithoutProjDamage = results.MeanWithoutProjectAAEQDamage(); + foreach (int altID in WithProjAltIDs) { string withProjName = GetAlternativeElementFromID(altID).Name; + foreach (int impactAreaID in results.GetImpactAreaIDs()) + { + foreach (string damcat in results.GetDamageCategories()) + { + foreach (string assetType in results.GetAssetCategories()) + { + double withProjAAEQ = results.MeanWithProjectAAEQDamage(altID, impactAreaID, damcat, assetType); + double aaeqReduced = results.MeanAAEQDamageReduced(altID, impactAreaID, damcat, assetType); + double point75 = results.AAEQDamageReducedExceededWithProbabilityQ(.75, altID, impactAreaID, damcat, assetType); + double point5 = results.AAEQDamageReducedExceededWithProbabilityQ(.5, altID, impactAreaID, damcat, assetType); + double point25 = results.AAEQDamageReducedExceededWithProbabilityQ(.25, altID, impactAreaID, damcat, assetType); + double aaeqWithoutProjDamage = results.MeanWithoutProjectAAEQDamage(impactAreaID, damcat, assetType); + AAEQSummaryRowItem row = new(impactAreaNames[impactAreaID], damcat, assetType, withoutProjName, aaeqWithoutProjDamage, withProjName, withProjAAEQ, aaeqReduced, point75, point5, point25); + aaeqSummaryRowItems.Add(row); + } + } - double withProjAAEQ = results.MeanWithProjectAAEQDamage(altID); - - double aaeqReduced = results.MeanAAEQDamageReduced(altID); - - double point75 = results.AAEQDamageReducedExceededWithProbabilityQ(.75, altID); - double point5 = results.AAEQDamageReducedExceededWithProbabilityQ(.5, altID); - double point25 = results.AAEQDamageReducedExceededWithProbabilityQ(.25, altID); - - AAEQSummaryRowItem row = new AAEQSummaryRowItem(withoutProjName, aaeqWithoutProjDamage, withProjName, withProjAAEQ, aaeqReduced, point75, point5, point25); + } + } + return aaeqSummaryRowItems; + } + private List CreateAggregatedAAEQSummaryTable(AlternativeComparisonReportResults results) + { + List aaeqSummaryRowItems = []; + Dictionary impactAreaNames = IASElement.GetImpactAreaNamesFromIDs(); + string withoutProjName = GetAlternativeElementFromID(WithoutProjAltID).Name; - aaeqSummaryRowItems.Add(row); + foreach (int altID in WithProjAltIDs) + { + string withProjName = GetAlternativeElementFromID(altID).Name; + foreach (int impactAreaID in results.GetImpactAreaIDs()) + { + double withProjAAEQ = results.MeanWithProjectAAEQDamage(altID, impactAreaID); + double aaeqReduced = results.MeanAAEQDamageReduced(altID, impactAreaID); + double point75 = results.AAEQDamageReducedExceededWithProbabilityQ(.75, altID, impactAreaID); + double point5 = results.AAEQDamageReducedExceededWithProbabilityQ(.5, altID, impactAreaID); + double point25 = results.AAEQDamageReducedExceededWithProbabilityQ(.25, altID, impactAreaID); + double aaeqWithoutProjDamage = results.MeanWithoutProjectAAEQDamage(impactAreaID); + AggregatedAAEQSummaryRowItem row = new(impactAreaNames[impactAreaID], withoutProjName, aaeqWithoutProjDamage, withProjName, withProjAAEQ, aaeqReduced, point75, point5, point25); + aaeqSummaryRowItems.Add(row); + } } return aaeqSummaryRowItems; } - + public List GetWithProjectAlternatives() { List alts = new List(); - foreach(int id in WithProjAltIDs ) + foreach (int id in WithProjAltIDs) { AlternativeElement altElement = GetAlternativeElementFromID(id); - if(altElement != null) + if (altElement != null) { alts.Add(altElement); } @@ -322,7 +410,7 @@ private FdaValidationResult GetCanComputeResults() List withProjAlts = GetWithProjectAlternatives(); FdaValidationResult withoutAltValidationResult = withoutAlt.RunPreComputeValidation(); - if(!withoutAltValidationResult.IsValid) + if (!withoutAltValidationResult.IsValid) { vr.AddErrorMessage("Alternative " + withoutAlt.Name + ":"); vr.AddErrorMessage(withoutAltValidationResult.ErrorMessage); @@ -343,8 +431,8 @@ private FdaValidationResult GetCanComputeResults() return vr; } - private SpecificAltCompReportResultsVM CreateAlternativeComparisonResult(int withProjID, string withProjName, List baseSummary, List futureSummary, List aaeqSummary) - { + private SpecificAltCompReportResultsVM CreateAlternativeComparisonResult(int withProjID, string withProjName) + { StudyPropertiesElement studyPropElem = StudyCache.GetStudyPropertiesElement(); double discountRate = studyPropElem.DiscountRate; @@ -355,15 +443,15 @@ private SpecificAltCompReportResultsVM CreateAlternativeComparisonResult(int wit int baseYear = _Results.Years[0]; int futureYear = _Results.Years[1]; - YearResult yr1 = new YearResult(baseYear, new DamageWithUncertaintyVM( _Results, withProjID, DamageMeasureYear.Base), new DamageByImpactAreaVM( _Results, withProjID, DamageMeasureYear.Base), new DamageByDamCatVM(_Results, DamageMeasureYear.Base, withProjID)); - YearResult yr2 = new YearResult(futureYear, new DamageWithUncertaintyVM( _Results, withProjID, DamageMeasureYear.Future), new DamageByImpactAreaVM( _Results, withProjID, DamageMeasureYear.Future), new DamageByDamCatVM(_Results, DamageMeasureYear.Future, withProjID)); + YearResult yr1 = new YearResult(baseYear, new DamageWithUncertaintyVM(_Results, withProjID, DamageMeasureYear.Base), new DamageByImpactAreaVM(_Results, withProjID, DamageMeasureYear.Base), new DamageByDamCatVM(_Results, DamageMeasureYear.Base, withProjID)); + YearResult yr2 = new YearResult(futureYear, new DamageWithUncertaintyVM(_Results, withProjID, DamageMeasureYear.Future), new DamageByImpactAreaVM(_Results, withProjID, DamageMeasureYear.Future), new DamageByDamCatVM(_Results, DamageMeasureYear.Future, withProjID)); - AAEQResult aaeqResult = new AAEQResult(new DamageWithUncertaintyVM( _Results, withProjID, DamageMeasureYear.AAEQ, discountRate, period), new DamageByImpactAreaVM( _Results, withProjID, DamageMeasureYear.AAEQ, discountRate, period), new DamageByDamCatVM(_Results, DamageMeasureYear.AAEQ, withProjID, discountRate, period)); + AAEQResult aaeqResult = new AAEQResult(new DamageWithUncertaintyVM(_Results, withProjID, DamageMeasureYear.AAEQ, discountRate, period), new DamageByImpactAreaVM(_Results, withProjID, DamageMeasureYear.AAEQ, discountRate, period), new DamageByDamCatVM(_Results, DamageMeasureYear.AAEQ, withProjID, discountRate, period)); EADResult eadResult = new EADResult(new List() { yr1, yr2 }); AlternativeResult altResult = new AlternativeResult(withProjName, eadResult, aaeqResult); - return new SpecificAltCompReportResultsVM(altResult, baseSummary, futureSummary, aaeqSummary); + return new SpecificAltCompReportResultsVM(altResult); } } } diff --git a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AAEQSummaryRowItem.cs b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AAEQSummaryRowItem.cs index 4f0454ade..94da62d2d 100644 --- a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AAEQSummaryRowItem.cs +++ b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AAEQSummaryRowItem.cs @@ -1,18 +1,37 @@ -namespace HEC.FDA.ViewModel.AlternativeComparisonReport.Results +using HEC.FDA.ViewModel.TableWithPlot.Rows.Attributes; + +namespace HEC.FDA.ViewModel.AlternativeComparisonReport.Results { public class AAEQSummaryRowItem { + [DisplayAsColumn("Impact Area")] + public string ImpactArea { get; set; } + [DisplayAsColumn("Damage Category")] + public string DamCat { get; set; } + [DisplayAsColumn("Asset Category")] + public string AssetCat { get; set; } + [DisplayAsColumn("Without Project Alternative")] public string WithoutProjAlternative { get; set; } + [DisplayAsColumn("Without Project EqAD")] public double WithoutProjAAEQ { get; set; } + [DisplayAsColumn("With Project Alternative")] public string WithProjAlternative { get; set; } + [DisplayAsColumn("With Project EqAD")] public double WithProjAAEQ { get; set; } + [DisplayAsColumn("Mean EqAD Reduced")] public double AAEQDamageReduced { get; set; } + [DisplayAsColumn("25th Percentile EqAD Reduced")]// This is intentionally swapped 1-x public double Point75 { get; set; } + [DisplayAsColumn("50th Percentile EqAD Reduced")] public double Point5 { get; set; } + [DisplayAsColumn("75th Percentile EqAD Reduced")] // This is intentionally swapped 1-x public double Point25 { get; set; } - public AAEQSummaryRowItem(string withoutName, double withoutAAEQDamage, string withProjName, double withProjAAEQ, + public AAEQSummaryRowItem(string impactArea, string damcat, string assetcat,string withoutName, double withoutAAEQDamage, string withProjName, double withProjAAEQ, double AAEQReduced, double point75, double point5, double point25) { + ImpactArea = impactArea; + DamCat = damcat; + AssetCat = assetcat; WithoutProjAlternative = withoutName; WithoutProjAAEQ = withoutAAEQDamage; WithProjAlternative = withProjName; diff --git a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AggregatedAAEQSummaryRowItem.cs b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AggregatedAAEQSummaryRowItem.cs new file mode 100644 index 000000000..35c8b491a --- /dev/null +++ b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AggregatedAAEQSummaryRowItem.cs @@ -0,0 +1,39 @@ +using HEC.FDA.ViewModel.TableWithPlot.Rows.Attributes; + +namespace HEC.FDA.ViewModel.AlternativeComparisonReport.Results +{ + public class AggregatedAAEQSummaryRowItem + { + [DisplayAsColumn("Impact Area")] + public string ImpactArea { get; set; } + [DisplayAsColumn("Without Project Alternative")] + public string WithoutProjAlternative { get; set; } + [DisplayAsColumn("Without Project EqAD")] + public double WithoutProjAAEQ { get; set; } + [DisplayAsColumn("With Project Alternative")] + public string WithProjAlternative { get; set; } + [DisplayAsColumn("With Project EqAD")] + public double WithProjAAEQ { get; set; } + [DisplayAsColumn("Mean EqAD Reduced")] + public double AAEQDamageReduced { get; set; } + [DisplayAsColumn("25th Percentile EqAD Reduced")] // This is intentionally swapped 1-x + public double Point75 { get; set; } + [DisplayAsColumn("50th Percentile EqAD Reduced")] + public double Point5 { get; set; } + [DisplayAsColumn("75th Percentile EqAD Reduced")] // This is intentionally swapped 1-x + public double Point25 { get; set; } + public AggregatedAAEQSummaryRowItem(string impactArea, string withoutName, double withoutAAEQDamage, string withProjName, double withProjAAEQ, + double AAEQReduced, double point75, double point5, double point25) + { + ImpactArea = impactArea; + WithoutProjAlternative = withoutName; + WithoutProjAAEQ = withoutAAEQDamage; + WithProjAlternative = withProjName; + WithProjAAEQ = withProjAAEQ; + AAEQDamageReduced = AAEQReduced; + Point75 = point75; + Point5 = point5; + Point25 = point25; + } + } +} diff --git a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AggregatedEADSummaryRowItem.cs b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AggregatedEADSummaryRowItem.cs new file mode 100644 index 000000000..3452372b0 --- /dev/null +++ b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/AggregatedEADSummaryRowItem.cs @@ -0,0 +1,41 @@ +using HEC.FDA.ViewModel.TableWithPlot.Rows.Attributes; +using System.Security.Permissions; + +namespace HEC.FDA.ViewModel.AlternativeComparisonReport.Results +{ + public class AggregatedEADSummaryRowItem + { + [DisplayAsColumn("Impact Area")] + public string ImpactArea { get; set; } + [DisplayAsColumn("Without Project Alternative")] + public string WithoutProjAlternative { get; set; } + [DisplayAsColumn("Without Project EAD")] + public double WithoutProjEAD { get; set; } + [DisplayAsColumn("With Project Alternative")] + public string WithProjAlternative { get; set; } + [DisplayAsColumn("With Project EAD")] + public double WithProjEAD { get; set; } + [DisplayAsColumn("Mean EAD Reduced")] + public double EADDamageReduced { get; set; } + [DisplayAsColumn("25th Percentile EAD Reduced")] //This is intentionally swapped 1-x + public double Point75 { get; set; } + [DisplayAsColumn("50th Percentile EAD Reduced")] + public double Point5 { get; set; } + [DisplayAsColumn("75th Percentile EAD Reduced")] //This is intentionally swapped 1-x + public double Point25 { get; set; } + + + public AggregatedEADSummaryRowItem(string impactArea, string withoutName, double withoutAAEQDamage, string withProjName, double withProjAAEQ, double AAEQReduced, double point75, double point5, double point25) + { + ImpactArea = impactArea; + WithoutProjAlternative = withoutName; + WithoutProjEAD = withoutAAEQDamage; + WithProjAlternative = withProjName; + WithProjEAD = withProjAAEQ; + EADDamageReduced = AAEQReduced; + Point75 = point75; + Point5 = point5; + Point25 = point25; + } + } +} diff --git a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/EADSummaryRowItem.cs b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/EADSummaryRowItem.cs index 821de782d..f4f3ba30c 100644 --- a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/EADSummaryRowItem.cs +++ b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/EADSummaryRowItem.cs @@ -1,19 +1,39 @@ -namespace HEC.FDA.ViewModel.AlternativeComparisonReport.Results +using HEC.FDA.ViewModel.TableWithPlot.Rows.Attributes; +using System.Security.Permissions; + +namespace HEC.FDA.ViewModel.AlternativeComparisonReport.Results { public class EADSummaryRowItem { + [DisplayAsColumn("Impact Area")] + public string ImpactArea { get; set; } + [DisplayAsColumn("Damage Category")] + public string DamCat { get; set; } + [DisplayAsColumn("Asset Category")] + public string AssetCat { get; set; } + [DisplayAsColumn("Without Project Alternative")] public string WithoutProjAlternative { get; set; } + [DisplayAsColumn("Without Project EAD")] public double WithoutProjEAD { get; set; } + [DisplayAsColumn("With Project Alternative")] public string WithProjAlternative { get; set; } + [DisplayAsColumn("With Project EAD")] public double WithProjEAD { get; set; } + [DisplayAsColumn("Mean EAD Reduced")] public double EADDamageReduced { get; set; } + [DisplayAsColumn("25th Percentile EAD Reduced")] //This is intentionally swapped 1-x public double Point75 { get; set; } + [DisplayAsColumn("50th Percentile EAD Reduced")] public double Point5 { get; set; } + [DisplayAsColumn("75th Percentile EAD Reduced")] //This is intentionally swapped 1-x public double Point25 { get; set; } - public EADSummaryRowItem(string withoutName, double withoutAAEQDamage, string withProjName, double withProjAAEQ, double AAEQReduced, double point75, double point5, double point25 ) + public EADSummaryRowItem(string impactArea, string damcat, string assetcat, string withoutName, double withoutAAEQDamage, string withProjName, double withProjAAEQ, double AAEQReduced, double point75, double point5, double point25 ) { + ImpactArea = impactArea; + DamCat = damcat; + AssetCat = assetcat; WithoutProjAlternative = withoutName; WithoutProjEAD = withoutAAEQDamage; WithProjAlternative = withProjName; diff --git a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/SpecificAltCompReportResultsVM.cs b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/SpecificAltCompReportResultsVM.cs index 1f8ee42ee..ebdd48595 100644 --- a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/SpecificAltCompReportResultsVM.cs +++ b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/SpecificAltCompReportResultsVM.cs @@ -58,7 +58,7 @@ public string SelectedReport public AlternativeResult AlternativeResult { get; } - public SpecificAltCompReportResultsVM(AlternativeResult altResult, List baseYearSummary, List futureYearSummary, List aaeqSummary) + public SpecificAltCompReportResultsVM(AlternativeResult altResult) { Name = altResult.Name; AlternativeResult = altResult; diff --git a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/SummaryVM.cs b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/SummaryVM.cs index ad29c228f..bbd8ce5b8 100644 --- a/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/SummaryVM.cs +++ b/HEC.FDA.ViewModel/AlternativeComparisonReport/Results/SummaryVM.cs @@ -6,27 +6,39 @@ namespace HEC.FDA.ViewModel.AlternativeComparisonReport.Results public class SummaryVM : SpecificAltCompReportResultsVM { - public AAEQSummaryVM AAEQSummaryVM { get; } + public List AAEQSummaryRows { get; } + public List AggAAEQSummaryRows { get; } - public EADSummaryVM BaseEADSummaryVM { get; } + public List BaseEADSummaryRows { get; } + public List AggBaseEADSummaryRows { get; } - public EADSummaryVM FutureEADSummaryVM { get; } + public List FutureEADSummaryRows { get; } + public List AggFutureEADSummaryRows { get; } public string BaseYearLabel { get; } public string FutureYearLabel { get; } public string AAEQLabel { get; } + public string AggBaseYearLabel { get; } + public string AggFutureYearLabel { get; } + public string AggAAEQLabel { get; } - public SummaryVM(List baseYearSummary, List futureYearSummary, List aaeqSummary, List years) :base() + public SummaryVM(List baseYearSummary, List futureYearSummary, List aaeqSummary, + List aggBaseYearSummary, List aggFutureYearSummary, List aggAAEQSummary, List years) :base() { - StudyPropertiesElement studyPropElem = StudyCache.GetStudyPropertiesElement(); - AAEQSummaryVM = new AAEQSummaryVM(aaeqSummary, studyPropElem.DiscountRate, studyPropElem.PeriodOfAnalysis); - BaseEADSummaryVM = new EADSummaryVM(baseYearSummary, studyPropElem.DiscountRate, studyPropElem.PeriodOfAnalysis); - FutureEADSummaryVM = new EADSummaryVM(futureYearSummary, studyPropElem.DiscountRate, studyPropElem.PeriodOfAnalysis); - - BaseYearLabel = "Base Year EAD " + years[0] + ":"; - FutureYearLabel = "Future Year EAD " + years[1] + ":"; - AAEQLabel = "Period of Analysis AAEQ Damage:"; - + AAEQSummaryRows = aaeqSummary; + AggAAEQSummaryRows = aggAAEQSummary; + BaseEADSummaryRows = baseYearSummary; + AggBaseEADSummaryRows = aggBaseYearSummary; + FutureEADSummaryRows = futureYearSummary; + AggFutureEADSummaryRows = aggFutureYearSummary; + + BaseYearLabel = "Base Year Expected Annual Damage Reduced by Damage and Asset Category " + years[0]; + FutureYearLabel = "Future Year Expected Annual Damage Reduced by Damage and Asset Category " + years[1]; + AAEQLabel = "Equivalent Annual Damage Distribution (EqAD) Reduced by Damage and Asset Category"; + + AggBaseYearLabel = "Base Year Expected Annual Damage Reduced Distribution " + years[0]; + AggFutureYearLabel = "Future Year Expected Annual Damage Reduced Distribution " + years[1]; + AggAAEQLabel = "Equivalent Annual Damage (EqAD) Reduced Distribution"; } } diff --git a/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeDamCatRowItem.cs b/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeDamCatRowItem.cs index 66f3db398..d05b02285 100644 --- a/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeDamCatRowItem.cs +++ b/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeDamCatRowItem.cs @@ -1,5 +1,8 @@ -using HEC.FDA.ViewModel.ImpactAreaScenario; +using HEC.FDA.Model.scenarios; +using HEC.FDA.ViewModel.ImpactAreaScenario; +using HEC.FDA.ViewModel.Results; using HEC.FDA.ViewModel.Study; +using HEC.FDA.ViewModel.TableWithPlot.Rows.Attributes; using Statistics.Distributions; using System; using System.Collections.Generic; @@ -12,41 +15,52 @@ namespace HEC.FDA.ViewModel.Alternatives.Results.BatchCompute public class AlternativeDamCatRowItem : BaseViewModel { + [DisplayAsColumn("Scenario Name")] public string Name { get; set; } - public IASElement BaseYearScenario { get; set; } - public IASElement FutureYearScenario { get; set; } - public double DiscountRate { get; set; } - public int PeriodOfAnalysis { get; set; } - public double Mean { get; set; } - public double Q1 { get; set; } - public double Q2 { get; set; } - public double Q3 { get; set; } + [DisplayAsColumn("Impact Area")] + public string ImpactAreaName { get; set; } + [DisplayAsColumn("Damage Category")] + public string DamCat { get; set; } + [DisplayAsColumn("Asset Category")] + public string AssetCat { get; set; } + [DisplayAsColumn("Mean EqAD")] + public double MeanDamage { get; set; } - public Dictionary DamCatMap = new Dictionary(); - - public AlternativeDamCatRowItem(AlternativeElement altElem) + private AlternativeDamCatRowItem(string name, string impactArea, string assetCategory, string damCat, double mean) { - Name = altElem.Name; - BaseYearScenario = altElem.BaseScenario.GetElement(); - FutureYearScenario = altElem.FutureScenario.GetElement(); + Name = name; + ImpactAreaName = impactArea; + AssetCat = assetCategory; + DamCat = damCat; + MeanDamage = mean; + } - StudyPropertiesElement studyPropElem = StudyCache.GetStudyPropertiesElement(); - DiscountRate = studyPropElem.DiscountRate; - PeriodOfAnalysis = altElem.Results.PeriodOfAnalysis; + public static List CreateAlternativeDamCatRowItems(AlternativeElement altElem) + { + List rowItems = []; - Mean = altElem.Results.MeanAAEQDamage(); - Q1 = altElem.Results.AAEQDamageExceededWithProbabilityQ(.75); - Q2 = altElem.Results.AAEQDamageExceededWithProbabilityQ(.5); - Q3 = altElem.Results.AAEQDamageExceededWithProbabilityQ(.25); + string Name = altElem.Name; + IASElement BaseYearScenario = altElem.BaseScenario.GetElement(); + List impactAreaIds = BaseYearScenario.Results.GetImpactAreaIDs(); + Dictionary impactAreaIdToName = IASElement.GetImpactAreaNamesFromIDs(); List damCats = altElem.Results.GetDamageCategories(); - foreach (string damCat in damCats) + List assetCats = altElem.Results.GetAssetCategories(); + foreach (int impactAreaID in impactAreaIds) { - Empirical damCatValue = altElem.Results.GetAAEQDamageDistribution(damageCategory: damCat); - DamCatMap.Add(damCat, Math.Round(damCatValue.Mean, 2)); + foreach (string damCat in damCats) + { + foreach(string assetCat in assetCats) + { + Empirical dist = altElem.Results.GetAAEQDamageDistribution(impactAreaID, damCat, assetCat); + double mean = Math.Round(dist.Mean, 2); + AlternativeDamCatRowItem row = new(Name, impactAreaIdToName[impactAreaID], assetCat, damCat, mean); + rowItems.Add(row); + } + } } + return rowItems; } - } } diff --git a/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeDamageRowItem.cs b/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeDamageRowItem.cs index da41fc997..73a483bb6 100644 --- a/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeDamageRowItem.cs +++ b/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeDamageRowItem.cs @@ -1,4 +1,6 @@ -using HEC.FDA.ViewModel.Study; +using HEC.FDA.ViewModel.ImpactAreaScenario; +using HEC.FDA.ViewModel.Study; +using HEC.FDA.ViewModel.TableWithPlot.Rows.Attributes; using System; using System.Collections.Generic; using System.Linq; @@ -9,30 +11,67 @@ namespace HEC.FDA.ViewModel.Alternatives.Results.BatchCompute { public class AlternativeDamageRowItem:BaseViewModel { + [DisplayAsColumn("Name")] public string Name { get; set; } + [DisplayAsColumn("Impact Area")] + public string ImpactArea { get; set; } + [DisplayAsColumn("Base Year")] public int BaseYear { get; set; } + [DisplayAsColumn("Future Year")] public int FutureYear { get; set; } + [DisplayAsColumn("Discount Rate")] public double DiscountRate { get; set; } + [DisplayAsColumn("Period of Analysis")] public int PeriodOfAnalysis { get; set; } + [DisplayAsColumn("Mean EqAD")] public double Mean { get; set; } - public double Q1 { get; set; } - public double Q2 { get; set; } - public double Q3 { get; set; } + [DisplayAsColumn("25th Percentile EqAD")] //This is intentionally swapped 1-x + public double Point75 { get; set; } + [DisplayAsColumn("50th Percentile EqAD")] + public double Point5 { get; set; } + [DisplayAsColumn("75th Percentile EqAD")]//This is intentionally swapped 1-x + public double Point25 { get; set; } + private AlternativeDamageRowItem(string name, string impactArea, int baseYear, int futureYear, double discountRate, int periodOfAnalysis, double mean, double point75, double point5, double point25) + { + Name = name; + ImpactArea = impactArea; + BaseYear = baseYear; + FutureYear = futureYear; + DiscountRate = discountRate; + PeriodOfAnalysis = periodOfAnalysis; + Mean = mean; + Point75 = point75; + Point5 = point5; + Point25 = point25; + } - public AlternativeDamageRowItem(AlternativeElement altElem) + public static List CreateAlternativeDamageRowItems(AlternativeElement altElem) { - Name = altElem.Name; - BaseYear = altElem.Results.AnalysisYears[0]; - FutureYear = altElem.Results.AnalysisYears[1]; + string Name = altElem.Name; + int baseYear = altElem.Results.AnalysisYears[0]; + int futureYear = altElem.Results.AnalysisYears[1]; + StudyPropertiesElement studyPropElem = StudyCache.GetStudyPropertiesElement(); - DiscountRate = studyPropElem.DiscountRate; - PeriodOfAnalysis = altElem.Results.PeriodOfAnalysis; - Mean = altElem.Results.MeanAAEQDamage(); - Q1 = altElem.Results.AAEQDamageExceededWithProbabilityQ(.75); - Q2 = altElem.Results.AAEQDamageExceededWithProbabilityQ(.5); - Q3 = altElem.Results.AAEQDamageExceededWithProbabilityQ(.25); + double DiscountRate = studyPropElem.DiscountRate; + int PeriodOfAnalysis = altElem.Results.PeriodOfAnalysis; + IASElement BaseYearScenario = altElem.BaseScenario.GetElement(); + List impactAreaIds = BaseYearScenario.Results.GetImpactAreaIDs(); + Dictionary impactAreaIdToName = IASElement.GetImpactAreaNamesFromIDs(); + + int rowsPerScenario = impactAreaIds.Count; + List rowItems = new(rowsPerScenario); + foreach(int impactAreaID in impactAreaIds) + { + double mean = altElem.Results.MeanAAEQDamage(impactAreaID); + double point75 = altElem.Results.AAEQDamageExceededWithProbabilityQ(.75,impactAreaID); + double point5 = altElem.Results.AAEQDamageExceededWithProbabilityQ( .5, impactAreaID); + double point25 = altElem.Results.AAEQDamageExceededWithProbabilityQ( .25, impactAreaID); + AlternativeDamageRowItem row = new(Name, impactAreaIdToName[impactAreaID], baseYear,futureYear, DiscountRate, PeriodOfAnalysis, mean, point75, point5, point25); + rowItems.Add(row); + } + return rowItems; } } diff --git a/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeSummaryVM.cs b/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeSummaryVM.cs index 41feb498d..e025cef31 100644 --- a/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeSummaryVM.cs +++ b/HEC.FDA.ViewModel/Alternatives/Results/BatchCompute/AlternativeSummaryVM.cs @@ -10,68 +10,19 @@ namespace HEC.FDA.ViewModel.Alternatives.Results.BatchCompute public class AlternativeSummaryVM : BaseViewModel { - public List Rows { get; } = new List(); - - public DataTable DamCatTable { get; set; } = new DataTable(); + public List Rows { get; } = []; + public List DamCatRows { get; } = []; public AlternativeSummaryVM(List altElems) { List damCatRows = new List(); foreach (AlternativeElement element in altElems) { - Rows.Add(new AlternativeDamageRowItem(element)); - damCatRows.Add(new AlternativeDamCatRowItem(element)); - } - LoadDamCatDataTable(damCatRows); - } - - private void LoadDamCatDataTable(List rows) - { - DataColumn nameCol = new DataColumn("Name", typeof(string)); - DamCatTable.Columns.Add(nameCol); - List allUniqueDamCats = GetAllDamCats(rows); - foreach (string damCat in allUniqueDamCats) - { - DamCatTable.Columns.Add(new DataColumn(damCat, typeof(string))); - } - - foreach (AlternativeDamCatRowItem row in rows) - { - AddDamCatRowToTable(row, allUniqueDamCats); + Rows.AddRange( AlternativeDamageRowItem.CreateAlternativeDamageRowItems(element)); + DamCatRows.AddRange( AlternativeDamCatRowItem.CreateAlternativeDamCatRowItems(element)); } } - private void AddDamCatRowToTable(AlternativeDamCatRowItem row, List allDamCats) - { - DataRow myRow = DamCatTable.NewRow(); - myRow["Name"] = row.Name; - foreach (string damCat in allDamCats) - { - if (row.DamCatMap.ContainsKey(damCat)) - { - myRow[damCat] = row.DamCatMap[damCat]; - } - else - { - //this alternative doesn't have a value for that dam cat. Assign 0. - myRow[damCat] = 0; - } - } - DamCatTable.Rows.Add(myRow); - } - - private List GetAllDamCats(List rows) - { - HashSet uniqueDamCats = new HashSet(); - foreach (AlternativeDamCatRowItem row in rows) - { - foreach (string damCat in row.DamCatMap.Keys) - { - uniqueDamCats.Add(damCat); - } - } - return uniqueDamCats.ToList(); - } } diff --git a/HEC.FDA.ViewModel/ImpactAreaScenario/IASElement.cs b/HEC.FDA.ViewModel/ImpactAreaScenario/IASElement.cs index 150ce54bb..f2c2dbe7b 100644 --- a/HEC.FDA.ViewModel/ImpactAreaScenario/IASElement.cs +++ b/HEC.FDA.ViewModel/ImpactAreaScenario/IASElement.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Dynamic; using System.Windows; using System.Xml.Linq; using HEC.FDA.Model.metrics; @@ -185,7 +186,16 @@ public List GetResults() } return results; } - + public static Dictionary GetImpactAreaNamesFromIDs() + { + List impactAreaRows = GetStudyImpactAreaRowItems(); + Dictionary impactAreaNames = []; + foreach (ImpactAreaRowItem row in impactAreaRows) + { + impactAreaNames.Add(row.ID, row.Name); + } + return impactAreaNames; + } private static string GetImpactAreaNameFromID(List rows, int id) { string rowName = null; diff --git a/HEC.FDA.ViewModel/ImpactAreaScenario/SpecificIAS.cs b/HEC.FDA.ViewModel/ImpactAreaScenario/SpecificIAS.cs index 24a199554..d71db4b88 100644 --- a/HEC.FDA.ViewModel/ImpactAreaScenario/SpecificIAS.cs +++ b/HEC.FDA.ViewModel/ImpactAreaScenario/SpecificIAS.cs @@ -51,6 +51,8 @@ public class SpecificIAS : BaseViewModel /// The impact area ID for the selected impact area. It will be -1 if no selection was made. /// public int ImpactAreaID { get; set; } + public string ImpactAreaName { get => GetSpecificImpactAreaName(); } + /// /// The flow freq ID for the selected flow freq. It will be -1 if no selection was made. /// @@ -160,12 +162,17 @@ private string CreateElementDoesntExistMessage(string elemName) } public string GetSpecificImpactAreaName() + { + return GetSpecificImpactAreaName(ImpactAreaID); + } + + public static string GetSpecificImpactAreaName(int id) { string name = ""; ImpactAreaElement impactAreaElem = (ImpactAreaElement)StudyCache.GetChildElementsOfType(typeof(ImpactAreaElement))[0]; - foreach(ImpactAreaRowItem row in impactAreaElem.ImpactAreaRows) + foreach (ImpactAreaRowItem row in impactAreaElem.ImpactAreaRows) { - if(row.ID == ImpactAreaID) + if (row.ID == id) { name = row.Name; } diff --git a/HEC.FDA.ViewModel/Results/ScenarioDamCatRowItem.cs b/HEC.FDA.ViewModel/Results/ScenarioDamCatRowItem.cs index 36218f8d2..0a9f78208 100644 --- a/HEC.FDA.ViewModel/Results/ScenarioDamCatRowItem.cs +++ b/HEC.FDA.ViewModel/Results/ScenarioDamCatRowItem.cs @@ -1,5 +1,6 @@ using HEC.FDA.Model.metrics; using HEC.FDA.ViewModel.ImpactAreaScenario; +using HEC.FDA.ViewModel.TableWithPlot.Rows.Attributes; using Statistics.Distributions; using System; using System.Collections.Generic; @@ -11,23 +12,54 @@ namespace HEC.FDA.ViewModel.Results { public class ScenarioDamCatRowItem { + [DisplayAsColumn("Scenario Name")] public string Name { get; set; } + [DisplayAsColumn("Analysis Year")] public string AnalysisYear { get; set; } - public Dictionary DamCatMap = new Dictionary(); + [DisplayAsColumn("Impact Area")] + public string ImpactAreaName { get; set; } + [DisplayAsColumn("Damage Category")] + public string DamCat { get; set; } + [DisplayAsColumn("Asset Category")] + public string AssetCat { get; set; } + [DisplayAsColumn("Mean EAD")] + public double MeanDamage { get; set; } - public ScenarioDamCatRowItem(IASElement scenario) + private ScenarioDamCatRowItem(string name, string analysisYear, string impactAreaName, string damcat, string assetCat, double mean) { - Name = scenario.Name; - AnalysisYear = scenario.AnalysisYear; - ScenarioResults results = scenario.Results; + Name = name; + AnalysisYear = analysisYear; + ImpactAreaName = impactAreaName; + DamCat = damcat; + AssetCat = assetCat; + MeanDamage = mean; + } + + public static List CreateScenarioDamCatRowItems(IASElement scenario) + { + string name = scenario.Name; + string analysisYear = scenario.AnalysisYear; + ScenarioResults results = scenario.Results; + List impactAreaIds = results.GetImpactAreaIDs(); + Dictionary impactAreaIdToName = IASElement.GetImpactAreaNamesFromIDs(); List damCats = results.GetDamageCategories(); - foreach (string damCat in damCats) + List assetCats = results.GetAssetCategories(); + + List rowItems = []; + foreach (int impactAreaID in impactAreaIds) { - Empirical damCatValue = results.GetConsequencesDistribution(damageCategory: damCat); - DamCatMap.Add(damCat, Math.Round(damCatValue.Mean,2)); + foreach (string damCat in damCats) + { + foreach (string assetCat in assetCats) + { + double mean = results.MeanExpectedAnnualConsequences(impactAreaID, damCat, assetCat); + ScenarioDamCatRowItem row = new(name, analysisYear, impactAreaIdToName[impactAreaID], damCat, assetCat, mean); + rowItems.Add(row); + } + } } + return rowItems; } - } } diff --git a/HEC.FDA.ViewModel/Results/ScenarioDamageRowItem.cs b/HEC.FDA.ViewModel/Results/ScenarioDamageRowItem.cs index a253be655..d1adec9d6 100644 --- a/HEC.FDA.ViewModel/Results/ScenarioDamageRowItem.cs +++ b/HEC.FDA.ViewModel/Results/ScenarioDamageRowItem.cs @@ -1,36 +1,61 @@ using HEC.FDA.Model.metrics; using HEC.FDA.ViewModel.ImpactAreaScenario; +using HEC.FDA.ViewModel.TableWithPlot.Rows.Attributes; using Statistics.Distributions; +using System; using System.Collections.Generic; +using System.Linq; +using Utility.Memory; namespace HEC.FDA.ViewModel.Results { public class ScenarioDamageRowItem { + [DisplayAsColumn("Name")] public string Name { get; set; } + [DisplayAsColumn("Analysis Year")] public string AnalysisYear { get; set; } + [DisplayAsColumn("Impact Area")] + public string ImpactArea { get; set; } + [DisplayAsColumn("Mean EAD")] public double Mean { get; set; } - public double Q1 { get; set; } - public double Q2 { get; set; } - public double Q3 { get; set; } + [DisplayAsColumn("25th Percentile EAD")] //This is intentionally swapped 1-x + public double Point75 { get; set; } + [DisplayAsColumn("50th Percentile EAD")] + public double Point5 { get; set; } + [DisplayAsColumn("75th Percentile EAD")]//This is intentionally swapped 1-x + public double Point25 { get; set; } + private ScenarioDamageRowItem(string name, string analysisYear, string impactArea, double mean, double point75, double point5, double point25) + { + Name = name; + AnalysisYear = analysisYear; + ImpactArea = impactArea; + Mean = mean; + Point75 = point75; + Point5 = point5; + Point25 = point25; + } - public ScenarioDamageRowItem(IASElement scenario) + public static List CreateScenarioDamageRowItems(IASElement scenario) { - Name = scenario.Name; - AnalysisYear = scenario.AnalysisYear; + List rowItems = []; + + string name = scenario.Name; + string analysisYear = scenario.AnalysisYear; ScenarioResults results = scenario.Results; - Mean = results.MeanExpectedAnnualConsequences(); - Q1 = results.ConsequencesExceededWithProbabilityQ(.75); - Q2 = results.ConsequencesExceededWithProbabilityQ(.5); - Q3 = results.ConsequencesExceededWithProbabilityQ(.25); - List damCats = results.GetDamageCategories(); - foreach (string damCat in damCats) + List impactAreaIds = results.GetImpactAreaIDs(); + Dictionary impactAreaIdToName = IASElement.GetImpactAreaNamesFromIDs(); + + foreach (int impactAreaID in impactAreaIds) { - Empirical damCatValue = results.GetConsequencesDistribution(damageCategory: damCat); + double Mean = results.MeanExpectedAnnualConsequences(impactAreaID); + double point75 = results.ConsequencesExceededWithProbabilityQ(.75, impactAreaID); + double point5 = results.ConsequencesExceededWithProbabilityQ(.50, impactAreaID); + double point25 = results.ConsequencesExceededWithProbabilityQ(.25, impactAreaID); + rowItems.Add(new(name, analysisYear, impactAreaIdToName[impactAreaID], Mean, point75, point5, point25)); } - - + return rowItems; } } diff --git a/HEC.FDA.ViewModel/Results/ScenarioDamageSummaryVM.cs b/HEC.FDA.ViewModel/Results/ScenarioDamageSummaryVM.cs index 891a6fb5f..57d099fe0 100644 --- a/HEC.FDA.ViewModel/Results/ScenarioDamageSummaryVM.cs +++ b/HEC.FDA.ViewModel/Results/ScenarioDamageSummaryVM.cs @@ -12,16 +12,11 @@ public class ScenarioDamageSummaryVM : BaseViewModel { private DataTable _DamCatTable; - public CustomObservableCollection SelectableElements { get; } = new CustomObservableCollection(); - public CustomObservableCollection Rows { get; } = new CustomObservableCollection(); - public CustomObservableCollection PerformanceRows { get; } = new CustomObservableCollection(); - public CustomObservableCollection AssuranceOfAEPRows { get; } = new CustomObservableCollection(); - - public DataTable DamCatTable - { - get { return _DamCatTable; } - set { _DamCatTable = value; NotifyPropertyChanged(); } - } + public CustomObservableCollection SelectableElements { get; } = []; + public CustomObservableCollection Rows { get; } = []; + public CustomObservableCollection PerformanceRows { get; } = []; + public CustomObservableCollection AssuranceOfAEPRows { get; } = []; + public CustomObservableCollection DamCatRows { get; } = []; public ScenarioDamageSummaryVM(List selectedScenarioElems) { @@ -97,12 +92,13 @@ private void LoadTables() Rows.Clear(); PerformanceRows.Clear(); AssuranceOfAEPRows.Clear(); + DamCatRows.Clear(); foreach (IASElement element in elems) { - Rows.Add(new ScenarioDamageRowItem(element)); - damCatRows.Add(new ScenarioDamCatRowItem(element)); - List resultsList = element.Results.ResultsList; - foreach (IContainImpactAreaScenarioResults impactAreaScenarioResults in resultsList) + Rows.AddRange(ScenarioDamageRowItem.CreateScenarioDamageRowItems(element)); + DamCatRows.AddRange(ScenarioDamCatRowItem.CreateScenarioDamCatRowItems(element)); + List resultsList = element.Results.ResultsList; + foreach (ImpactAreaScenarioResults impactAreaScenarioResults in resultsList) { int iasID = impactAreaScenarioResults.ImpactAreaID; SpecificIAS ias = element.SpecificIASElements.Where(ias => ias.ImpactAreaID == iasID).First(); @@ -114,7 +110,6 @@ private void LoadTables() } } } - LoadDamCatDataTable(damCatRows); } private void SelectElem_SelectionChanged(object sender, System.EventArgs e) @@ -134,59 +129,5 @@ private List GetSelectedElements() } return selectedElements; } - - private void LoadDamCatDataTable(List rows) - { - - _DamCatTable = new DataTable(); - DataColumn nameCol = new DataColumn("Name", typeof(string)); - _DamCatTable.Columns.Add(nameCol); - DataColumn yearCol = new DataColumn("Analysis Year", typeof(int)); - _DamCatTable.Columns.Add(yearCol); - List allUniqueDamCats = GetAllDamCats(rows); - foreach (string damCat in allUniqueDamCats) - { - _DamCatTable.Columns.Add( new DataColumn(damCat, typeof(string))); - } - - foreach(ScenarioDamCatRowItem row in rows) - { - AddDamCatRowToTable(row, allUniqueDamCats); - } - NotifyPropertyChanged(nameof(DamCatTable)); - } - - private void AddDamCatRowToTable(ScenarioDamCatRowItem row, List allDamCats) - { - DataRow myRow = _DamCatTable.NewRow(); - myRow["Name"] = row.Name; - myRow["Analysis Year"] = row.AnalysisYear; - foreach(string damCat in allDamCats) - { - if(row.DamCatMap.ContainsKey(damCat)) - { - myRow[damCat] = row.DamCatMap[damCat]; - } - else - { - //this scenario doesn't have a value for that dam cat. Assign 0. - myRow[damCat] = 0; - } - } - _DamCatTable.Rows.Add(myRow); - } - - private List GetAllDamCats(List rows) - { - HashSet uniqueDamCats = new HashSet(); - foreach(ScenarioDamCatRowItem row in rows) - { - foreach(string damCat in row.DamCatMap.Keys) - { - uniqueDamCats.Add(damCat); - } - } - return uniqueDamCats.ToList(); - } } } diff --git a/lib/DatabaseManager.dll b/lib/DatabaseManager.dll deleted file mode 100644 index 72f57a6a9..000000000 Binary files a/lib/DatabaseManager.dll and /dev/null differ