Exemplo n.º 1
0
        public 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.ME2CalculatorParams.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.ME2CalculatorParams.AnalyzerParms.ObservationsPath
                = CalculatorHelpers.GetFullCalculatorResultsPath(
                      this.ME2CalculatorParams);
            if (!CalculatorHelpers.URIAbsoluteExists(this.ME2CalculatorParams.ExtensionDocToCalcURI,
                                                     this.ME2CalculatorParams.AnalyzerParms.ObservationsPath))
            {
                this.ME2CalculatorParams.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYZER_BASECALCS_MISSING");
                return(false);
            }
            if (this.ME2CalculatorParams.SubApplicationType
                == Constants.SUBAPPLICATION_TYPES.inputprices)
            {
                IOME2StockSubscriber subInput
                             = new IOME2StockSubscriber(this.ME2CalculatorParams);
                bHasAnalysis = subInput.RunCalculator();
                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BIME2StockAnalyzer inputAnalyzer = new BIME2StockAnalyzer(
                        subInput.GCCalculatorParams);
                    inputAnalyzer.InputGroup = subInput.ME2StockCalculator.BIME2Calculator.InputGroup;
                    //2. Aggregate the base ME collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = inputAnalyzer.SetInputME2StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis  = inputAnalyzer.SaveME2StockTotals();
                        inputAnalyzer = null;
                    }
                }
                subInput = null;
            }
            else if (this.ME2CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.outputprices)
            {
                IOME2StockSubscriber subOutput
                             = new IOME2StockSubscriber(this.ME2CalculatorParams);
                bHasAnalysis = subOutput.RunCalculator();
                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BIME2StockAnalyzer outputAnalyzer = new BIME2StockAnalyzer(
                        subOutput.GCCalculatorParams);
                    outputAnalyzer.OutputGroup = subOutput.ME2StockCalculator.BIME2Calculator.OutputGroup;
                    //2. Aggregate the base ME collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = outputAnalyzer.SetOutputME2StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis   = outputAnalyzer.SaveME2StockTotals();
                        outputAnalyzer = null;
                    }
                }
                subOutput = null;
            }
            else if (this.ME2CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.operationprices)
            {
                //build an object collection
                OCME2StockSubscriber subOperation
                             = new OCME2StockSubscriber(this.ME2CalculatorParams);
                bHasAnalysis = subOperation.RunCalculator();
                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BIME2StockAnalyzer opAnalyzer = new BIME2StockAnalyzer(
                        subOperation.GCCalculatorParams);
                    opAnalyzer.OCGroup = subOperation.ME2StockCalculator.BIME2Calculator.OCGroup;
                    //2. Aggregate the base ME collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = opAnalyzer.SetOCME2StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = opAnalyzer.SaveME2StockTotals();
                        opAnalyzer   = null;
                    }
                }
                subOperation = null;
            }
            else if (this.ME2CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.componentprices)
            {
                //build an object collection
                OCME2StockSubscriber subComponent
                             = new OCME2StockSubscriber(this.ME2CalculatorParams);
                bHasAnalysis = subComponent.RunCalculator();
                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BIME2StockAnalyzer compAnalyzer = new BIME2StockAnalyzer(
                        subComponent.GCCalculatorParams);
                    compAnalyzer.OCGroup = subComponent.ME2StockCalculator.BIME2Calculator.OCGroup;
                    //2. Aggregate the base ME collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = compAnalyzer.SetOCME2StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = compAnalyzer.SaveME2StockTotals();
                        compAnalyzer = null;
                    }
                }
                subComponent = null;
            }
            else if (this.ME2CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.outcomeprices)
            {
                OutcomeME2StockSubscriber subOutcome
                             = new OutcomeME2StockSubscriber(this.ME2CalculatorParams);
                bHasAnalysis = subOutcome.RunCalculator();
                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BIME2StockAnalyzer outcomeAnalyzer = new BIME2StockAnalyzer(
                        subOutcome.GCCalculatorParams);
                    outcomeAnalyzer.OutcomeGroup = subOutcome.ME2StockCalculator.BIME2Calculator.OutcomeGroup;
                    //2. Aggregate the base ME collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = outcomeAnalyzer.SetOutcomeME2StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis    = outcomeAnalyzer.SaveME2StockTotals();
                        outcomeAnalyzer = null;
                    }
                }
                subOutcome = null;
            }
            else if (this.ME2CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.budgets)
            {
                BIME2StockSubscriber subBudget
                             = new BIME2StockSubscriber(this.ME2CalculatorParams);
                bHasAnalysis = subBudget.RunCalculator();
                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BIME2StockAnalyzer biAnalyzer = new BIME2StockAnalyzer(
                        subBudget.GCCalculatorParams);
                    biAnalyzer.BudgetGroup = subBudget.ME2StockCalculator.BudgetGroup;
                    //2. Aggregate the base ME collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = biAnalyzer.SetBIME2StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = biAnalyzer.SaveME2StockTotals();
                        biAnalyzer   = null;
                    }
                }
                subBudget = null;
            }
            else if (this.ME2CalculatorParams.SubApplicationType
                     == Constants.SUBAPPLICATION_TYPES.investments)
            {
                BIME2StockSubscriber subInvestment
                             = new BIME2StockSubscriber(this.ME2CalculatorParams);
                bHasAnalysis = subInvestment.RunCalculator();
                if (bHasAnalysis)
                {
                    //transfer object model to Analyzer
                    BIME2StockAnalyzer biAnalyzer = new BIME2StockAnalyzer(
                        subInvestment.GCCalculatorParams);
                    biAnalyzer.BudgetGroup = subInvestment.ME2StockCalculator.BudgetGroup;
                    //2. Aggregate the base ME collections and add Stock totals to collections
                    //aggregation is for full collection including descendants
                    bHasAggregation = biAnalyzer.SetBIME2StockTotals();
                    if (bHasAggregation)
                    {
                        //Save the results as xml
                        bHasAnalysis = biAnalyzer.SaveME2StockTotals();
                        biAnalyzer   = null;
                    }
                }
                subInvestment = null;
            }
            if (!bHasAggregation)
            {
                bHasAnalysis = false;
            }
            //set the db parameters needed for saving
            SetAnalysisParameters();
            //stylesheet set in analyzerhelper
            return(bHasAnalysis);
        }
