public async Task <bool> RunAnalyzerStep( ExtensionContentURI extDocToCalcURI, ExtensionContentURI extCalcDocURI, string stepNumber, IList <string> urisToAnalyze, IDictionary <string, string> updates, CancellationToken cancellationToken) { bool bHasAnalysis = false; CalculatorParameters fnCalcParams = CalculatorHelpers.SetCalculatorParameters( extDocToCalcURI, extCalcDocURI, stepNumber, urisToAnalyze, updates); FNAnalyzerHelper fnAnalyzerHelper = new FNAnalyzerHelper(fnCalcParams); //check to make sure the analyzer can be run fnAnalyzerHelper.SetOptions(); if (fnAnalyzerHelper.FNCalculatorParams.ErrorMessage != string.Empty) { extDocToCalcURI.ErrorMessage += fnAnalyzerHelper.FNCalculatorParams.ErrorMessage; return(false); } ContractHelpers.EXTENSION_STEPS eStepNumber = ContractHelpers.GetEnumStepNumber(stepNumber); bool bHasUpdates = false; switch (eStepNumber) { case ContractHelpers.EXTENSION_STEPS.stepzero: bHasAnalysis = true; break; case ContractHelpers.EXTENSION_STEPS.stepone: bHasAnalysis = true; break; case ContractHelpers.EXTENSION_STEPS.steptwo: //clear updates collection updates.Clear(); //just need the html form edits in this step bHasAnalysis = true; 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(fnCalcParams, stepNumber, updates); if (fnAnalyzerHelper.AnalyzerType == FNAnalyzerHelper.ANALYZER_TYPES.resources01) { //linked view insertions needs some analysis parameters SetAnalyzerParameters(fnAnalyzerHelper, fnCalcParams); //the calculator pattern handles children linked view insertions //better than the analyzer pattern FNCalculatorHelper fnCalculatorHelper = new FNCalculatorHelper(fnCalcParams); bHasAnalysis = await fnCalculatorHelper.RunCalculations(); } else { //run the analysis (when analyses are available) //bHasAnalysis = fnAnalyzerHelper // .RunAnalysis(urisToAnalyze); } extDocToCalcURI.ErrorMessage = fnCalcParams.ErrorMessage; extDocToCalcURI.ErrorMessage += fnAnalyzerHelper.FNCalculatorParams.ErrorMessage; if (!bHasAnalysis) { extDocToCalcURI.ErrorMessage = (extDocToCalcURI.ErrorMessage == string.Empty) ? Errors.MakeStandardErrorMsg("CALCULATORS_URI_MISMATCH") : extDocToCalcURI.ErrorMessage; return(bHasAnalysis); } if (string.IsNullOrEmpty(extDocToCalcURI.ErrorMessage)) { //two step analyzers need to be saved now FNAnalyzerHelper.ANALYZER_TYPES eAnalyzerType = fnAnalyzerHelper.GetAnalyzerType( fnAnalyzerHelper.FNCalculatorParams.AnalyzerParms.AnalyzerType); //when 3+ step analyzers start being used CheckForLastStepAnalyzer(eAnalyzerType, eStepNumber, extDocToCalcURI); if (!CalculatorHelpers.IsSaveAction(extDocToCalcURI)) { //replace the old calculator with the new one //and save the new calculations document bool bHasReplacedCalcDoc = await CalculatorHelpers.SaveNewCalculationsDocument( fnAnalyzerHelper.FNCalculatorParams); if (bHasReplacedCalcDoc) { //the resource01 app uses the calculator, rather //than analyzer, pattern (i.e. children linked views //can be inserted) if (fnAnalyzerHelper.AnalyzerType != FNAnalyzerHelper.ANALYZER_TYPES.resources01) { //and add xmldoc params to update collection //only doctocalc gets updated CalculatorHelpers.AddXmlDocAndXmlDocIdsToUpdates( fnAnalyzerHelper.FNCalculatorParams); } bHasAnalysis = true; } else { extDocToCalcURI.ErrorMessage = Errors.MakeStandardErrorMsg("ANALYSES_ID_MISMATCH"); } } } else { bHasAnalysis = false; } extDocToCalcURI.URIDataManager.NeedsFullView = true; extDocToCalcURI.URIDataManager.NeedsSummaryView = false; break; case ContractHelpers.EXTENSION_STEPS.stepfour: bHasAnalysis = true; if (fnAnalyzerHelper.AnalyzerType == FNAnalyzerHelper.ANALYZER_TYPES.resources01) { extDocToCalcURI.URIDataManager.NeedsFullView = false; extDocToCalcURI.URIDataManager.NeedsSummaryView = true; extCalcDocURI.URIFileExtensionType = CalculatorHelpers.GetAttribute(fnCalcParams.LinkedViewElement, Calculator1.cFileExtensionType); } if (extDocToCalcURI.URIDataManager.TempDocSaveMethod == Constants.SAVECALCS_METHOD.saveastext.ToString()) { //analyzers aren't yet available } else { //tells addinhelper to save calcs CalculatorHelpers.SetTempDocSaveAnalysesProperty(extDocToCalcURI); } break; default: //as many steps as needed can be added to this addin break; } extDocToCalcURI.ErrorMessage += fnAnalyzerHelper.FNCalculatorParams.ErrorMessage; return(bHasAnalysis); }