Exemplo n.º 1
0
        public async Task <bool> RunInputOrOutputCalculations()
        {
            bool             bHasCalculations = false;
            CALCULATOR_TYPES eCalculatorType
                = GetCalculatorType(this.HCCalculatorParams.CalculatorType);

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

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

            case CALCULATOR_TYPES.hcbenefit1:
                IOHCStockSubscriber subOutput
                    = new IOHCStockSubscriber(this.HCCalculatorParams);
                bHasCalculations = await subOutput.RunCalculator();

                CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams,
                                                         subOutput.GCCalculatorParams);
                break;

            default:
                break;
            }
            //set parameters/attributes needed to update db and display this analysis
            SetCalculatorParameters();
            return(bHasCalculations);
        }
Exemplo n.º 2
0
        public bool RunCalculations()
        {
            bool bHasCalculations = false;

            //these calculators use a mix of calculator and analyzer patterns
            this.HCCalculatorParams.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.HCCalculatorParams.AnalyzerParms.ObservationsPath
                = CalculatorHelpers.GetFullCalculatorResultsPath(
                      this.HCCalculatorParams);
            if (!CalculatorHelpers.URIAbsoluteExists(this.HCCalculatorParams.ExtensionDocToCalcURI,
                                                     this.HCCalculatorParams.AnalyzerParms.ObservationsPath))
            {
                this.HCCalculatorParams.ErrorMessage
                    = Errors.MakeStandardErrorMsg("ANALYZER_BASECALCS_MISSING");
                return(false);
            }
            if (this.HCCalculatorParams.CalculatorType
                == CalculatorHelpers.CALCULATOR_TYPES.input.ToString() ||
                this.HCCalculatorParams.CalculatorType
                == CALCULATOR_TYPES.healthcost1.ToString() ||
                this.HCCalculatorParams.CalculatorType
                == CalculatorHelpers.CALCULATOR_TYPES.output.ToString() ||
                this.HCCalculatorParams.CalculatorType
                == CALCULATOR_TYPES.hcbenefit1.ToString())
            {
                this.HCCalculatorParams.RunCalculatorType
                    = CalculatorHelpers.RUN_CALCULATOR_TYPES.basic;
                if (this.HCCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.healthcost1.ToString())
                {
                    IOHCStockSubscriber subInput
                        = new IOHCStockSubscriber(this.HCCalculatorParams);
                    bHasCalculations = subInput.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subInput.GCCalculatorParams);
                    subInput = null;
                }
                else if (this.HCCalculatorParams.RelatedCalculatorType
                         == CALCULATOR_TYPES.hcbenefit1.ToString())
                {
                    IOHCStockSubscriber subOutput
                        = new IOHCStockSubscriber(this.HCCalculatorParams);
                    bHasCalculations = subOutput.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subOutput.GCCalculatorParams);
                    subOutput = null;
                }
                else
                {
                    //don't rely on just related calcs type
                    if (this.HCCalculatorParams.CalculatorType
                        == CalculatorHelpers.CALCULATOR_TYPES.input.ToString() ||
                        this.HCCalculatorParams.CalculatorType
                        == CALCULATOR_TYPES.healthcost1.ToString())
                    {
                        IOHCStockSubscriber subInput
                            = new IOHCStockSubscriber(this.HCCalculatorParams);
                        bHasCalculations = subInput.RunCalculator();
                        CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subInput.GCCalculatorParams);
                        subInput = null;
                    }
                    else if (this.HCCalculatorParams.CalculatorType
                             == CalculatorHelpers.CALCULATOR_TYPES.output.ToString() ||
                             this.HCCalculatorParams.CalculatorType
                             == CALCULATOR_TYPES.hcbenefit1.ToString())
                    {
                        IOHCStockSubscriber subOutput
                            = new IOHCStockSubscriber(this.HCCalculatorParams);
                        bHasCalculations = subOutput.RunCalculator();
                        CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subOutput.GCCalculatorParams);
                        subOutput = null;
                    }
                }
            }
            else if (this.HCCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.outcome.ToString())
            {
                if (this.HCCalculatorParams.RelatedCalculatorType != string.Empty &&
                    this.HCCalculatorParams.RelatedCalculatorType
                    != Constants.NONE)
                {
                    if (this.HCCalculatorParams.RelatedCalculatorType
                        == CALCULATOR_TYPES.hcbenefit1.ToString())
                    {
                        OutcomeHCStockSubscriber subOutcome
                            = new OutcomeHCStockSubscriber(this.HCCalculatorParams);
                        bHasCalculations = subOutcome.RunCalculator();
                        CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subOutcome.GCCalculatorParams);
                        subOutcome = null;
                    }
                }
                else
                {
                    OutcomeHCStockSubscriber subOutcome
                        = new OutcomeHCStockSubscriber(this.HCCalculatorParams);
                    bHasCalculations = subOutcome.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subOutcome.GCCalculatorParams);
                    subOutcome = null;
                }
            }
            else if (this.HCCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.operation.ToString() ||
                     this.HCCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.component.ToString())
            {
                if (this.HCCalculatorParams.RelatedCalculatorType != string.Empty &&
                    this.HCCalculatorParams.RelatedCalculatorType
                    != Constants.NONE)
                {
                    if (this.HCCalculatorParams.RelatedCalculatorType
                        == CALCULATOR_TYPES.healthcost1.ToString())
                    {
                        OCHCStockSubscriber subOperation
                            = new OCHCStockSubscriber(this.HCCalculatorParams);
                        bHasCalculations = subOperation.RunCalculator();
                        CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subOperation.GCCalculatorParams);
                        subOperation = null;
                    }
                }
                else
                {
                    OCHCStockSubscriber subOperation
                        = new OCHCStockSubscriber(this.HCCalculatorParams);
                    bHasCalculations = subOperation.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subOperation.GCCalculatorParams);
                    subOperation = null;
                }
            }
            else if (this.HCCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.budget.ToString() ||
                     this.HCCalculatorParams.CalculatorType
                     == CalculatorHelpers.CALCULATOR_TYPES.investment.ToString())
            {
                if (this.HCCalculatorParams.RelatedCalculatorType
                    == CALCULATOR_TYPES.healthcost1.ToString())
                {
                    BIHCStockSubscriber subBudget
                        = new BIHCStockSubscriber(this.HCCalculatorParams);
                    bHasCalculations = subBudget.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subBudget.GCCalculatorParams);
                    subBudget = null;
                }
                else if (this.HCCalculatorParams.RelatedCalculatorType
                         == CALCULATOR_TYPES.hcbenefit1.ToString())
                {
                    BIHCStockSubscriber subBudget
                        = new BIHCStockSubscriber(this.HCCalculatorParams);
                    bHasCalculations = subBudget.RunCalculator();
                    CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subBudget.GCCalculatorParams);
                    subBudget = null;
                }
                else
                {
                    if (this.HCCalculatorParams.RelatedCalculatorsType != string.Empty)
                    {
                        //set by analyzer or by user
                        BIHCStockSubscriber subBudget
                            = new BIHCStockSubscriber(this.HCCalculatorParams);
                        bHasCalculations = subBudget.RunCalculator();
                        CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subBudget.GCCalculatorParams);
                        subBudget = null;
                    }
                    else
                    {
                        //set by analyzer or by user
                        BIHCStockSubscriber subBudget
                            = new BIHCStockSubscriber(this.HCCalculatorParams);
                        bHasCalculations = subBudget.RunCalculator();
                        CalculatorHelpers.UpdateCalculatorParams(this.HCCalculatorParams, subBudget.GCCalculatorParams);
                        subBudget = null;
                    }
                }
            }
            //stylesheet set in analyzerhelper
            return(bHasCalculations);
        }