Beispiel #1
0
        public static ME2Stock GetNewME2Stock(CalculatorParameters calcParams,
                                              Calculator1 baseElement, List <Calculator1> calcs, ME2Stock descendant)
        {
            ME2Stock newStock = new ME2Stock(calcParams, calcParams.AnalyzerParms.AnalyzerType);

            if (calcs == null)
            {
                calcs = new List <Calculator1>();
            }
            if (calcs.Count > 0)
            {
                ME2AnalyzerHelper.CopyandInitStockCalculator(calcs
                                                             .FirstOrDefault(), newStock);
            }
            else
            {
                //need the options
                newStock.CopyCalculatorProperties(descendant);
            }
            BIME2StockAnalyzer.CopyBaseElementProperties(baseElement, newStock);
            return(newStock);
        }
Beispiel #2
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);
        }