private bool SetOutcomeGroupCalculations(
            CalculatorParameters calcParameters,
            OutcomeGroup outcomeGroup)
        {
            bool bHasCalculations = false;

            outcomeGroup.TotalR         += calcParameters.ParentTimePeriod.TotalR;
            outcomeGroup.TotalRINCENT   += calcParameters.ParentTimePeriod.TotalRINCENT;
            outcomeGroup.TotalAMR       += calcParameters.ParentTimePeriod.TotalAMR;
            outcomeGroup.TotalAMRINCENT += calcParameters.ParentTimePeriod.TotalAMRINCENT;
            bHasCalculations             = true;
            return(bHasCalculations);
        }
Beispiel #2
0
 //copy constructor
 public OutcomeGroup(CalculatorParameters calcParameters,
                     OutcomeGroup outcomeGroup)
 {
     //several extensions store some calculator props in base element (observations, targettype)
     //no harm done in setting them but never set their attributes
     this.CopyCalculatorProperties(outcomeGroup);
     this.CopySharedObjectProperties(outcomeGroup);
     this.DocStatus = outcomeGroup.DocStatus;
     this.ServiceId = outcomeGroup.ServiceId;
     this.Type      = outcomeGroup.Type;
     this.CopyTotalBenefitsProperties(outcomeGroup);
     //calculators are always app-specific and must be copied subsequently
     this.Calculators  = new List <Calculator1>();
     this.ErrorMessage = outcomeGroup.ErrorMessage;
     if (outcomeGroup.Local == null)
     {
         outcomeGroup.Local = new Local();
     }
     this.Local = new Local(calcParameters, outcomeGroup.Local);
     if (outcomeGroup.XmlDocElement != null)
     {
         this.XmlDocElement = new XElement(outcomeGroup.XmlDocElement);
     }
 }
        private bool AddNPVCalculationsToCurrentElement(
            CalculatorParameters calcParameters, ref XElement currentCalculationsElement,
            ref XElement currentElement, IDictionary <string, string> updates)
        {
            bool bHasCalculations = false;

            if (currentElement.Name.LocalName
                == Outcome.OUTCOME_PRICE_TYPES.outcomegroup.ToString())
            {
                OutcomeGroup outcomeGroup
                    = new OutcomeGroup();
                //deserialize xml to object
                outcomeGroup.SetOutcomeGroupProperties(
                    calcParameters, currentCalculationsElement, currentElement);
                bHasCalculations = SetOutcomeGroupCalculations(
                    calcParameters, outcomeGroup);
                //serialize object back to xml
                outcomeGroup.SetOutcomeGroupAttributes(
                    calcParameters, ref currentElement, updates);
                if (outcomeGroup != null)
                {
                    //locals only for calculator
                    outcomeGroup.Local.SetLocalAttributesForCalculator(calcParameters,
                                                                       ref currentCalculationsElement);
                }
            }
            else if (currentElement.Name.LocalName
                     .EndsWith(Outcome.OUTCOME_PRICE_TYPES.outcome.ToString()))
            {
                BICalculator biCalculator = new BICalculator();
                bHasCalculations
                    = biCalculator.SetOutcomeCalculations(
                          calcParameters, calcParameters.ParentOutcome);
                //serialize object back to xml
                calcParameters.ParentOutcome.SetOutcomeAttributes(
                    calcParameters, ref currentElement, updates);
                if (calcParameters.ParentOutcome.Local != null)
                {
                    //locals only for calculator
                    calcParameters.ParentOutcome.Local.SetLocalAttributesForCalculator(calcParameters,
                                                                                       ref currentCalculationsElement);
                }
            }
            else if (currentElement.Name.LocalName.EndsWith(Output.OUTPUT_PRICE_TYPES.output.ToString()))
            {
                Output output = new Output();
                //deserialize xml to object
                output.SetOutputProperties(
                    calcParameters, currentCalculationsElement, currentElement);
                BICalculator biCalculator = new BICalculator();
                bHasCalculations
                    = biCalculator.SetOutputCalculations(
                          calcParameters, output, ref currentCalculationsElement);
                //serialize object back to xml
                output.SetOutputAttributes(
                    calcParameters, ref currentElement, updates);
                //and set the totals
                output.SetTotalBenefitsAttributes(string.Empty, ref currentElement);
                if (output.Local != null)
                {
                    //locals only for calculator
                    output.Local.SetLocalAttributesForCalculator(calcParameters,
                                                                 ref currentCalculationsElement);
                }
            }
            return(bHasCalculations);
        }