public void SetTotalLCA1Total1Attributes(LCA1Total1 ind, string attNameExtension, ref XmlWriter writer) { bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); bool bIsBoth = (bIsBenefitNode == false && bIsCostNode == false) ? true : false; if (bIsCostNode || bIsBoth) { writer.WriteAttributeString( string.Concat(cTotalOCCost, attNameExtension), ind.TotalOCCost.ToString("f2")); writer.WriteAttributeString( string.Concat(cTotalAOHCost, attNameExtension), ind.TotalAOHCost.ToString("f2")); writer.WriteAttributeString( string.Concat(cTotalCAPCost, attNameExtension), ind.TotalCAPCost.ToString("f2")); writer.WriteAttributeString( string.Concat(cTotalLCCCost, attNameExtension), ind.TotalLCCCost.ToString("f2")); writer.WriteAttributeString( string.Concat(cTotalEAACost, attNameExtension), ind.TotalEAACost.ToString("f2")); writer.WriteAttributeString( string.Concat(cTotalUnitCost, attNameExtension), ind.TotalUnitCost.ToString("f2")); } if (bIsBenefitNode || bIsBoth) { writer.WriteAttributeString( string.Concat(cTotalRBenefit, attNameExtension), ind.TotalRBenefit.ToString("f2")); writer.WriteAttributeString( string.Concat(cTotalLCBBenefit, attNameExtension), ind.TotalLCBBenefit.ToString("f2")); writer.WriteAttributeString( string.Concat(cTotalREAABenefit, attNameExtension), ind.TotalREAABenefit.ToString("f2")); writer.WriteAttributeString( string.Concat(cTotalRUnitBenefit, attNameExtension), ind.TotalRUnitBenefit.ToString("f2")); } }
public void SetTotalNPV1Total1Attributes(NPV1Total1 ind, string attNameExtension, ref XmlWriter writer) { bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); bool bIsBoth = (bIsBenefitNode == false && bIsCostNode == false) ? true : false; if (bIsCostNode || bIsBoth) { ind.SetTotalCostsSummaryAttributes(attNameExtension, ref writer); if (this.CalcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.inputprices) { //limited ps and qs ind.SetTotalOCPricePsandQsAttributes(attNameExtension, ref writer); } else { if (this.CalcParameters.SubApplicationType != Constants.SUBAPPLICATION_TYPES.componentprices && this.CalcParameters.SubApplicationType != Constants.SUBAPPLICATION_TYPES.operationprices) { ind.SetTotalCostsSummaryNetsAttributes(attNameExtension, ref writer); } if (this.CalcParameters.CurrentElementNodeName.Contains(Input.INPUT_PRICE_TYPES.input.ToString())) { //limited ps and qs ind.SetTotalCostsPsandQsAttributes(attNameExtension, ref writer); } } } if (bIsBenefitNode || bIsBoth) { ind.SetTotalBenefitsSummaryAttributes(attNameExtension, ref writer); ind.SetTotalBenefitsPsandQsAttributes(attNameExtension, ref writer); } }
public virtual void SetTotalLCA1Total1Attributes(LCA1Total1 ind, string attNameExtension, ref XElement calculator) { bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); bool bIsBoth = (bIsBenefitNode == false && bIsCostNode == false) ? true : false; if (bIsCostNode || bIsBoth) { CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalOCCost, attNameExtension), ind.TotalOCCost); CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalAOHCost, attNameExtension), ind.TotalAOHCost); CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalCAPCost, attNameExtension), ind.TotalCAPCost); CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalLCCCost, attNameExtension), ind.TotalLCCCost); CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalEAACost, attNameExtension), ind.TotalEAACost); CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalUnitCost, attNameExtension), ind.TotalUnitCost); } if (bIsBenefitNode || bIsBoth) { CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalRBenefit, attNameExtension), ind.TotalRBenefit); CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalLCBBenefit, attNameExtension), ind.TotalLCBBenefit); CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalREAABenefit, attNameExtension), ind.TotalREAABenefit); CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalRUnitBenefit, attNameExtension), ind.TotalRUnitBenefit); } }
public virtual void SetTotalNPV1StocksAttributes(string attNameExt, ref XmlWriter writer) { //remember that the analyzer inheriting from this must .SetAnalyzerAtts bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); if (this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvstat1.ToString()) { if (this.Stat1 != null) { this.Stat1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; this.Stat1.CalcParameters.SubApplicationType = this.CalcParameters.SubApplicationType; //set the analysis this.Stat1.SetTotalNPV1Stat1Attributes( this.Stat1, attNameExt, ref writer); } } else if (this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangeyr.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangeid.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangealt.ToString()) { if (this.Change1 != null) { this.Change1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; this.Change1.CalcParameters.SubApplicationType = this.CalcParameters.SubApplicationType; //set the analysis this.Change1.SetTotalNPV1Change1Attributes( this.Change1, attNameExt, ref writer); } } else if (this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvprogress1.ToString()) { if (this.Progress1 != null) { this.Progress1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; this.Progress1.CalcParameters.SubApplicationType = this.CalcParameters.SubApplicationType; //set the analysis this.Progress1.SetTotalNPV1Progress1Attributes( this.Progress1, attNameExt, ref writer); } } else { if (this.Total1 != null) { this.Total1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; this.Total1.CalcParameters.SubApplicationType = this.CalcParameters.SubApplicationType; //set the analysis this.Total1.SetTotalNPV1Total1Attributes(this.Total1, attNameExt, ref writer); } } }
public void SetTotalMN1Total1Attributes(MN1Total1 ind, string attNameExtension, ref XmlWriter writer) { bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); bool bIsBoth = (bIsBenefitNode == false && bIsCostNode == false) ? true : false; if (bIsCostNode || bIsBoth) { writer.WriteAttributeString( string.Concat(cTotalFNIndex, attNameExtension), ind.TotalFNIndex.ToString("f2")); } if (bIsBenefitNode || bIsBoth) { } }
public virtual void SetTotalMN1Total1Attributes(MN1Total1 ind, string attNameExtension, ref XElement calculator) { bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); bool bIsBoth = (bIsBenefitNode == false && bIsCostNode == false) ? true : false; if (bIsCostNode || bIsBoth) { CalculatorHelpers.SetAttributeDoubleF2(calculator, string.Concat(cTotalFNIndex, attNameExtension), ind.TotalFNIndex); } if (bIsBenefitNode || bIsBoth) { } }
public void SetTotalNPV1Stat1Attributes(NPV1Stat1 ind, string attNameExtension, ref XmlWriter writer) { bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); bool bIsBoth = (bIsBenefitNode == false && bIsCostNode == false) ? true : false; if (bIsCostNode || bIsBoth) { writer.WriteAttributeString( string.Concat(TCostN, attNameExtension), ind.TotalCostN.ToString("N2", CultureInfo.InvariantCulture)); if (this.CalcParameters.CurrentElementNodeName.Contains(Input.INPUT_PRICE_TYPES.input.ToString())) { //tamincent will be extra in prices ind.SetAmortCosts2Attributes(attNameExtension, ref writer); if (this.CalcParameters.SubApplicationType != Constants.SUBAPPLICATION_TYPES.inputprices) { //no stats for tech inputs, but show totals ind.SetTotalCostsPsandQsAttributes(attNameExtension, ref writer); } } else { ind.SetAmortCosts2Attributes(attNameExtension, ref writer); if (this.CalcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.budgets || this.CalcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.investments) { ind.SetAmortNets2Attributes(attNameExtension, ref writer); } } } if (bIsBenefitNode || bIsBoth) { writer.WriteAttributeString( string.Concat(TBenefitN, attNameExtension), ind.TotalBenefitN.ToString("N2", CultureInfo.InvariantCulture)); //a few extra atts for prices ind.SetAmortBenefits2Attributes(attNameExtension, ref writer); ind.SetAmortBenefits2PsandQsAttributes(attNameExtension, ref writer); } }
public virtual void SetTotalLCA1StocksAttributes(string attNameExt, ref XmlWriter writer) { //remember that the analyzer inheriting from this must .SetAnalyzerAtts bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); if (this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcastat1.ToString()) { if (this.Stat1 != null) { this.Stat1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; //set the analysis this.Stat1.SetTotalLCA1Stat1Attributes( this.Stat1, attNameExt, ref writer); if (bIsCostNode) { //set the costs this.Stat1.SubP1Stock.SetTotalSubPrice1StocksAttributes(attNameExt, ref writer); } else if (bIsBenefitNode) { //set the benefits this.Stat1.SubP2Stock.SetTotalSubPrice2StocksAttributes(attNameExt, ref writer); } else { //set both this.Stat1.SubP1Stock.SetTotalSubPrice1StocksAttributes(attNameExt, ref writer); this.Stat1.SubP2Stock.SetTotalSubPrice2StocksAttributes(attNameExt, ref writer); } } } else if (this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcachangeyr.ToString() || this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcachangeid.ToString() || this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcachangealt.ToString()) { if (this.Change1 != null) { this.Change1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; //set the analysis this.Change1.SetTotalLCA1Change1Attributes( this.Change1, attNameExt, ref writer); if (bIsCostNode) { //set the costs this.Change1.SubP1Stock.SetTotalSubPrice1StocksAttributes(attNameExt, ref writer); } else if (bIsBenefitNode) { //set the benefits this.Change1.SubP2Stock.SetTotalSubPrice2StocksAttributes(attNameExt, ref writer); } else { //set both this.Change1.SubP1Stock.SetTotalSubPrice1StocksAttributes(attNameExt, ref writer); this.Change1.SubP2Stock.SetTotalSubPrice2StocksAttributes(attNameExt, ref writer); } } } else if (this.AnalyzerType == LCA1AnalyzerHelper.ANALYZER_TYPES.lcaprogress1.ToString()) { if (this.Progress1 != null) { this.Progress1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; //set the analysis this.Progress1.SetTotalLCA1Progress1Attributes( this.Progress1, attNameExt, ref writer); if (bIsCostNode) { //set the costs this.Progress1.SubP1Stock.SetTotalSubPrice1StocksAttributes(attNameExt, ref writer); } else if (bIsBenefitNode) { //set the benefits this.Progress1.SubP2Stock.SetTotalSubPrice2StocksAttributes(attNameExt, ref writer); } else { //set both this.Progress1.SubP1Stock.SetTotalSubPrice1StocksAttributes(attNameExt, ref writer); this.Progress1.SubP2Stock.SetTotalSubPrice2StocksAttributes(attNameExt, ref writer); } } } else { if (this.Total1 != null) { this.Total1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; //set the analysis this.Total1.SetTotalLCA1Total1Attributes( this.Total1, attNameExt, ref writer); if (bIsCostNode) { //set the costs this.Total1.SubP1Stock.SetTotalSubPrice1StocksAttributes(attNameExt, ref writer); } else if (bIsBenefitNode) { //set the benefits this.Total1.SubP2Stock.SetTotalSubPrice2StocksAttributes(attNameExt, ref writer); } else { //set both this.Total1.SubP1Stock.SetTotalSubPrice1StocksAttributes(attNameExt, ref writer); this.Total1.SubP2Stock.SetTotalSubPrice2StocksAttributes(attNameExt, ref writer); } } } }
public virtual void SetTotalMN1StockAttributes(string attNameExt, ref XmlWriter writer) { //remember that the analyzer inheriting from this must .SetAnalyzerAtts if (this.AnalyzerType == MN1AnalyzerHelper.ANALYZER_TYPES.mnstat1.ToString()) { if (this.Stat1 != null) { //set the analysis this.Stat1.SetTotalMN1Stat1Attributes( this.Stat1, attNameExt, ref writer); } } else if (this.AnalyzerType == MN1AnalyzerHelper.ANALYZER_TYPES.mnchangeyr.ToString() || this.AnalyzerType == MN1AnalyzerHelper.ANALYZER_TYPES.mnchangeid.ToString() || this.AnalyzerType == MN1AnalyzerHelper.ANALYZER_TYPES.mnchangealt.ToString()) { if (this.Change1 != null) { //set the analysis this.Change1.SetTotalMN1Change1Attributes( this.Change1, attNameExt, ref writer); } } else if (this.AnalyzerType == MN1AnalyzerHelper.ANALYZER_TYPES.mnprogress1.ToString()) { if (this.Progress1 != null) { this.Progress1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; //set the analysis this.Progress1.SetTotalMN1Progress1Attributes( this.Progress1, attNameExt, ref writer); } } else { if (this.Total1 != null) { bool bIsCostNode = CalculatorHelpers.IsCostNode(this.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(this.CalcParameters.CurrentElementNodeName); this.Total1.CalcParameters.CurrentElementNodeName = this.CalcParameters.CurrentElementNodeName; //set the analysis this.Total1.SetTotalMN1Total1Attributes( this.Total1, attNameExt, ref writer); if (bIsCostNode) { //set the costs this.Total1.MNSR1Stock.SetTotalMNSR01StockAttributes(attNameExt, ref writer); } else if (bIsBenefitNode) { //set the benefits this.Total1.MNSR2Stock.SetTotalMNSR02StockAttributes(attNameExt, ref writer); } else { //stock01 is the net from subtracting outputs from inputs (otherwise too many nutr to display) this.Total1.MNSR1Stock.SetTotalMNSR01StockAttributes(attNameExt, ref writer); } } } }
private bool SetBaseAnalyses(NPV1Stock npv1Stock, List <Calculator1> calcs) { bool bHasAnalysis = false; bool bHasTotals = false; //set the calc totals in each observation int iCostN2 = 0; int iBenefitN2 = 0; List <NPV1Stat1> stats2 = new List <NPV1Stat1>(); double dbMultiplier = 1; //this is the IO pattern: test if the Alt2 Pattern is still needed //make sure this does not need IEnumerable<System.Linq.IGrouping<int, Calculator1>> //calcsByAlt2 = calcs.GroupBy(c => c.Alternative2); //inputs and outputs use calc for each observation (not the Grouping.Alternative) foreach (Calculator1 calc in calcs) { if (calc.GetType().Equals(npv1Stock.GetType())) { NPV1Stock stock = (NPV1Stock)calc; if (stock != null) { if (stock.Stat1 != null) { //set the calc totals in each observation NPV1Stock observation2Stock = new NPV1Stock(stock.Stat1.CalcParameters, stock.Stat1.CalcParameters.AnalyzerParms.AnalyzerType); observation2Stock.Stat1 = new NPV1Stat1(); observation2Stock.Stat1.CalcParameters = new CalculatorParameters(stock.Stat1.CalcParameters); //since Stat1 is new, this method will not accrue totals //but it will set N //calc.Multiplier not used because base calcs used it bHasTotals = AddSubTotalToTotalStock(observation2Stock.Stat1, dbMultiplier, stock.Stat1); if (bHasTotals) { //add to the stats collection stats2.Add(observation2Stock.Stat1); bool bIsCostNode = CalculatorHelpers.IsCostNode(stock.CalcParameters.CurrentElementNodeName); bool bIsBenefitNode = CalculatorHelpers.IsBenefitNode(stock.CalcParameters.CurrentElementNodeName); if (bIsCostNode) { iCostN2++; } else if (bIsBenefitNode) { iBenefitN2++; } else { iCostN2++; iBenefitN2++; } } } } } } if (iCostN2 > 0 || iBenefitN2 > 0) { bHasAnalysis = true; bHasTotals = SetStatsAnalysis(stats2, npv1Stock, iCostN2, iBenefitN2); } return(bHasAnalysis); }