Exemplo n.º 2
0
        public bool RunME2CalculatorCalculations()
        {
            bool             bHasCalculations = false;
            CALCULATOR_TYPES eCalculatorType
                = GetCalculatorType(this.ME2CalculatorParams.CalculatorType);

            this.ME2CalculatorParams.RunCalculatorType
                = CalculatorHelpers.RUN_CALCULATOR_TYPES.basic;
            this.ME2CalculatorParams.AnalyzerParms.ObservationsPath
                = this.ME2CalculatorParams.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
            switch (eCalculatorType)
            {
            case CALCULATOR_TYPES.me2:
                if (this.ME2CalculatorParams.SubApplicationType
                    == Constants.SUBAPPLICATION_TYPES.budgets ||
                    this.ME2CalculatorParams.SubApplicationType
                    == Constants.SUBAPPLICATION_TYPES.investments)
                {
                    BIME2StockSubscriber subME2Calculator
                        = new BIME2StockSubscriber(this.ME2CalculatorParams);
                    bHasCalculations = subME2Calculator.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.ME2CalculatorParams, subME2Calculator.GCCalculatorParams);
                }
                else if (this.ME2CalculatorParams.SubApplicationType
                         == Constants.SUBAPPLICATION_TYPES.outcomeprices)
                {
                    OutcomeME2StockSubscriber subME2Calculator
                        = new OutcomeME2StockSubscriber(this.ME2CalculatorParams);
                    bHasCalculations = subME2Calculator.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.ME2CalculatorParams, subME2Calculator.GCCalculatorParams);
                }
                else if (this.ME2CalculatorParams.SubApplicationType
                         == Constants.SUBAPPLICATION_TYPES.operationprices ||
                         this.ME2CalculatorParams.SubApplicationType
                         == Constants.SUBAPPLICATION_TYPES.componentprices)
                {
                    OCME2StockSubscriber subME2Calculator
                        = new OCME2StockSubscriber(this.ME2CalculatorParams);
                    //build the me2s object collections
                    bHasCalculations = subME2Calculator.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.ME2CalculatorParams, subME2Calculator.GCCalculatorParams);
                }
                else if (this.ME2CalculatorParams.SubApplicationType
                         == Constants.SUBAPPLICATION_TYPES.inputprices ||
                         this.ME2CalculatorParams.SubApplicationType
                         == Constants.SUBAPPLICATION_TYPES.outputprices)
                {
                    IOME2StockSubscriber subME2Calculator
                        = new IOME2StockSubscriber(this.ME2CalculatorParams);
                    bHasCalculations = subME2Calculator.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.ME2CalculatorParams, subME2Calculator.GCCalculatorParams);
                }
                break;

            default:
                break;
            }
            //set parameters/attributes needed to update db and display this analysis
            SetCalculatorParameters();
            return(bHasCalculations);
        }