public void AdjustJointOutputCalculations( Output output, ref XElement currentCalculationsElement, CalculatorParameters calcParameters) { //transfer changes found in calcParams.ParentOutcome.Outputs[] //to this output, prior to discounting if (calcParameters.ParentOutcome.Outputs != null) { int iOutputId = output.Id; Output adjustedOutput = calcParameters.ParentOutcome.Outputs .FirstOrDefault(i => i.Id == iOutputId && i.Type == CostBenefitCalculator.TYPE_NEWCALCS); if (adjustedOutput != null) { //replace output output.CopyOutput(adjustedOutput); //output = new Output(adjustedOutput); if (adjustedOutput.XmlDocElement != null) { //adjustments can change fuel amounts, AOHAmounts ... output.XmlDocElement = new XElement(adjustedOutput.XmlDocElement); string sId = CalculatorHelpers.GetAttribute(currentCalculationsElement, Calculator1.cId); currentCalculationsElement = CalculatorHelpers.GetChildLinkedViewUsingAttribute( adjustedOutput.XmlDocElement, Calculator1.cId, sId); } } } }
//copy constructor public OperationComponent(CalculatorParameters calcParameters, OperationComponent operationorcomponent) { //several extensions store some calculator props in base element (observations, targettype) //no harm done in setting them but never set their attributes this.CopyCalculatorProperties(operationorcomponent); this.CopySharedObjectProperties(operationorcomponent); this.Amount = operationorcomponent.Amount; this.Unit = operationorcomponent.Unit; this.Weight = operationorcomponent.Weight; this.EffectiveLife = operationorcomponent.EffectiveLife; this.SalvageValue = operationorcomponent.SalvageValue; this.IncentiveAmount = operationorcomponent.IncentiveAmount; this.IncentiveRate = operationorcomponent.IncentiveRate; this.TimePeriodId = operationorcomponent.TimePeriodId; this.Type = operationorcomponent.Type; this.ErrorMessage = operationorcomponent.ErrorMessage; this.AnnuityType = operationorcomponent.AnnuityType; this.AnnuityCount = operationorcomponent.AnnuityCount; //better to set in base this.CopyTotalCostsProperties(operationorcomponent); //calculators are always app-specific and must be copied subsequently this.Calculators = new List <Calculator1>(); if (operationorcomponent.Local == null) { operationorcomponent.Local = new Local(); } this.Local = new Local(calcParameters, operationorcomponent.Local); if (operationorcomponent.XmlDocElement != null) { this.XmlDocElement = new XElement(operationorcomponent.XmlDocElement); } }
public void SetDescendantLCA1StockInputAttributes(string attNameExt, CalculatorParameters calcParams, ref XmlWriter writer) { //the lcatotal1 analyzer adds its totals to the base lcc1calculator linked view //less duplication and easier to display and extend if (writer != null) { //set the base analyzer this.SetCalculatorAttributes(attNameExt, ref writer); bool bHasCalcs = false; if (this.SubP1Stock.SubPrice1s != null) { if (this.SubP1Stock.SubPrice1s.Count > 0) { LCC1Calculator lcc = (LCC1Calculator)this.SubP1Stock.SubPrice1s.FirstOrDefault(); if (lcc != null) { //set locals lcc.LCCInput.Local.SetLocalAttributesForCalculator(attNameExt, calcParams, ref writer); lcc.SetLCC1Attributes(attNameExt, ref writer); bHasCalcs = true; } } } //don't need both subps and subpstock if (!bHasCalcs) { this.SetTotalLCA1StocksAttributes(attNameExt, ref writer); } } }
public void SetLocalAttributesForCalculator(string attNameExt, CalculatorParameters calcParameters, ref XmlWriter writer) { if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.locals) { this.SetCalculatorAttributes(attNameExt, ref writer); } writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.UNITGROUP_ID, attNameExt), this.UnitGroupId.ToString()); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.CURRENCYGROUP_ID, attNameExt), this.CurrencyGroupId.ToString()); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.REAL_RATE_ID, attNameExt), this.RealRateId.ToString()); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.NOMINAL_RATE_ID, attNameExt), this.NominalRateId.ToString()); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.RATINGGROUP_ID, attNameExt), this.RatingGroupId.ToString()); if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.locals) { writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.DATASOURCEPRICE_ID, attNameExt), this.DataSourcePriceId.ToString()); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.GEOCODEPRICE_ID, attNameExt), this.GeoCodePriceId.ToString()); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.DATASOURCETECH_ID, attNameExt), this.DataSourceTechId.ToString()); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.GEOCODETECH_ID, attNameExt), this.GeoCodeTechId.ToString()); } writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.REAL_RATE, attNameExt), this.RealRate.ToString("f3")); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.NOMINAL_RATE, attNameExt), this.NominalRate.ToString("f3")); writer.WriteAttributeString( string.Concat(DataAppHelpers.Locals.INFLATION_RATE, attNameExt), this.InflationRate.ToString("f3")); }
//constructor sets class (base) properties public OCMachineryStockSubscriber(CalculatorParameters calcParameters) : base(calcParameters) { if (calcParameters.RelatedCalculatorType == AgBudgetingHelpers.CALCULATOR_TYPES.agmachinery.ToString()) { if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType == ARSAnalyzerHelper.ANALYZER_TYPES.resources02.ToString()) { this.Machinery2StockCalculator = new OCMachinery2StockCalculator(calcParameters); } else if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType == ARSAnalyzerHelper.ANALYZER_TYPES.resources02a.ToString()) { this.Machinery2StockCalculator = new OCMachinery2StockCalculator(calcParameters); } else { this.MachineryStockCalculator = new OCMachineryStockCalculator(calcParameters); } } else if (calcParameters.RelatedCalculatorType == AgBudgetingHelpers.CALCULATOR_TYPES.irrpower.ToString()) { this.IrrPowerStockCalculator = new OCIrrPowerStockCalculator(calcParameters); } else if (calcParameters.RelatedCalculatorType == AgBudgetingHelpers.CALCULATOR_TYPES.gencapital.ToString()) { this.GeneralCapitalStockCalculator = new OCGeneralCapitalStockCalculator(calcParameters); } }
//constructor sets class properties public ARSTextSubscriber(CalculatorParameters calcParameters, ARSAnalyzerHelper.ANALYZER_TYPES analyzerType) : base(calcParameters) { //the base class holds the parameters this.AnalyzerType = analyzerType; }
public BIME2StockCalculator(CalculatorParameters calcParameters) : base(calcParameters) { //base sets calc and analysis //this needs to set Indic1Stock Init(); }
public bool SetSB1B1Calculations( SB1CalculatorHelper.CALCULATOR_TYPES calculatorType, CalculatorParameters calcParameters, XElement calculator, XElement currentElement) { bool bHasCalculations = false; InitSB1B1Properties(); //deserialize xml to object //set the base output properties (including local) this.SB1BOutput.SetOutputProperties(calcParameters, calculator, currentElement); this.SetSB1B1Properties(calculator, currentElement); bHasCalculations = RunSB1B1CalculationsAsync(calcParameters).Result; if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.outputprices) { //serialize object back to xml and fill in updates list this.SB1BOutput.SetOutputAttributes(calcParameters, currentElement, calcParameters.Updates); } else { } this.SetSB1B1Attributes(string.Empty, calculator); //set the totals into calculator this.SB1BOutput.SetNewOutputAttributes(calcParameters, calculator); CalculatorHelpers.SetCalculatorId( calculator, currentElement); return(bHasCalculations); }
//serialize regular input properties public void SetNewInputAttributes(CalculatorParameters calcParameters, ref XElement elementNeedingAttributes) { CalculatorHelpers.SetAttributeDateS(elementNeedingAttributes, DataAppHelpers.Prices.INPUT_DATE, this.Date); CalculatorHelpers.SetAttributeDoubleF3(elementNeedingAttributes, DataAppHelpers.Prices.OC_AMOUNT, this.OCAmount); CalculatorHelpers.SetAttributeDoubleF3(elementNeedingAttributes, DataAppHelpers.Prices.OC_PRICE, this.OCPrice); CalculatorHelpers.SetAttribute(elementNeedingAttributes, DataAppHelpers.Prices.OC_UNIT, this.OCUnit); CalculatorHelpers.SetAttributeDoubleF3(elementNeedingAttributes, DataAppHelpers.Prices.AOH_AMOUNT, this.AOHAmount); CalculatorHelpers.SetAttributeDoubleF3(elementNeedingAttributes, DataAppHelpers.Prices.AOH_PRICE, this.AOHPrice); CalculatorHelpers.SetAttribute(elementNeedingAttributes, DataAppHelpers.Prices.AOH_UNIT, this.AOHUnit); CalculatorHelpers.SetAttributeDoubleF3(elementNeedingAttributes, DataAppHelpers.Prices.CAP_AMOUNT, this.CAPAmount); CalculatorHelpers.SetAttributeDoubleF3(elementNeedingAttributes, DataAppHelpers.Prices.CAP_PRICE, this.CAPPrice); CalculatorHelpers.SetAttribute(elementNeedingAttributes, DataAppHelpers.Prices.CAP_UNIT, this.CAPUnit); CalculatorHelpers.SetAttribute(elementNeedingAttributes, DataAppHelpers.Economics1.ANNUITY_TYPE, this.AnnuityType.ToString()); if (this.Local != null) { //locals only for calculator this.Local.SetLocalAttributesForCalculator(calcParameters, ref elementNeedingAttributes); } }
public void SetDescendantNPV1StockOutputAttributes(string attNameExt, CalculatorParameters calcParams, ref XmlWriter writer) { //the npvtotal1 analyzer adds its totals to the base lcb1calculator linked view //less duplication and easier to extend if (writer != null) { if (this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvtotal1.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvstat1.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangeyr.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangeid.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvchangealt.ToString() || this.AnalyzerType == NPV1AnalyzerHelper.ANALYZER_TYPES.npvprogress1.ToString()) { this.SetCalculatorAttributes(attNameExt, ref writer); bool bHasCalcs = false; //don't need both subps and subpstock if (!bHasCalcs) { //set the analysis this.SetTotalNPV1StocksAttributes(attNameExt, ref writer); } } } }
//constructors //constructor sets class (base) properties public BIMachineryStockSubscriber(CalculatorParameters calcParameters) : base(calcParameters) { //this calls the constructors which also inherit from bicalculator for base params if (calcParameters.RelatedCalculatorType == AgBudgetingHelpers.CALCULATOR_TYPES.agmachinery.ToString()) { if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType == ARSAnalyzerHelper.ANALYZER_TYPES.resources02.ToString()) { this.BIM2Calculator = new BIMachinery2StockCalculator(calcParameters); } else if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType == ARSAnalyzerHelper.ANALYZER_TYPES.resources02a.ToString()) { this.BIM2aCalculator = new BIMachinery2aStockCalculator(calcParameters); } else { this.BIM1Calculator = new BIMachineryStockCalculator(calcParameters); } } else if (calcParameters.RelatedCalculatorType == AgBudgetingHelpers.CALCULATOR_TYPES.irrpower.ToString()) { this.BIIP1Calculator = new BIIrrPowerStockCalculator(calcParameters); } else if (calcParameters.RelatedCalculatorType == AgBudgetingHelpers.CALCULATOR_TYPES.gencapital.ToString()) { this.BIGC1Calculator = new BIGeneralCapitalStockCalculator(calcParameters); } }
private static void SerializeChildrenInputs(OperationComponent opComp, CalculatorParameters calcParameters, XElement currentCalculator, ref XElement opCompEl, IDictionary<string, string> updates) { //serialize and add children inputs to operationEl if (opComp.Inputs != null) { foreach (Input input in opComp.Inputs) { XElement inputEl = null; if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.budgets) { inputEl = new XElement(BudgetInvestment.BUDGET_TYPES.budgetinput.ToString()); } else if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.investments) { inputEl = new XElement(BudgetInvestment.INVESTMENT_TYPES.investmentinput.ToString()); } input.SetSharedObjectAttributes(string.Empty, ref inputEl); input.SetNewInputAttributes(calcParameters, ref inputEl); input.SetTotalCostsAttributes(string.Empty, ref inputEl); opCompEl.Add(inputEl); } } }
private static void SerializeChildrenOutputs(Outcome outcome, CalculatorParameters calcParameters, XElement currentCalculator, ref XElement outcomeEl, IDictionary<string, string> updates) { //serialize and add childrent inputs to operationEl if (outcome.Outputs != null) { foreach (Output output in outcome.Outputs) { XElement outputEl = null; if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.budgets) { outputEl = new XElement(BudgetInvestment.BUDGET_TYPES.budgetoutput.ToString()); } else if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.investments) { outputEl = new XElement(BudgetInvestment.INVESTMENT_TYPES.investmentoutput.ToString()); } output.SetSharedObjectAttributes(string.Empty, ref outputEl); output.SetNewOutputAttributes(calcParameters, ref outputEl); output.SetTotalBenefitsAttributes(string.Empty, ref outputEl); outcomeEl.Add(outputEl); } } }
public bool SetSB1C1Calculations( SB1CalculatorHelper.CALCULATOR_TYPES calculatorType, CalculatorParameters calcParameters, XElement calculator, XElement currentElement) { bool bHasCalculations = false; InitSB1C1Properties(); //deserialize xml to object //set the base input properties //locals come from input this.SB1CInput.SetInputProperties(calcParameters, calculator, currentElement); //set the calculator this.SetSB1C1Properties(calculator, currentElement); bHasCalculations = RunSB1C1CalculationsAsync(calcParameters).Result; //serialize object back to xml and fill in updates list if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.inputprices) { this.SB1CInput.SetInputAttributes(calcParameters, currentElement, calcParameters.Updates); } else { } //this sets and removes some atts this.SetSB1C1Attributes(string.Empty, calculator); //set the totals into calculator this.SB1CInput.SetNewInputAttributes(calcParameters, calculator); CalculatorHelpers.SetCalculatorId( calculator, currentElement); return(bHasCalculations); }
public virtual void SetHealthBenefit1Properties(CalculatorParameters calcParameters, XElement calculator, XElement currentElement) { SetOutputProperties(calcParameters, calculator, currentElement); SetHealthBenefit1Properties(calculator); }
//set the class properties using the XElement public void SetBudgetInvestmentProperties(CalculatorParameters calcParameters, XElement currentCalculationsElement, XElement currentElement) { //several extensions store some calculator props in base element (observations, targettype) //no harm done in setting them but never set their attributes in base element this.SetCalculatorProperties(currentCalculationsElement); this.SetSharedObjectProperties(currentElement); this.SetTotalBenefitsProperties(currentElement); this.SetTotalCostsProperties(currentElement); //this.Id = CalculatorHelpers.GetAttributeInt(currentElement, Calculator1.cId); this.InitialValue = CalculatorHelpers.GetAttributeDouble(currentElement, DataAppHelpers.Prices.INITIAL_VALUE); this.SalvageValue = CalculatorHelpers.GetAttributeDouble(currentElement, DataAppHelpers.Prices.SALVAGE_VALUE); this.InvestmentEAA = CalculatorHelpers.GetAttributeDouble(currentElement, INVESTMENTEAA); this.Local = new Local(); //can't use calcParams.CurrentElementURIPattern because also gets set from ancestors string sCurrentNodeURIPattern = CalculatorHelpers.MakeNewURIPatternFromElement( calcParameters.ExtensionDocToCalcURI.URIPattern, currentElement); this.Local = CalculatorHelpers.GetLocal(sCurrentNodeURIPattern, calcParameters, currentCalculationsElement, currentElement); this.XmlDocElement = currentCalculationsElement; }
public bool RunHCCalculations(CalculatorParameters calcParameters, HealthBenefit1Calculator hcBenefit1) { bool bHasCalculations = false; if (hcBenefit1 != null) { FixSelections(hcBenefit1); //calculate the adjusted benefit hcBenefit1.AdjustedBenefit = hcBenefit1.OutputCost * (hcBenefit1.BenefitAdjustment / 100); //set the base input properties //remember not to set amounts or the calcs have to be rerun in npv calcors hcBenefit1.Price = hcBenefit1.AdjustedBenefit; hcBenefit1.Unit = (hcBenefit1.Unit != string.Empty && hcBenefit1.Unit != Constants.NONE) ? hcBenefit1.Unit : Constants.EACH; //set the bcrating (equally weighted) SetAverageBenefitRating(hcBenefit1); bHasCalculations = true; } else { calcParameters.ErrorMessage = Errors.MakeStandardErrorMsg("CALCULATORS_WRONG_ONE"); } return(bHasCalculations); }
//set the XElement parameter's attributes using this class public void SetBudgetInvestmentAttributes(CalculatorParameters calcParameters, ref XElement currentElement, IDictionary <string, string> updates) { //version 1.4.5 requires setting calculator atts separately (so specific calc can be used) //serialize the current element this.SetSharedObjectAttributes(string.Empty, ref currentElement); this.SetTotalBenefitsAttributes(string.Empty, ref currentElement); this.SetTotalCostsAttributes(string.Empty, ref currentElement); DataHelpers.AddInHelperLinq.UpdateNewValue(calcParameters.AttributeNeedsDbUpdate, calcParameters.CurrentElementURIPattern, DataAppHelpers.Prices.INITIAL_VALUE, this.InitialValue.ToString("f2"), RuleHelpers.GeneralRules.DECIMAL, calcParameters.StepNumber, ref currentElement, updates); DataHelpers.AddInHelperLinq.UpdateNewValue(calcParameters.AttributeNeedsDbUpdate, calcParameters.CurrentElementURIPattern, DataAppHelpers.Prices.SALVAGE_VALUE, this.SalvageValue.ToString("f2"), RuleHelpers.GeneralRules.DECIMAL, calcParameters.StepNumber, ref currentElement, updates); CalculatorHelpers.SetAttributeDoubleF2(currentElement, INVESTMENTEAA, this.InvestmentEAA); if (this.Local == null) { this.Local = new Local(); } this.Local.SetLocalAttributes(calcParameters, ref currentElement, updates); //xmldoc atts are handled in the calculator helpers //any annuities on hand are serialized using AddGrowthPeriodsToBudgetInvestment(calcParameters, calcParameters.ParentBudgetInvestment.TimePeriods, ref currentElement); }
//copy constructor public BudgetInvestmentGroup(CalculatorParameters calcParameters, BudgetInvestmentGroup budgetOrInvestmentGroup) { //several extensions store some calculator props in base element (observations, targettype) //no harm done in setting them but never set their attributes this.CopyCalculatorProperties(budgetOrInvestmentGroup); this.CopySharedObjectProperties(budgetOrInvestmentGroup); this.DocStatus = budgetOrInvestmentGroup.DocStatus; this.ServiceId = budgetOrInvestmentGroup.ServiceId; this.Type = budgetOrInvestmentGroup.Type; //better to set in base this.CopyTotalBenefitsProperties(budgetOrInvestmentGroup); this.CopyTotalCostsProperties(budgetOrInvestmentGroup); //calculators are always app-specific and must be copied subsequently this.Calculators = new List <Calculator1>(); this.ErrorMessage = budgetOrInvestmentGroup.ErrorMessage; if (budgetOrInvestmentGroup.Local == null) { budgetOrInvestmentGroup.Local = new Local(); } this.Local = new Local(calcParameters, budgetOrInvestmentGroup.Local); if (budgetOrInvestmentGroup.XmlDocElement != null) { this.XmlDocElement = new XElement(budgetOrInvestmentGroup.XmlDocElement); } }
public static bool AddTimePeriodTotalsToTimePeriodsCollection( CalculatorParameters calcParameters, TimePeriod tp) { bool bHasAdded = false; if (calcParameters.ParentBudgetInvestment.TimePeriods != null) { if (calcParameters.ParentBudgetInvestment.TimePeriods.Count > 0) { bool bHasTimePeriod = calcParameters.ParentBudgetInvestment.TimePeriods. Any(c => c.Id == tp.Id); if (bHasTimePeriod) { int iIndex = GetTimePeriodIndex(calcParameters, tp); //remove the existing tp calcParameters.ParentBudgetInvestment.TimePeriods .RemoveAt(iIndex); //insert the calculated tp at the same index calcParameters.ParentBudgetInvestment.TimePeriods .Insert(iIndex, tp); bHasAdded = true; } } } return(bHasAdded); }
public void SetLocalProperties(CalculatorParameters calcParameters, XElement elementWithLocals, XElement currentElement) { //the host base is based on base calculator/analyzer properties (not currentElement) this.SetSharedObjectProperties(currentElement); this.Id = CalculatorHelpers.GetAttributeInt(currentElement, Calculator1.cId); this.UnitGroupId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.UNITGROUP_ID); this.CurrencyGroupId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.CURRENCYGROUP_ID); this.RealRateId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.REAL_RATE_ID); this.NominalRateId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.NOMINAL_RATE_ID); this.RatingGroupId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.RATINGGROUP_ID); if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.locals) { this.DataSourcePriceId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.DATASOURCEPRICE_ID); this.GeoCodePriceId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.GEOCODEPRICE_ID); this.DataSourceTechId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.DATASOURCETECH_ID); this.GeoCodeTechId = CalculatorHelpers.GetAttributeInt(elementWithLocals, DataAppHelpers.Locals.GEOCODETECH_ID); } this.RealRate = CalculatorHelpers.GetAttributeDouble(elementWithLocals, DataAppHelpers.Locals.REAL_RATE); this.NominalRate = CalculatorHelpers.GetAttributeDouble(elementWithLocals, DataAppHelpers.Locals.NOMINAL_RATE); this.InflationRate = CalculatorHelpers.GetAttributeDouble(elementWithLocals, DataAppHelpers.Locals.INFLATION_RATE); this.XmlDocElement = elementWithLocals; }
public static TimePeriod GetLastTimePeriod(CalculatorParameters calcParameters, TimePeriod currentTimePeriod) { TimePeriod lastTimePeriod = null; if (calcParameters.ParentBudgetInvestment.TimePeriods != null) { if (calcParameters.ParentBudgetInvestment.TimePeriods.Count > 0) { bool bHasTimePeriod = calcParameters.ParentBudgetInvestment.TimePeriods. Any(c => c.Id == currentTimePeriod.Id); if (bHasTimePeriod) { int iIndex = GetTimePeriodIndex(calcParameters, currentTimePeriod); //return the previous timeperiod if (iIndex > 0) { lastTimePeriod = calcParameters.ParentBudgetInvestment .TimePeriods[iIndex - 1]; } } } } return(lastTimePeriod); }
public bool AddCalculationsToCurrentElement( CalculatorParameters calcParameters, XElement currentCalculationsElement, XElement currentElement) { bool bHasCalculations = false; if (currentElement.Name.LocalName == Input.INPUT_PRICE_TYPES.inputgroup.ToString() && calcParameters.ExtensionDocToCalcURI.URINodeName != Constants.LINKEDVIEWS_TYPES.linkedview.ToString()) { bHasCalculations = BIM1Calculator.SetTotalMachineryStockCalculations( currentCalculationsElement, currentElement); } else { if (currentCalculationsElement != null) { Machinery1Input machInput = new Machinery1Input(); //deserialize xml to object machInput.SetMachinery1InputProperties(calcParameters, currentCalculationsElement, currentElement); //init analyzer props machInput.SetCalculatorProperties(currentCalculationsElement); //run the calculations bHasCalculations = RunMachineryStockCalculations(machInput, calcParameters); //serialize object back to xml (note that the base calc is not run here) string sAttNameExtension = string.Empty; //set new machinery input totals machInput.SetAndRemoveCalculatorAttributes(sAttNameExtension, currentCalculationsElement); machInput.SetMachinery1InputAttributes(calcParameters, currentCalculationsElement, currentElement); //set calculatorid (primary way to display calculation attributes) CalculatorHelpers.SetCalculatorId( currentCalculationsElement, currentElement); //input groups only aggregate inputs (not input series) if (currentElement.Name.LocalName .Contains(Input.INPUT_PRICE_TYPES.input.ToString())) { //add the machinery to the machstock.machstocks dictionary //the count is 1-based, while iNodePosition is 0-based //so the count is the correct next index position int iNodePosition = BIM1Calculator.MachineryStock .GetNodePositionCount(calcParameters.AnalyzerParms.FilePositionIndex, machInput); if (iNodePosition < 0) { iNodePosition = 0; } bHasCalculations = BIM1Calculator.MachineryStock .AddMachinery1StocksToDictionary( calcParameters.AnalyzerParms.FilePositionIndex, iNodePosition, machInput); } } } return(bHasCalculations); }
public static int GetTimePeriodIndex(CalculatorParameters calcParameters, TimePeriod currentTimePeriod) { int iIndex = 0; if (calcParameters.ParentBudgetInvestment.TimePeriods != null) { if (calcParameters.ParentBudgetInvestment.TimePeriods.Count > 0) { bool bHasTimePeriod = calcParameters.ParentBudgetInvestment.TimePeriods. Any(c => c.Id == currentTimePeriod.Id); if (bHasTimePeriod) { foreach (TimePeriod timePeriod in calcParameters.ParentBudgetInvestment.TimePeriods) { if (timePeriod.Id == currentTimePeriod.Id) { break; } iIndex += 1; } } } } return(iIndex); }
public bool RunDevPacksCalculations(CalculatorParameters calcParameters) { bool bHasCalculations = false; //these calculators use a mixed calculatorpatterns calcParameters.RunCalculatorType = CalculatorHelpers.RUN_CALCULATOR_TYPES.iotechnology; if (calcParameters.ExtensionDocToCalcURI.URIDataManager.SubAppType == Constants.SUBAPPLICATION_TYPES.inputprices.ToString() || calcParameters.ExtensionDocToCalcURI.URIDataManager.SubAppType == Constants.SUBAPPLICATION_TYPES.outputprices.ToString()) { calcParameters.RunCalculatorType = CalculatorHelpers.RUN_CALCULATOR_TYPES.basic; } //both calculators and analyzers both calculate a file in this path: calcParameters.AnalyzerParms.ObservationsPath = calcParameters.ExtensionDocToCalcURI.URIDataManager.TempDocPath; //prepare the event subscriber FNDevPacksSubscriber subDevPacks = new FNDevPacksSubscriber(calcParameters); //run the analyses (raising the publisher's events for each node) bHasCalculations = subDevPacks.RunDevPackCalculator(); CalculatorHelpers.UpdateCalculatorParams( calcParameters, subDevPacks.GCCalculatorParams); subDevPacks = null; return(bHasCalculations); }
private void AddObservation(XElement obsElement, ref CalculatorParameters calcParameters, ref string attName, ref string attValue) { string sAttributeValueList = string.Empty; //convert the attribute name to the statistical object property names //used in further analyses (i.e. output.amount to output.tramount) CostBenefitCalculator.ConvertAttributeNameToStatisticName( calcParameters.CurrentElementNodeName, ref attName); if (!string.IsNullOrEmpty(attName)) { if (obsElement.Attribute(attName) != null) { //add to the existing observations string sOldAttValue = CalculatorHelpers.GetAttribute( obsElement, attName); string sTotalAttsValue = string.Concat(sOldAttValue, Constants.STRING_DELIMITER, attValue); sAttributeValueList = string.Concat(sTotalAttsValue, Constants.FILENAME_DELIMITER, calcParameters.AnalyzerParms.FilePositionIndex.ToString()); //double delimited string: 2.52_1;3.25_1 attValue = sAttributeValueList; } else { //add to a new observation //always use standard delimited string sAttributeValueList = string.Concat(attValue, Constants.FILENAME_DELIMITER, calcParameters.AnalyzerParms.FilePositionIndex.ToString()); //double delimited string: 2.52_1;3.25_1 attValue = sAttributeValueList; } } }
public BIIrrPowerStockCalculator(CalculatorParameters calcParameters) : base(calcParameters) { //base sets calc and analysis //this needs to set machstock Init(); }
private bool RunOutputCalculations(OutputDiscounted outputDiscounted, CalculatorParameters calcParameters) { //this calculator does not do cumulative totals bool bHasCalculations = false; //outputs are discounted using the BudgetsandInvestments calculator //that calculator relies on 'ancestor' objects (ancestor xml nodes) //for some calculation parameters calcParameters.ParentBudgetInvestment = new BudgetInvestment(); calcParameters.ParentBudgetInvestment.Local = new Local(); calcParameters.ParentBudgetInvestment.Local.NominalRate = outputDiscounted.Local.NominalRate; calcParameters.ParentBudgetInvestment.Local.InflationRate = outputDiscounted.Local.InflationRate; calcParameters.ParentBudgetInvestment.Local.RealRate = outputDiscounted.Local.RealRate; calcParameters.ParentBudgetInvestment.InitEOPDate = outputDiscounted.EndOfPeriodDate; calcParameters.ParentBudgetInvestment.PreProdPeriods = 0; calcParameters.ParentBudgetInvestment.ProdPeriods = 1; calcParameters.ParentTimePeriod = new TimePeriod(); calcParameters.ParentTimePeriod.IsDiscounted = outputDiscounted.IsDiscounted; calcParameters.ParentTimePeriod.Date = outputDiscounted.EndOfPeriodDate; //convert discountedoutput to an Output object that can be used to run calcs Output output = OutputDiscounted.ConvertDiscountedOutput(calcParameters, outputDiscounted); XElement oCurrentCalculationElement = null; BICalculator biCalculator = new BICalculator(); bHasCalculations = biCalculator.SetOutputCalculations( calcParameters, output, oCurrentCalculationElement); //transfer the new calculations back to outputDiscounted (via its base output object) outputDiscounted.SetOutputProperties(calcParameters, output); return(bHasCalculations); }
public bool SetLCC1Calculations( LCA1CalculatorHelper.CALCULATOR_TYPES calculatorType, CalculatorParameters calcParameters, XElement calculator, XElement currentElement) { bool bHasCalculations = false; string sErrorMessage = string.Empty; //deserialize xml to object //set the base input properties (updates base input prices) //locals come from input this.LCCInput.SetInputProperties(calcParameters, calculator, currentElement); //set the calculator this.SetLCC1Properties(calculator, currentElement); bHasCalculations = RunLCC1Calculations(ref sErrorMessage); //serialize object back to xml and fill in updates list this.LCCInput.SetInputAttributes(calcParameters, currentElement, calcParameters.Updates); this.SetLCC1Attributes(string.Empty, calculator); //set the totals into calculator this.LCCInput.SetNewInputAttributes(calcParameters, calculator); //set calculatorid (primary way to display calculation attributes) CalculatorHelpers.SetCalculatorId( calculator, currentElement); calcParameters.ErrorMessage = sErrorMessage; return(bHasCalculations); }
public BIGeneralCapitalStockCalculator(CalculatorParameters calcParameters) : base(calcParameters) { //base sets calc and analysis //this needs to set machstock Init(calcParameters); }