//define the actions to take when the event is raised
        public void AddCalculations(object sender, CustomEventArgs e)
        {
            //pass a byref xelement from the publisher's data
            XElement statElement       = null;
            XElement linkedViewElement = null;

            if (e.CurrentElement != null)
            {
                statElement = new XElement(e.CurrentElement);
            }
            if (e.LinkedViewElement != null)
            {
                linkedViewElement = new XElement(e.LinkedViewElement);
            }
            MN1CalculatorHelper.CALCULATOR_TYPES eCalculatorType
                = MN1CalculatorHelper.GetCalculatorType(
                      this.GCCalculatorParams.CalculatorType);
            //run normally and save the same statelement and linkedviewelement
            e.HasCalculations = RunMN1Analysis(
                ref statElement, ref linkedViewElement);
            if (e.HasCalculations)
            {
                //pass the new statelement back to the publisher
                //by setting the CalculatedElement property of CustomEventArgs
                if (statElement != null)
                {
                    e.CurrentElement = new XElement(statElement);
                }
                if (linkedViewElement != null)
                {
                    e.LinkedViewElement = new XElement(linkedViewElement);
                }
            }
        }
        private bool RunMN1Calculation(MN1CalculatorHelper.CALCULATOR_TYPES calculatorType,
                                       ref XElement currentElement, ref XElement currentCalculationsElement)
        {
            bool bHasCalculations = false;

            switch (calculatorType)
            {
            case MN1CalculatorHelper.CALCULATOR_TYPES.foodnutSR01:
                //serialize, run calcs, and deserialize
                MNC1Calculator mnc1 = new MNC1Calculator();
                bHasCalculations = mnc1.SetMNC1Calculations(calculatorType, this.GCCalculatorParams,
                                                            ref currentCalculationsElement, ref currentElement);
                break;

            case MN1CalculatorHelper.CALCULATOR_TYPES.foodnutSR02:
                //serialize, run calcs, and deserialize
                MNB1Calculator mnb1 = new MNB1Calculator();
                bHasCalculations = mnb1.SetMNB1Calculations(calculatorType, this.GCCalculatorParams,
                                                            ref currentCalculationsElement, ref currentElement);
                break;

            default:
                //should be running an analysis
                break;
            }
            return(bHasCalculations);
        }
Beispiel #3
0
 private static void CheckForLastStepCalculator(
     CalculatorParameters mn1CalcParams,
     ContractHelpers.EXTENSION_STEPS stepNumber,
     ExtensionContentURI extDocToCalcURI)
 {
     MN1CalculatorHelper.CALCULATOR_TYPES eCalculatorType
         = MN1CalculatorHelper.GetCalculatorType(
               mn1CalcParams.CalculatorType);
     //other projects have code for handling different
     //numbers of steps in calculators
 }
        //define the actions to take when the event is raised
        public void AddCalculations(object sender, CustomEventArgs e)
        {
            //pass a byref xelement from the publisher's data
            XElement statElement       = null;
            XElement linkedViewElement = null;

            if (e.CurrentElement != null)
            {
                statElement = new XElement(e.CurrentElement);
            }
            if (e.LinkedViewElement != null)
            {
                linkedViewElement = new XElement(e.LinkedViewElement);
            }
            //run the stats and add them to statelement
            MN1CalculatorHelper.CALCULATOR_TYPES eCalculatorType
                = MN1CalculatorHelper.GetCalculatorType(
                      this.GCCalculatorParams.CalculatorType);
            //run the stats and add them to statelement
            if (eCalculatorType == MN1CalculatorHelper.CALCULATOR_TYPES.foodnutSR01 ||
                eCalculatorType == MN1CalculatorHelper.CALCULATOR_TYPES.foodnutSR02)
            {
                e.HasCalculations = RunMN1Calculation(eCalculatorType,
                                                      statElement, linkedViewElement);
            }
            else
            {
                //run normally and save the same statelement and linkedviewelement
                e.HasCalculations = RunMN1Analysis(
                    statElement, linkedViewElement);
                //if (!this.HasTotals)
                //{
                //    //run normally and save the same statelement and linkedviewelement
                //    e.HasCalculations = RunMN1Analysis(
                //        statElement, linkedViewElement);
                //}
            }
            if (e.HasCalculations)
            {
                //pass the new statelement back to the publisher
                //by setting the CalculatedElement property of CustomEventArgs
                if (statElement != null)
                {
                    e.CurrentElement = new XElement(statElement);
                }
                if (linkedViewElement != null)
                {
                    e.LinkedViewElement = new XElement(linkedViewElement);
                }
            }
        }
Beispiel #5
0
        public bool SetMNC1Calculations(
            MN1CalculatorHelper.CALCULATOR_TYPES calculatorType,
            CalculatorParameters calcParameters, XElement calculator,
            XElement currentElement)
        {
            bool   bHasCalculations = false;
            string sErrorMessage    = string.Empty;

            InitMNC1Properties();
            //deserialize xml to object
            //set the base input properties (updates base input prices)
            //locals come from input
            this.MNCInput.SetInputProperties(calcParameters,
                                             calculator, currentElement);
            //set the calculator
            this.SetMNC1Properties(calculator, currentElement);
            bHasCalculations = RunMNC1Calculations(calcParameters);
            if (calcParameters.SubApplicationType == Constants.SUBAPPLICATION_TYPES.inputprices)
            {
                //serialize object back to xml and fill in updates list
                //this also removes atts
                this.MNCInput.SetInputAttributes(calcParameters,
                                                 currentElement, calcParameters.Updates);
            }
            else
            {
                //no db updates outside base output
                this.MNCInput.SetInputAttributes(calcParameters,
                                                 currentElement, null);
            }
            //this sets and removes some atts
            this.SetMNC1Attributes(string.Empty, calculator);
            //set the totals into calculator
            this.MNCInput.SetNewInputAttributes(calcParameters, calculator);
            //set calculatorid (primary way to display calculation attributes)
            CalculatorHelpers.SetCalculatorId(
                calculator, currentElement);
            calcParameters.ErrorMessage = sErrorMessage;
            return(bHasCalculations);
        }