Exemplo n.º 1
0
        private bool RunInputOrOutputCalculation(ref XElement currentElement,
                                                 ref XElement linkedViewElement, IDictionary <string, string> updates)
        {
            bool bHasCalculations = false;

            CalculatorHelpers.CALCULATOR_TYPES eCalculatorType
                = CalculatorHelpers.GetCalculatorType(
                      this.GCCalculatorParams.CalculatorType);
            IOCalculator ioCalculator = new IOCalculator();

            switch (eCalculatorType)
            {
            //these two apps are expected to need separate calcs in the future
            case CalculatorHelpers.CALCULATOR_TYPES.input:
                bHasCalculations
                    = ioCalculator.SetInputOutputCalculations(
                          eCalculatorType, this.GCCalculatorParams, ref linkedViewElement,
                          ref currentElement, updates);
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.output:
                bHasCalculations
                    = ioCalculator.SetInputOutputCalculations(
                          eCalculatorType, this.GCCalculatorParams, ref linkedViewElement,
                          ref currentElement, updates);
                break;

            default:
                break;
            }
            return(bHasCalculations);
        }
Exemplo n.º 2
0
        private bool RunOutcomeCalculation(ref XElement currentElement,
                                           ref XElement currentCalculationsElement)
        {
            bool bHasCalculations = false;

            //no if (needsCalculation) because calcs are run at all node levels
            //once the calculator is initiated
            CalculatorHelpers.CALCULATOR_TYPES eCalculatorType
                = CalculatorHelpers.GetCalculatorType(this.GCCalculatorParams.CalculatorType);
            NPVOutcomeCalculator ocCalculator = new NPVOutcomeCalculator();

            switch (eCalculatorType)
            {
            //these two apps are expected to need separate calcs in the future
            case CalculatorHelpers.CALCULATOR_TYPES.outcome:
                bHasCalculations
                    = ocCalculator.SetOutcomeCalculations(
                          eCalculatorType, this.GCCalculatorParams, currentCalculationsElement,
                          currentElement, this.GCCalculatorParams.Updates);
                break;

            default:
                break;
            }
            return(bHasCalculations);
        }
Exemplo n.º 3
0
        private bool RunBudgetInvestmentCalculation(ref XElement currentElement,
                                                    ref XElement currentCalculationsElement)
        {
            bool bHasCalculations = false;

            CalculatorHelpers.CALCULATOR_TYPES eCalculatorType
                = CalculatorHelpers.GetCalculatorType(this.GCCalculatorParams.CalculatorType);
            BICalculator biCalculator = new BICalculator();

            switch (eCalculatorType)
            {
            case CalculatorHelpers.CALCULATOR_TYPES.budget:
                bHasCalculations
                    = biCalculator.SetBudgetAndInvestmentCalculations(
                          eCalculatorType, this.GCCalculatorParams, ref currentCalculationsElement,
                          ref currentElement, this.GCCalculatorParams.Updates);
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.investment:
                bHasCalculations
                    = biCalculator.SetBudgetAndInvestmentCalculations(
                          eCalculatorType, this.GCCalculatorParams, ref currentCalculationsElement,
                          ref currentElement, this.GCCalculatorParams.Updates);
                break;

            default:
                break;
            }
            return(bHasCalculations);
        }
