private bool RunLCA1Calculation(LCA1CalculatorHelper.CALCULATOR_TYPES calculatorType, ref XElement currentElement, ref XElement currentCalculationsElement) { bool bHasCalculations = false; switch (calculatorType) { case LCA1CalculatorHelper.CALCULATOR_TYPES.buildcost1: //serialize, run calcs, and deserialize LCC1Calculator lcc1 = new LCC1Calculator(); bHasCalculations = lcc1.SetLCC1Calculations(calculatorType, this.GCCalculatorParams, ref currentCalculationsElement, ref currentElement); break; case LCA1CalculatorHelper.CALCULATOR_TYPES.buildbenefit1: //serialize, run calcs, and deserialize LCB1Calculator lcb1 = new LCB1Calculator(); bHasCalculations = lcb1.SetLCB1Calculations(calculatorType, this.GCCalculatorParams, ref currentCalculationsElement, ref currentElement); break; default: //should be running an analysis break; } return(bHasCalculations); }
//define the actions to take when the event is raised public void AddCalculations(object sender, CustomEventArgs e) { //pass a byref xelement from the publisher's data XElement statElement = null; XElement linkedViewElement = null; if (e.CurrentElement != null) { statElement = new XElement(e.CurrentElement); } if (e.LinkedViewElement != null) { linkedViewElement = new XElement(e.LinkedViewElement); } LCA1CalculatorHelper.CALCULATOR_TYPES eCalculatorType = LCA1CalculatorHelper.GetCalculatorType( this.GCCalculatorParams.CalculatorType); //run the stats and add them to statelement //run normally and save the same statelement and linkedviewelement e.HasCalculations = RunLCA1Analysis( statElement, linkedViewElement); if (e.HasCalculations) { //pass the new statelement back to the publisher //by setting the CalculatedElement property of CustomEventArgs if (statElement != null) { e.CurrentElement = new XElement(statElement); } if (linkedViewElement != null) { e.LinkedViewElement = new XElement(linkedViewElement); } } }
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); }
private static void CheckForLastStepCalculator( CalculatorParameters lca1CalcParams, ContractHelpers.EXTENSION_STEPS stepNumber, ExtensionContentURI extDocToCalcURI) { LCA1CalculatorHelper.CALCULATOR_TYPES eCalculatorType = LCA1CalculatorHelper.GetCalculatorType( lca1CalcParams.CalculatorType); //other projects have code for handling different //numbers of steps in calculators }