public async Task <bool> RunAnalysis(IList <string> urisToAnalyze)
        {
            bool bHasAnalysis = false;
            //set the files needing analysis
            await CalculatorHelpers.SetFileOrFoldersToAnalyze(this.ARSCalculatorParams.AnalyzerParms.FilesToAnalyzeExtensionType,
                                                              this.ARSCalculatorParams, urisToAnalyze);

            //run the analysis
            if (this.ARSCalculatorParams.AnalyzerParms.FileOrFolderPaths != null)
            {
                if (this.ARSCalculatorParams.AnalyzerParms.FileOrFolderPaths.Count > 0)
                {
                    //build the base file needed by the regular analysis
                    this.ARSCalculatorParams.AnalyzerParms.ObservationsPath
                        = await CalculatorHelpers.GetFullCalculatorResultsPath(this.ARSCalculatorParams);

                    bHasAnalysis = await CalculatorHelpers.AddFilesToBaseDocument(this.ARSCalculatorParams);

                    if (bHasAnalysis)
                    {
                        //run the regular analysis
                        bHasAnalysis = await RunCalculations();

                        if (bHasAnalysis)
                        {
                            //v170 set devpack params
                            CalculatorHelpers.UpdateDevPackAnalyzerParams(this.ARSCalculatorParams);
                        }
                        //reset subapptype
                        this.ARSCalculatorParams.SubApplicationType = Constants.SUBAPPLICATION_TYPES.devpacks;
                    }
                    this.ARSCalculatorParams.ErrorMessage += this.ARSCalculatorParams.ErrorMessage;
                }
                else
                {
                    if (this.ARSCalculatorParams.DocToCalcNodeName
                        == Constants.LINKEDVIEWS_TYPES.linkedviewpack.ToString())
                    {
                        //setting default analyzer attribute values
                    }
                    else
                    {
                        this.ARSCalculatorParams.ErrorMessage
                            = Errors.MakeStandardErrorMsg("ANALYSES_NOFILES");
                    }
                }
            }
            else
            {
                this.ARSCalculatorParams.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYSES_NOFILES");
            }
            return(bHasAnalysis);
        }
        public async Task <bool> RunCalculations()
        {
            bool bHasCalculations = false;

            //these calculators use a mix of calculator and analyzer patterns
            this.ARSCalculatorParams.RunCalculatorType
                = CalculatorHelpers.RUN_CALCULATOR_TYPES.iotechnology;
            //urisToAnalyze has the summary calculated results path in position 0.
            //This calculator uses that path to derive 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.ARSCalculatorParams.AnalyzerParms.ObservationsPath
                = await CalculatorHelpers.GetFullCalculatorResultsPath(
                      this.ARSCalculatorParams);

            if (!await CalculatorHelpers.URIAbsoluteExists(this.ARSCalculatorParams.ExtensionDocToCalcURI,
                                                           this.ARSCalculatorParams.AnalyzerParms.ObservationsPath))
            {
                this.ARSCalculatorParams.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYZER_BASECALCS_MISSING");
                return(false);
            }
            //can run npv calcs or base input calculators
            if (this.ARSCalculatorParams.CalculatorType
                == CalculatorHelpers.CALCULATOR_TYPES.input.ToString() ||
                this.ARSCalculatorParams.CalculatorType
                == AgBudgetingHelpers.CALCULATOR_TYPES.agmachinery.ToString() ||
                this.ARSCalculatorParams.CalculatorType
                == AgBudgetingHelpers.CALCULATOR_TYPES.irrpower.ToString() ||
                this.ARSCalculatorParams.CalculatorType
                == AgBudgetingHelpers.CALCULATOR_TYPES.gencapital.ToString())
            {
                IOMachineryStockSubscriber subInput
                    = new IOMachineryStockSubscriber(this.ARSCalculatorParams);
                bHasCalculations = await subInput.RunCalculator();

                CalculatorHelpers.UpdateCalculatorParams(this.ARSCalculatorParams,
                                                         subInput.GCCalculatorParams);
                subInput = null;
            }
            else if (this.ARSCalculatorParams.CalculatorType.StartsWith(
                         CalculatorHelpers.CALCULATOR_TYPES.operation.ToString()) ||
                     this.ARSCalculatorParams.CalculatorType.StartsWith(
                         CalculatorHelpers.CALCULATOR_TYPES.component.ToString()))
            {
                OCMachineryStockSubscriber subOperation
                    = new OCMachineryStockSubscriber(this.ARSCalculatorParams);
                bHasCalculations = await subOperation.RunCalculator();

                CalculatorHelpers.UpdateCalculatorParams(this.ARSCalculatorParams,
                                                         subOperation.GCCalculatorParams);
                subOperation = null;
            }
            else if (this.ARSCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.budget.ToString() ||
                     this.ARSCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.investment.ToString())
            {
                BIMachineryStockSubscriber subBudget
                    = new BIMachineryStockSubscriber(this.ARSCalculatorParams);
                bHasCalculations = await subBudget.RunCalculator();

                CalculatorHelpers.UpdateCalculatorParams(this.ARSCalculatorParams,
                                                         subBudget.GCCalculatorParams);
                subBudget = null;
            }
            return(bHasCalculations);
        }
