public async Task <bool> RunNPV1CalculatorCalculations()
        {
            bool             bHasCalculations = false;
            CALCULATOR_TYPES eCalculatorType
                = GetCalculatorType(this.NPV1CalculatorParams.CalculatorType);

            this.NPV1CalculatorParams.RunCalculatorType
                = CalculatorHelpers.RUN_CALCULATOR_TYPES.basic;
            this.NPV1CalculatorParams.AnalyzerParms.ObservationsPath
                = this.NPV1CalculatorParams.ExtensionDocToCalcURI.URIDataManager.TempDocPath;
            //note that running descendant calculations inserts a calculator
            //with all of its attributes into the descendant, but the descendant
            //may still need to have a calculation run
            IONPV1StockSubscriber subNPV1Calculator
                = new IONPV1StockSubscriber(this.NPV1CalculatorParams);

            //use NPVCalculators extension to run calculations
            switch (eCalculatorType)
            {
            case CALCULATOR_TYPES.npv:
                bHasCalculations = await subNPV1Calculator.RunCalculator();

                break;

            default:
                break;
            }
            CalculatorHelpers.UpdateCalculatorParams(this.NPV1CalculatorParams, subNPV1Calculator.GCCalculatorParams);
            //set parameters/attributes needed to update db and display this analysis
            SetCalculatorParameters();
            return(bHasCalculations);
        }
        public async Task <bool> RunAnalysis()
        {
            bool bHasAnalysis    = false;
            bool bHasAggregation = false;

            //must use analyzeobjects in order to get complete collections
            //otherwise ancestor nodes can't be serialized (no id spells trouble)
            this.NPV1CalculatorParams.RunCalculatorType
                = CalculatorHelpers.RUN_CALCULATOR_TYPES.analyzeobjects;
            //urisToAnalyze has the summary calculated results path in position 0.
            //This calculator uses that path to derive the the full calculated
            //results path. The full path document is used to run the calculations
            //(it has the input and output calculated results that are
            //the basis for most resource stock calculations).
            this.NPV1CalculatorParams.AnalyzerParms.ObservationsPath
                = await CalculatorHelpers.GetFullCalculatorResultsPath(
                      this.NPV1CalculatorParams);

            if (!await CalculatorHelpers.URIAbsoluteExists(this.NPV1CalculatorParams.ExtensionDocToCalcURI,
                                                           this.NPV1CalculatorParams.AnalyzerParms.ObservationsPath))
            {
                this.NPV1CalculatorParams.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYZER_BASECALCS_MISSING");
                return(false);
            }
            if (this.NPV1CalculatorParams.SubApplicationType
                == Constants.SUBAPPLICATION_TYPES.inputprices)
            {
                IONPV1StockSubscriber subInput
                             = new IONPV1StockSubscriber(this.NPV1CalculatorParams);
                bHasAnalysis = await subInput.RunCalculator();

                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BINPV1StockAnalyzer inputAnalyzer = new BINPV1StockAnalyzer(
                        subInput.GCCalculatorParams);
                    inputAnalyzer.InputGroup = subInput.NPV1StockCalculator.BINPV1Calculator.InputGroup;
                    //2. Aggregate the base NPV collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = inputAnalyzer.SetInputNPV1StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = await inputAnalyzer.SaveNPV1StockTotals();

                        inputAnalyzer = null;
                    }
                }
                subInput = null;
            }
            else if (this.NPV1CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.outputprices)
            {
                IONPV1StockSubscriber subOutput
                             = new IONPV1StockSubscriber(this.NPV1CalculatorParams);
                bHasAnalysis = await subOutput.RunCalculator();

                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BINPV1StockAnalyzer outputAnalyzer = new BINPV1StockAnalyzer(
                        subOutput.GCCalculatorParams);
                    outputAnalyzer.OutputGroup = subOutput.NPV1StockCalculator.BINPV1Calculator.OutputGroup;
                    //2. Aggregate the base NPV collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = outputAnalyzer.SetOutputNPV1StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = await outputAnalyzer.SaveNPV1StockTotals();

                        outputAnalyzer = null;
                    }
                }
                subOutput = null;
            }
            else if (this.NPV1CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.operationprices)
            {
                //build an object collection
                OCNPV1StockSubscriber subOperation
                             = new OCNPV1StockSubscriber(this.NPV1CalculatorParams);
                bHasAnalysis = await subOperation.RunCalculator();

                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BINPV1StockAnalyzer opAnalyzer = new BINPV1StockAnalyzer(
                        subOperation.GCCalculatorParams);
                    opAnalyzer.OCGroup = subOperation.NPV1StockCalculator.BINPV1Calculator.OCGroup;
                    //2. Aggregate the base NPV collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = opAnalyzer.SetOCNPV1StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = await opAnalyzer.SaveNPV1StockTotals();

                        opAnalyzer = null;
                    }
                }
                subOperation = null;
            }
            else if (this.NPV1CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.componentprices)
            {
                //build an object collection
                OCNPV1StockSubscriber subComponent
                             = new OCNPV1StockSubscriber(this.NPV1CalculatorParams);
                bHasAnalysis = await subComponent.RunCalculator();

                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BINPV1StockAnalyzer compAnalyzer = new BINPV1StockAnalyzer(
                        subComponent.GCCalculatorParams);
                    compAnalyzer.OCGroup = subComponent.NPV1StockCalculator.BINPV1Calculator.OCGroup;
                    //2. Aggregate the base NPV collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = compAnalyzer.SetOCNPV1StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = await compAnalyzer.SaveNPV1StockTotals();

                        compAnalyzer = null;
                    }
                }
                subComponent = null;
            }
            else if (this.NPV1CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.outcomeprices)
            {
                OutcomeNPV1StockSubscriber subOutcome
                             = new OutcomeNPV1StockSubscriber(this.NPV1CalculatorParams);
                bHasAnalysis = await subOutcome.RunCalculator();

                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BINPV1StockAnalyzer outcomeAnalyzer = new BINPV1StockAnalyzer(
                        subOutcome.GCCalculatorParams);
                    outcomeAnalyzer.OutcomeGroup = subOutcome.NPV1StockCalculator.BINPV1Calculator.OutcomeGroup;
                    //2. Aggregate the base NPV collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = outcomeAnalyzer.SetOutcomeNPV1StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = await outcomeAnalyzer.SaveNPV1StockTotals();

                        outcomeAnalyzer = null;
                    }
                }
                subOutcome = null;
            }
            else if (this.NPV1CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.budgets)
            {
                BINPV1StockSubscriber subBudget
                             = new BINPV1StockSubscriber(this.NPV1CalculatorParams);
                bHasAnalysis = await subBudget.RunCalculator();

                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BINPV1StockAnalyzer biAnalyzer = new BINPV1StockAnalyzer(
                        subBudget.GCCalculatorParams);
                    biAnalyzer.BudgetGroup = subBudget.NPV1StockCalculator.BudgetGroup;
                    //2. Aggregate the base NPV collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = biAnalyzer.SetBINPV1StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = await biAnalyzer.SaveNPV1StockTotals();

                        biAnalyzer = null;
                    }
                }
                subBudget = null;
            }
            else if (this.NPV1CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.investments)
            {
                BINPV1StockSubscriber subInvestment
                             = new BINPV1StockSubscriber(this.NPV1CalculatorParams);
                bHasAnalysis = await subInvestment.RunCalculator();

                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BINPV1StockAnalyzer biAnalyzer = new BINPV1StockAnalyzer(
                        subInvestment.GCCalculatorParams);
                    biAnalyzer.BudgetGroup = subInvestment.NPV1StockCalculator.BudgetGroup;
                    //2. Aggregate the base NPV collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = biAnalyzer.SetBINPV1StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = await biAnalyzer.SaveNPV1StockTotals();

                        biAnalyzer = null;
                    }
                }
                subInvestment = null;
            }
            if (!bHasAggregation)
            {
                bHasAnalysis = false;
            }
            //set the db parameters needed for saving
            SetAnalysisParameters();
            //stylesheet set in analyzerhelper
            return(bHasAnalysis);
        }