コード例 #1
0
        public async Task <bool> RunInputCalculations()
        {
            bool             bHasCalculations = false;
            CALCULATOR_TYPES eCalculatorType
                = GetCalculatorType(this.FNCalculatorParams.CalculatorType);

            this.FNCalculatorParams.RunCalculatorType
                = CalculatorHelpers.RUN_CALCULATOR_TYPES.iotechnology;
            if (this.FNCalculatorParams.ExtensionDocToCalcURI.URIDataManager.SubAppType
                == Constants.SUBAPPLICATION_TYPES.inputprices.ToString() ||
                this.FNCalculatorParams.ExtensionDocToCalcURI.URIDataManager.SubAppType
                == Constants.SUBAPPLICATION_TYPES.outputprices.ToString())
            {
                this.FNCalculatorParams.RunCalculatorType
                    = CalculatorHelpers.RUN_CALCULATOR_TYPES.basic;
            }
            this.FNCalculatorParams.AnalyzerParms.ObservationsPath
                = this.FNCalculatorParams.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.foodfactUSA1:
                IOFNStockSubscriber subInput
                    = new IOFNStockSubscriber(this.FNCalculatorParams);
                bHasCalculations = await subInput.RunCalculator();

                CalculatorHelpers.UpdateCalculatorParams(this.FNCalculatorParams,
                                                         subInput.GCCalculatorParams);
                break;

            case CALCULATOR_TYPES.foodnutSR01:
                IOFNStockSubscriber subFoodStock
                    = new IOFNStockSubscriber(this.FNCalculatorParams);
                bHasCalculations = await subFoodStock.RunCalculator();

                CalculatorHelpers.UpdateCalculatorParams(this.FNCalculatorParams,
                                                         subFoodStock.GCCalculatorParams);
                break;

            default:
                break;
            }
            //set parameters/attributes needed to update db and display this analysis
            SetCalculatorParameters();
            return(bHasCalculations);
        }
コード例 #2
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);
        }