Exemple #3
0
        public bool RunCalculations()
        {
            bool bHasCalculations = false;

            //these calculators use a mix of calculator and analyzer patterns
            this.FNCalculatorParams.RunCalculatorType
                = CalculatorHelpers.RUN_CALCULATOR_TYPES.iotechnology;
            //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.FNCalculatorParams.AnalyzerParms.ObservationsPath
                = CalculatorHelpers.GetFullCalculatorResultsPath(
                      this.FNCalculatorParams);
            if (!CalculatorHelpers.URIAbsoluteExists(this.FNCalculatorParams.ExtensionDocToCalcURI,
                                                     this.FNCalculatorParams.AnalyzerParms.ObservationsPath))
            {
                this.FNCalculatorParams.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYZER_BASECALCS_MISSING");
                return(false);
            }
            if (this.FNCalculatorParams.CalculatorType
                == CalculatorHelpers.CALCULATOR_TYPES.input.ToString() ||
                this.FNCalculatorParams.CalculatorType
                == CALCULATOR_TYPES.foodfactUSA1.ToString() ||
                this.FNCalculatorParams.CalculatorType
                == CALCULATOR_TYPES.foodnutSR01.ToString())
            {
                this.FNCalculatorParams.RunCalculatorType
                    = CalculatorHelpers.RUN_CALCULATOR_TYPES.basic;
                if (this.FNCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.foodfactUSA1.ToString() ||
                    this.FNCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.foodnutSR01.ToString())
                {
                    IOFNStockSubscriber subInput
                        = new IOFNStockSubscriber(this.FNCalculatorParams);
                    bHasCalculations = subInput.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.FNCalculatorParams, subInput.GCCalculatorParams);
                    subInput = null;
                }
            }
            else if (this.FNCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.operation.ToString() ||
                     this.FNCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.component.ToString())
            {
                if (this.FNCalculatorParams.RelatedCalculatorType != string.Empty &&
                    this.FNCalculatorParams.RelatedCalculatorType
                    != Constants.NONE)
                {
                    if (this.FNCalculatorParams.RelatedCalculatorType
                        == CALCULATOR_TYPES.foodfactUSA1.ToString() ||
                        this.FNCalculatorParams.RelatedCalculatorType
                        == CALCULATOR_TYPES.foodnutSR01.ToString())
                    {
                        OCFNStockSubscriber subOperation
                            = new OCFNStockSubscriber(this.FNCalculatorParams);
                        bHasCalculations = subOperation.RunCalculator();
                        CalculatorHelpers.UpdateCalculatorParams(this.FNCalculatorParams, subOperation.GCCalculatorParams);
                        subOperation = null;
                    }
                }
            }
            else if (this.FNCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.budget.ToString() ||
                     this.FNCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.investment.ToString())
            {
                if (this.FNCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.foodfactUSA1.ToString() ||
                    this.FNCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.foodnutSR01.ToString())
                {
                    BIFNStockSubscriber subBudget
                        = new BIFNStockSubscriber(this.FNCalculatorParams);
                    bHasCalculations = subBudget.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.FNCalculatorParams, subBudget.GCCalculatorParams);
                    subBudget = null;
                }
            }
            //stylesheet set in analyzerhelper
            return(bHasCalculations);
        }
Exemple #4
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);
        }