//define the actions to take when the event is raised public void AddDevPackCalculations(object sender, CustomEventArgs e) { bool bHasCalculations = false; //e.CalculatorParams = current devpack or devpackpart being processed //the file paths identify the document to run calcs on and the //uripattern identifies the node holding the linkedviews //note that e.CalcParams.ExtensionDoctoCalcURI.Resources[0] holds //parent contenturi used to start the extension //(with original doctocalc file that is used when the linkedview is needed) AgBudgetingHelpers abCalculatorHelper = new AgBudgetingHelpers(e.CalculatorParams); //run the calculations bHasCalculations = abCalculatorHelper .RunCalculations(); //pass the bool back to the publisher //by setting the HasCalculations property of CustomEventArgs e.HasCalculations = bHasCalculations; }
private bool RunInputOrOutputCalculation(XElement currentElement, XElement currentCalculationsElement, IDictionary <string, string> updates) { bool bHasCalculations = false; AgBudgetingHelpers.CALCULATOR_TYPES eCalculatorType = AgBudgetingHelpers.GetCalculatorType( this.GCCalculatorParams.CalculatorType); switch (eCalculatorType) { case AgBudgetingHelpers.CALCULATOR_TYPES.agmachinery: bHasCalculations = Machinery1InputCalculator.SetMachinery1Calculations( eCalculatorType, this.GCCalculatorParams, currentCalculationsElement, currentElement, updates); break; case AgBudgetingHelpers.CALCULATOR_TYPES.irrpower: bHasCalculations = Machinery1InputCalculator.SetMachinery1Calculations( eCalculatorType, this.GCCalculatorParams, currentCalculationsElement, currentElement, updates); break; case AgBudgetingHelpers.CALCULATOR_TYPES.lifecycle: bHasCalculations = Machinery1InputCalculator.SetMachinery1Calculations( eCalculatorType, this.GCCalculatorParams, currentCalculationsElement, currentElement, updates); break; case AgBudgetingHelpers.CALCULATOR_TYPES.gencapital: bHasCalculations = Machinery1InputCalculator.SetMachinery1Calculations( eCalculatorType, this.GCCalculatorParams, currentCalculationsElement, currentElement, updates); break; default: break; } return(bHasCalculations); }
public async Task <bool> RunCalculatorStep( ExtensionContentURI extDocToCalcURI, ExtensionContentURI extCalcDocURI, string stepNumber, IList <string> urisToAnalyze, IDictionary <string, string> updates, CancellationToken cancellationToken) { bool bHasCalculation = false; CalculatorHelpers eCalcHelpers = new CalculatorHelpers(); CalculatorParameters ABCalcParams = CalculatorHelpers.SetCalculatorParameters( extDocToCalcURI, extCalcDocURI, stepNumber, urisToAnalyze, updates); AgBudgetingHelpers agBudgetHelpers = new AgBudgetingHelpers(ABCalcParams); ContractHelpers.EXTENSION_STEPS eStepNumber = ContractHelpers.GetEnumStepNumber(stepNumber); bool bHasUpdates = false; switch (eStepNumber) { case ContractHelpers.EXTENSION_STEPS.stepzero: bHasCalculation = true; break; case ContractHelpers.EXTENSION_STEPS.stepone: bHasCalculation = true; break; case ContractHelpers.EXTENSION_STEPS.steptwo: //clear updates collection updates.Clear(); if (ABCalcParams != null) { //set constants for this step bHasCalculation = await AgBudgetingHelpers.SetConstants(ABCalcParams); } extDocToCalcURI.URIDataManager.NeedsFullView = false; extDocToCalcURI.URIDataManager.NeedsSummaryView = false; break; case ContractHelpers.EXTENSION_STEPS.stepthree: //get rid of any update member that was added after running the same step 2x bHasUpdates = await CalculatorHelpers.RefreshUpdates(ABCalcParams, stepNumber, updates); if (ABCalcParams != null) { bHasCalculation = await AgBudgetingHelpers.SetConstants(ABCalcParams); } extDocToCalcURI.URIDataManager.NeedsFullView = false; extDocToCalcURI.URIDataManager.NeedsSummaryView = false; break; case ContractHelpers.EXTENSION_STEPS.stepfour: //get rid of any update member that was added after running the same step 2x bHasUpdates = await CalculatorHelpers.RefreshUpdates(ABCalcParams, stepNumber, updates); if (ABCalcParams != null) { if (ABCalcParams.ExtensionDocToCalcURI.URIDataManager.SubAppType != Constants.SUBAPPLICATION_TYPES.devpacks.ToString()) { //run the calculations bHasCalculation = await agBudgetHelpers.RunCalculations(); } else { //run custom document calculations bHasCalculation = await agBudgetHelpers.RunDevPacksCalculations(ABCalcParams); } if (!bHasCalculation) { extDocToCalcURI.ErrorMessage = (extDocToCalcURI.ErrorMessage == string.Empty) ? Errors.MakeStandardErrorMsg("CALCULATORS_URI_MISMATCH") : extDocToCalcURI.ErrorMessage; return(bHasCalculation); } if (string.IsNullOrEmpty(extDocToCalcURI.ErrorMessage)) { //two step calculators need to be saved now AgBudgetingHelpers.CALCULATOR_TYPES eCalculatorType = AgBudgetingHelpers.GetCalculatorType( ABCalcParams.CalculatorType); CheckForLastStepCalculator(eCalculatorType, eStepNumber, extDocToCalcURI); //replace the old calculator with the new one //and save the new calculations document bHasCalculation = await CalculatorHelpers.SaveNewCalculationsDocument(ABCalcParams); } else { bHasCalculation = false; } } extDocToCalcURI.URIDataManager.NeedsFullView = true; extDocToCalcURI.URIDataManager.NeedsSummaryView = false; break; case ContractHelpers.EXTENSION_STEPS.stepfive: extDocToCalcURI.URIDataManager.NeedsFullView = false; extDocToCalcURI.URIDataManager.NeedsSummaryView = true; extCalcDocURI.URIFileExtensionType = CalculatorHelpers.GetAttribute(ABCalcParams.LinkedViewElement, Calculator1.cFileExtensionType); bHasCalculation = true; //tells addinhelper to save calcs CalculatorHelpers.SetTempDocSaveCalcsProperty(extDocToCalcURI); break; default: //as many steps as needed can be added to this addin break; } extDocToCalcURI.ErrorMessage += ABCalcParams.ErrorMessage; return(bHasCalculation); }