Exemplo n.º 4
0
 public void ChangeCalculator(XElement currentElement,
                              ref XElement calculator)
 {
     //these analyzers use atts from calculators only
     if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType
         == ME2AnalyzerHelper.ANALYZER_TYPES.mechangealt.ToString() ||
         this.GCCalculatorParams.AnalyzerParms.AnalyzerType
         == ME2AnalyzerHelper.ANALYZER_TYPES.meprogress1.ToString())
     {
         //don't change the starting calculator
         if (this.GCCalculatorParams.StartingDocToCalcNodeName
             == currentElement.Name.LocalName)
         {
             return;
         }
         bool bIsChildren
             = CalculatorHelpers.IsSelfOrChildNode(this.GCCalculatorParams, currentElement.Name.LocalName);
         bool bIsTPGrandChild =
             (currentElement.Name.LocalName == BudgetInvestment.BUDGET_TYPES.budgettimeperiod.ToString() ||
              currentElement.Name.LocalName == BudgetInvestment.INVESTMENT_TYPES.investmenttimeperiod.ToString())
             ? true : false;
         //need the alt or target type from mecalcs
         if (bIsChildren || bIsTPGrandChild)
         {
             bool   bIsMECalculator  = false;
             string sCurrentCalcType = string.Empty;
             if (calculator != null)
             {
                 sCurrentCalcType = CalculatorHelpers.GetAttribute(calculator, Calculator1.cCalculatorType);
             }
             if (!string.IsNullOrEmpty(sCurrentCalcType))
             {
                 //see if it matches a real me calctype
                 CalculatorHelpers.CALCULATOR_TYPES calcType
                     = CalculatorHelpers.GetCalculatorType(sCurrentCalcType);
                 if (calcType != CalculatorHelpers.CALCULATOR_TYPES.none)
                 {
                     bIsMECalculator = true;
                 }
             }
             if (calculator == null ||
                 bIsMECalculator == false)
             {
                 calculator = CalculatorHelpers.GetChildLinkedViewUsingAttribute(currentElement,
                                                                                 Calculator1.cCalculatorType, currentElement.Name.LocalName);
             }
         }
     }
 }
Exemplo n.º 5
0
        private bool RunBudgetInvestmentCalculation(XElement currentElement,
                                                    XElement currentCalculationsElement)
        {
            bool bHasCalculations = false;

            CalculatorHelpers.CALCULATOR_TYPES eCalculatorType
                = CalculatorHelpers.GetCalculatorType(this.GCCalculatorParams.CalculatorType);
            switch (eCalculatorType)
            {
            case CalculatorHelpers.CALCULATOR_TYPES.budget:
                if (this.GCCalculatorParams.RelatedCalculatorType
                    == FNCalculatorHelper.CALCULATOR_TYPES.foodfactUSA1.ToString())
                {
                    bHasCalculations
                        = BIFN1Calculator.AddStock1CalculationsToCurrentElement(
                              currentCalculationsElement, currentElement);
                }
                else if (this.GCCalculatorParams.RelatedCalculatorType
                         == FNCalculatorHelper.CALCULATOR_TYPES.foodnutSR01.ToString())
                {
                    bHasCalculations
                        = BIFNSR01Calculator.AddStock1CalculationsToCurrentElement(
                              currentCalculationsElement, currentElement);
                }
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.investment:
                if (this.GCCalculatorParams.RelatedCalculatorType
                    == FNCalculatorHelper.CALCULATOR_TYPES.foodfactUSA1.ToString())
                {
                    bHasCalculations
                        = BIFN1Calculator.AddStock1CalculationsToCurrentElement(
                              currentCalculationsElement, currentElement);
                }
                break;

            default:
                break;
            }
            bHasCalculations = TransferErrors(bHasCalculations);
            //some calcparams have to be passed back to this.calcparams
            UpdateCalculatorParams(currentElement.Name.LocalName);
            return(bHasCalculations);
        }
Exemplo n.º 6
0
 private static void CheckForLastStepCalculator(
     CalculatorParameters npvCalcParams,
     ContractHelpers.EXTENSION_STEPS stepNumber,
     ExtensionContentURI extDocToCalcURI)
 {
     CalculatorHelpers.CALCULATOR_TYPES eCalculatorType
         = CalculatorHelpers.GetCalculatorType(
               npvCalcParams.CalculatorType);
     //keep for code sample but Locals moved to Locals Extension
     if (eCalculatorType
         == CalculatorHelpers.CALCULATOR_TYPES.locals)
     {
         if (stepNumber == ContractHelpers.EXTENSION_STEPS.stepthree)
         {
             //tells addinhelper to save calcs
             CalculatorHelpers.SetTempDocSaveCalcsProperty(extDocToCalcURI);
         }
     }
 }
