Exemple #1
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, ref currentCalculationsElement,
                          ref currentElement, this.GCCalculatorParams.Updates);
                break;

            default:
                break;
            }
            return(bHasCalculations);
        }
 //descendents need properties from ancestor objects (i.e. realrate)
 //to run their calculations, the ancestors are kept statefully in this.GCCalculatorParams
 private void AddAncestorObjects(XElement currentElement)
 {
     if (currentElement.Name.LocalName
         .EndsWith(Outcome.OUTCOME_PRICE_TYPES.outcome.ToString()))
     {
         XElement currentCalculationsElement
             = CalculatorHelpers.GetCalculator(this.GCCalculatorParams,
                                               currentElement);
         SetAncestorProperties(currentElement, currentCalculationsElement);
         //run joint output calculations (i.e. fuel amount, fuel cost)
         //these will be copied to descendent output nodes as calculations are run
         //on those nodes
         NPVOutcomeCalculator outcomeCalculator = new NPVOutcomeCalculator();
         outcomeCalculator.SetJointOutputCalculations(
             this.GCCalculatorParams);
     }
 }
Exemple #3
0
        //descendants need properties from ancestor objects (i.e. realrate)
        //to run their calculations; the ancestors are kept statefully in this.GCCalculatorParams
        private void AddAncestorObjects(XElement currentElement)
        {
            XElement currentCalculationsElement = null;

            currentCalculationsElement
                = CalculatorHelpers.GetCalculator(this.GCCalculatorParams,
                                                  currentElement);
            if (currentElement.Name.LocalName
                == BudgetInvestment.BUDGET_TYPES.budgetgroup.ToString() ||
                currentElement.Name.LocalName
                == BudgetInvestment.INVESTMENT_TYPES.investmentgroup.ToString())
            {
                //set the stateful ancestor object
                this.GCCalculatorParams.ParentBudgetInvestmentGroup
                    = new BudgetInvestmentGroup();
                //deserialize xml to object
                this.GCCalculatorParams.ParentBudgetInvestmentGroup.SetBudgetInvestmentGroupProperties(
                    this.GCCalculatorParams, currentCalculationsElement, currentElement);
                //init the total costs to zero
                this.GCCalculatorParams.ParentBudgetInvestmentGroup.InitTotalBenefitsProperties();
                this.GCCalculatorParams.ParentBudgetInvestmentGroup.InitTotalCostsProperties();
            }
            else if (currentElement.Name.LocalName
                     == BudgetInvestment.BUDGET_TYPES.budget.ToString() ||
                     currentElement.Name.LocalName
                     == BudgetInvestment.INVESTMENT_TYPES.investment.ToString())
            {
                //set the stateful ancestor object
                this.GCCalculatorParams.ParentBudgetInvestment
                    = new BudgetInvestment();
                //deserialize xml to object
                this.GCCalculatorParams.ParentBudgetInvestment.SetBudgetInvestmentProperties(
                    this.GCCalculatorParams, currentCalculationsElement, currentElement);
                //init the total costs to zero
                this.GCCalculatorParams.ParentBudgetInvestment.InitTotalBenefitsProperties();
                this.GCCalculatorParams.ParentBudgetInvestment.InitTotalCostsProperties();

                //anyway to setpreprod annuities later rather than running here?
                SetAncestorBudgetInvestment(currentCalculationsElement, currentElement);

                //run preproduction and other annuity calculations
                BICalculator biCalculator = new BICalculator();
                biCalculator.SetPreProductionCalculations(
                    this.GCCalculatorParams, currentElement);
                //reset annuities collection
                this.GCCalculatorParams.ParentBudgetInvestment.AnnEquivalents = null;
            }
            else if (currentElement.Name.LocalName
                     == BudgetInvestment.BUDGET_TYPES.budgettimeperiod.ToString() ||
                     currentElement.Name.LocalName
                     == BudgetInvestment.INVESTMENT_TYPES.investmenttimeperiod.ToString())
            {
                //set the stateful ancestor object
                //last time period date's are used in some calculations
                DateTime dtLastTimePeriodDate = new DateTime(1000, 12, 1);
                bool     bHasLastDate         = false;
                if (this.GCCalculatorParams.ParentTimePeriod != null)
                {
                    bHasLastDate         = true;
                    dtLastTimePeriodDate = this.GCCalculatorParams.ParentTimePeriod.Date;
                }
                this.GCCalculatorParams.ParentTimePeriod = new TimePeriod();
                //deserialize xml to object
                this.GCCalculatorParams.ParentTimePeriod.SetTimePeriodProperties(
                    this.GCCalculatorParams, currentCalculationsElement, currentElement);
                //init the total costs to zero
                this.GCCalculatorParams.ParentTimePeriod.InitTotalBenefitsProperties();
                this.GCCalculatorParams.ParentTimePeriod.InitTotalCostsProperties();
                if (this.GCCalculatorParams.ParentBudgetInvestment.PreProdPeriods == 0 &&
                    this.GCCalculatorParams.ParentBudgetInvestment.ProdPeriods <= 1)
                {
                    //no preproduction annuities
                    this.GCCalculatorParams.ParentBudgetInvestment.InitEOPDate
                        = this.GCCalculatorParams.ParentTimePeriod.Date;
                }
                //copy some of the last tps properties to current tp
                if (!bHasLastDate)
                {
                    dtLastTimePeriodDate
                        = this.GCCalculatorParams.ParentTimePeriod.Date;
                }
                this.GCCalculatorParams.ParentTimePeriod.LastPeriodDate
                    = dtLastTimePeriodDate;
            }
            else if (currentElement.Name.LocalName
                     .EndsWith(Outcome.OUTCOME_PRICE_TYPES.outcome.ToString()))
            {
                this.GCCalculatorParams.ParentOutcome = new Outcome();
                this.GCCalculatorParams.ParentOutcome.SetOutcomeProperties(
                    this.GCCalculatorParams, currentCalculationsElement, currentElement);
                //init the total costs to zero
                this.GCCalculatorParams.ParentOutcome.InitTotalBenefitsProperties();
                SetAncestorOutcome(currentCalculationsElement, currentElement);
                //run joint output calculations
                //these will be copied to descendant output nodes as calculations
                //are run on those nodes
                NPVOutcomeCalculator outcomeCalculator = new NPVOutcomeCalculator();
                outcomeCalculator.SetJointOutputCalculations(
                    this.GCCalculatorParams);
            }
            else if (currentElement.Name.LocalName
                     .EndsWith(OperationComponent.OPERATION_PRICE_TYPES.operation.ToString()) ||
                     currentElement.Name.LocalName
                     .EndsWith(OperationComponent.COMPONENT_PRICE_TYPES.component.ToString()))
            {
                this.GCCalculatorParams.ParentOperationComponent = new OperationComponent();
                this.GCCalculatorParams.ParentOperationComponent.SetOperationComponentProperties(
                    this.GCCalculatorParams, currentCalculationsElement, currentElement);
                //init the total costs to zero
                this.GCCalculatorParams.ParentOperationComponent.InitTotalCostsProperties();
                SetAncestorOperationComponent(currentCalculationsElement, currentElement);
                //run joint input calculations (i.e. fuel amount, fuel cost)
                //these will be copied to descendant input nodes as calculations
                //are run on those nodes
                OCCalculator ocCalculator = new OCCalculator();
                ocCalculator.SetJointInputCalculations(
                    this.GCCalculatorParams);
            }
        }