Exemplo n.º 7
0
        public bool SetInputOutputCalculations(
            CalculatorHelpers.CALCULATOR_TYPES calculatorType,
            CalculatorParameters calcParameters, XElement currentCalculationsElement,
            XElement currentElement, IDictionary <string, string> updates)
        {
            bool bHasCalculations = false;

            switch (calculatorType)
            {
            case CalculatorHelpers.CALCULATOR_TYPES.input:
                InputDiscounted inputDiscounted = new InputDiscounted();
                //deserialize xml to object
                inputDiscounted.SetInputDiscountedProperties(
                    calcParameters, currentCalculationsElement, currentElement);
                //set up and run and the calculations
                bHasCalculations = RunInputCalculations(inputDiscounted,
                                                        calcParameters);
                //serialize object back to xml
                inputDiscounted.SetInputDiscountedAttributes(
                    calcParameters, currentCalculationsElement,
                    currentElement, updates);
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.output:
                OutputDiscounted outputDiscounted = new OutputDiscounted();
                //deserialize xml to object
                outputDiscounted.SetOutputDiscountedProperties(
                    calcParameters, currentCalculationsElement, currentElement);
                //set up and run and the calculations
                bHasCalculations = RunOutputCalculations(outputDiscounted,
                                                         calcParameters);
                //serialize object back to xml
                outputDiscounted.SetOutputDiscountedAttributes(
                    calcParameters, currentCalculationsElement,
                    currentElement, updates);
                break;

            default:
                break;
            }
            return(bHasCalculations);
        }
Exemplo n.º 8
0
        //additional timeliness penalty object (adds optional costs to base object)
        //public TimelinessOpComp1 TimelinessOutcome1 { get; set; }
        public bool SetOutcomeCalculations(
            CalculatorHelpers.CALCULATOR_TYPES calculatorType,
            CalculatorParameters calcParameters, ref XElement currentCalculationsElement,
            ref XElement currentElement, IDictionary <string, string> updates)
        {
            bool bHasCalculations = false;

            //this.TimelinessOutcome1 = new TimelinessOpComp1();
            switch (calculatorType)
            {
            case CalculatorHelpers.CALCULATOR_TYPES.outcome:
                bHasCalculations = AddNPVCalculationsToCurrentElement(calcParameters,
                                                                      ref currentCalculationsElement, ref currentElement,
                                                                      updates);
                break;

            default:
                break;
            }
            return(bHasCalculations);
        }
Exemplo n.º 9
0
        private bool RunBudgetInvestmentCalculation(ref XElement currentElement,
                                                    ref XElement currentCalculationsElement)
        {
            bool bHasCalculations = false;

            CalculatorHelpers.CALCULATOR_TYPES eCalculatorType
                = CalculatorHelpers.GetCalculatorType(this.GCCalculatorParams.CalculatorType);
            switch (eCalculatorType)
            {
            case CalculatorHelpers.CALCULATOR_TYPES.budget:
                if (this.GCCalculatorParams.RelatedCalculatorType
                    == HCCalculatorHelper.CALCULATOR_TYPES.healthcost1.ToString() ||
                    this.GCCalculatorParams.RelatedCalculatorsType != string.Empty)
                {
                    bHasCalculations
                        = BIHC1Calculator.AddStock1CalculationsToCurrentElement(
                              ref currentCalculationsElement, ref currentElement);
                }
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.investment:
                if (this.GCCalculatorParams.RelatedCalculatorType
                    == HCCalculatorHelper.CALCULATOR_TYPES.healthcost1.ToString() ||
                    this.GCCalculatorParams.RelatedCalculatorsType != string.Empty)
                {
                    bHasCalculations
                        = BIHC1Calculator.AddStock1CalculationsToCurrentElement(
                              ref currentCalculationsElement, ref currentElement);
                }
                break;

            default:
                break;
            }
            bHasCalculations = TransferErrors(bHasCalculations);
            //some calcparams have to be passed back to this.calcparams
            UpdateCalculatorParams(currentElement.Name.LocalName);
            return(bHasCalculations);
        }
Exemplo n.º 10
0
 //constructor sets class (base) properties
 public NPVOutcomeSubscriber(CalculatorParameters calcParameters,
                             CalculatorHelpers.CALCULATOR_TYPES calculatorType)
     : base(calcParameters)
 {
     this.CalculatorType = calculatorType;
 }
Exemplo n.º 11
0
        public bool RunCalculations()
        {
            bool bHasCalculations = false;

            //these calculators use a basic calculatorpatterns
            this.NPVCalculatorParams.RunCalculatorType
                = CalculatorHelpers.RUN_CALCULATOR_TYPES.basic;
            CalculatorHelpers.CALCULATOR_TYPES eCalculatorType
                = CalculatorHelpers.GetCalculatorType(this.NPVCalculatorParams.CalculatorType);
            //both calculators and analyzers both calculate a file in this path:
            this.NPVCalculatorParams.AnalyzerParms.ObservationsPath
                = this.NPVCalculatorParams.ExtensionDocToCalcURI.URIDataManager.TempDocPath;
            switch (eCalculatorType)
            {
            case CalculatorHelpers.CALCULATOR_TYPES.input:
                //prepare the event subscriber
                NPVIOSubscriber subInput
                    = new NPVIOSubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subInput.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subInput.GCCalculatorParams);
                subInput = null;
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.output:
                //prepare the event subscriber
                NPVIOSubscriber subOutput
                    = new NPVIOSubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subOutput.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subOutput.GCCalculatorParams);
                subOutput = null;
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.outcome:
                //prepare the event subscriber
                NPVOutcomeSubscriber subOutcome
                    = new NPVOutcomeSubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subOutcome.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subOutcome.GCCalculatorParams);
                subOutcome = null;
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.operation:
                //prepare the event subscriber
                NPVOCSubscriber subOperation
                    = new NPVOCSubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subOperation.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subOperation.GCCalculatorParams);
                subOperation = null;
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.operation2:
                //prepare the event subscriber
                NPVOCSubscriber subOperation2
                    = new NPVOCSubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subOperation2.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subOperation2.GCCalculatorParams);
                subOperation2 = null;
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.component:
                //prepare the event subscriber
                NPVOCSubscriber subComponent
                    = new NPVOCSubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subComponent.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subComponent.GCCalculatorParams);
                subComponent = null;
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.component2:
                //prepare the event subscriber
                NPVOCSubscriber subComponent2
                    = new NPVOCSubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subComponent2.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subComponent2.GCCalculatorParams);
                subComponent2 = null;
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.budget:
                //prepare the event subscriber
                NPVBISubscriber subBudget
                    = new NPVBISubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subBudget.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subBudget.GCCalculatorParams);
                subBudget = null;
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.investment:
                //prepare the event subscriber
                NPVBISubscriber subInvestment
                    = new NPVBISubscriber(this.NPVCalculatorParams, eCalculatorType);
                //run the analyses (raising the publisher's events for each node)
                bHasCalculations = subInvestment.RunCalculator();
                CalculatorHelpers.UpdateCalculatorParams(this.NPVCalculatorParams,
                                                         subInvestment.GCCalculatorParams);
                subInvestment = null;
                break;

            default:
                break;
            }
            //set parameters/attributes needed to update db and display this analysis
            SetCalculatorParameters();
            return(bHasCalculations);
        }
Exemplo n.º 12
0
        private bool RunBudgetInvestmentCalculation(ref XElement currentElement,
                                                    ref XElement currentCalculationsElement)
        {
            bool bHasCalculations = false;

            CalculatorHelpers.CALCULATOR_TYPES eCalculatorType
                = CalculatorHelpers.GetCalculatorType(this.GCCalculatorParams.CalculatorType);
            switch (eCalculatorType)
            {
            case CalculatorHelpers.CALCULATOR_TYPES.budget:
                if (this.GCCalculatorParams.RelatedCalculatorType
                    == AgBudgetingHelpers.CALCULATOR_TYPES.agmachinery.ToString())
                {
                    if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType
                        == ARSAnalyzerHelper.ANALYZER_TYPES.resources02.ToString())
                    {
                        bHasCalculations
                            = BIM2Calculator.AddStock2CalculationsToCurrentElement(
                                  ref currentCalculationsElement, ref currentElement);
                    }
                    else if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType
                             == ARSAnalyzerHelper.ANALYZER_TYPES.resources02a.ToString())
                    {
                        bHasCalculations
                            = BIM2aCalculator.AddStock2aCalculationsToCurrentElement(
                                  ref currentCalculationsElement, ref currentElement);
                    }
                    else
                    {
                        bHasCalculations
                            = BIM1Calculator.AddStock1CalculationsToCurrentElement(
                                  ref currentCalculationsElement, ref currentElement);
                    }
                }
                else if (this.GCCalculatorParams.RelatedCalculatorType
                         == AgBudgetingHelpers.CALCULATOR_TYPES.irrpower.ToString())
                {
                    bHasCalculations
                        = BIIP1Calculator.AddCalculationsToCurrentElement(
                              ref currentCalculationsElement, ref currentElement);
                }
                else if (this.GCCalculatorParams.RelatedCalculatorType
                         == AgBudgetingHelpers.CALCULATOR_TYPES.gencapital.ToString())
                {
                    bHasCalculations
                        = BIGC1Calculator.AddCalculationsToCurrentElement(
                              ref currentCalculationsElement, ref currentElement);
                }
                break;

            case CalculatorHelpers.CALCULATOR_TYPES.investment:
                if (this.GCCalculatorParams.RelatedCalculatorType
                    == AgBudgetingHelpers.CALCULATOR_TYPES.agmachinery.ToString())
                {
                    if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType
                        == ARSAnalyzerHelper.ANALYZER_TYPES.resources02.ToString())
                    {
                        bHasCalculations
                            = BIM2Calculator.AddStock2CalculationsToCurrentElement(
                                  ref currentCalculationsElement, ref currentElement);
                    }
                    else if (this.GCCalculatorParams.AnalyzerParms.AnalyzerType
                             == ARSAnalyzerHelper.ANALYZER_TYPES.resources02a.ToString())
                    {
                        bHasCalculations
                            = BIM2aCalculator.AddStock2aCalculationsToCurrentElement(
                                  ref currentCalculationsElement, ref currentElement);
                    }
                    else
                    {
                        bHasCalculations
                            = BIM1Calculator.AddStock1CalculationsToCurrentElement(
                                  ref currentCalculationsElement, ref currentElement);
                    }
                }
                else if (this.GCCalculatorParams.RelatedCalculatorType
                         == AgBudgetingHelpers.CALCULATOR_TYPES.irrpower.ToString())
                {
                    bHasCalculations
                        = BIIP1Calculator.AddCalculationsToCurrentElement(
                              ref currentCalculationsElement, ref currentElement);
                }
                else if (this.GCCalculatorParams.RelatedCalculatorType
                         == AgBudgetingHelpers.CALCULATOR_TYPES.gencapital.ToString())
                {
                    bHasCalculations
                        = BIGC1Calculator.AddCalculationsToCurrentElement(
                              ref currentCalculationsElement, ref currentElement);
                }
                break;

            default:
                break;
            }
            bHasCalculations = TransferErrors(bHasCalculations);
            //some calcparams have to be passed back to this.calcparams
            UpdateCalculatorParams(currentElement.Name.LocalName);
            return(bHasCalculations);
        }