Пример #1
0
        //run the analyses for inputs an outputs
        public bool RunAnalyses(MN1Stock mn1Stock)
        {
            bool bHasAnalyses = false;

            //add totals to lca stocks (
            bHasAnalyses = SetAnalyses(mn1Stock);
            return(bHasAnalyses);
        }
Пример #2
0
        private bool SetAnalyses(MN1Stock mn1Stock)
        {
            bool bHasAnalysis = false;
            bool bHasTotals   = false;

            //only the totStocks are used to store numerical results
            //calcprops and analyzerprops stored in mn1stock
            mn1Stock.Total1 = new MN1Total1(this.CalcParameters);
            //need one property set
            mn1Stock.Total1.SubApplicationType = mn1Stock.CalcParameters.SubApplicationType.ToString();
            //these are the mnc and mnb calculations
            //the initial aggregation must have serialized them correctly as mnc or mnb calcors
            //costs
            foreach (MNC1Calculator ind in mn1Stock.MNSR1Stock.FoodNutritionCalcs)
            {
                if (ind.CalculatorType
                    == MN1CalculatorHelper.CALCULATOR_TYPES.foodnutSR01.ToString())
                {
                    //rerun calcs using input.OCAmount or input.CAPAmount and multiplier (input.times)
                    ind.RunMNC1Calculations(mn1Stock.CalcParameters);
                    //rerun calcs using multiplier (input.times)
                    bHasTotals = AddInputToTotalStock(mn1Stock.Total1, mn1Stock.Multiplier,
                                                      ind);
                    //stock needs some calculator properties (date)
                    BIMN1StockAnalyzer.CopyBaseElementProperties(ind.MNCInput, mn1Stock);
                    mn1Stock.Date = ind.MNCInput.Date;
                    if (bHasTotals)
                    {
                        bHasAnalysis = true;
                    }
                }
            }
            //benefits
            foreach (MNB1Calculator ind in mn1Stock.MNSR2Stock.FoodNutritionCalcs)
            {
                if (ind.CalculatorType
                    == MN1CalculatorHelper.CALCULATOR_TYPES.foodnutSR02.ToString())
                {
                    //rerun calcs using input.OCAmount or input.CAPAmount and multiplier (input.times)
                    ind.RunMNB1Calculations(mn1Stock.CalcParameters);
                    //ind.FoodNutritionCalcs holds the subprices collection (which must also be totaled)
                    bHasTotals = AddOutputToTotalStock(mn1Stock.Total1, mn1Stock.Multiplier,
                                                       ind);
                    //stock needs some calculator properties (date)
                    BIMN1StockAnalyzer.CopyBaseElementProperties(ind.MNBOutput, mn1Stock);
                    mn1Stock.Date = ind.MNBOutput.Date;
                    if (bHasTotals)
                    {
                        bHasAnalysis = true;
                    }
                }
            }
            return(bHasAnalysis);
        }
Пример #3
0
        //run the analyes for everything else
        //descendentstock holds input and output stock totals and calculators
        public bool RunAnalyses(MN1Stock mn1Stock, List <Calculator1> calcs)
        {
            bool bHasAnalyses = false;

            //add totals to mn1stock.Total1
            if (mn1Stock.Total1 == null)
            {
                mn1Stock.Total1 = new MN1Total1(this.CalcParameters);
            }
            //need one property set
            mn1Stock.Total1.SubApplicationType = this.CalcParameters.SubApplicationType.ToString();
            bHasAnalyses = SetAnalyses(mn1Stock, calcs);
            return(bHasAnalyses);
        }
Пример #4
0
 public virtual void CopyTotalMN1StockProperties(
     MN1Stock calculator)
 {
     if (this.AnalyzerType
         == MN1AnalyzerHelper.ANALYZER_TYPES.mnstat1.ToString())
     {
         this.Stat1 = new MN1Stat1(this.CalcParameters);
         this.CopyCalculatorProperties(calculator);
         this.Stat1.CopyCalculatorProperties(calculator.Stat1);
         this.Stat1.CopyTotalMN1Stat1Properties(
             this.Stat1, calculator.Stat1);
     }
     else if (this.AnalyzerType
              == MN1AnalyzerHelper.ANALYZER_TYPES.mnchangeyr.ToString() ||
              this.AnalyzerType == MN1AnalyzerHelper.ANALYZER_TYPES.mnchangeid.ToString() ||
              this.AnalyzerType == MN1AnalyzerHelper.ANALYZER_TYPES.mnchangealt.ToString())
     {
         this.Change1 = new MN1Change1(this.CalcParameters);
         this.CopyCalculatorProperties(calculator);
         this.Change1.CopyCalculatorProperties(calculator.Change1);
         this.Change1.CopyTotalMN1Change1Properties(
             this.Change1, calculator.Change1);
     }
     else if (this.AnalyzerType
              == MN1AnalyzerHelper.ANALYZER_TYPES.mnprogress1.ToString())
     {
         this.Progress1 = new MN1Progress1(this.CalcParameters);
         this.CopyCalculatorProperties(calculator);
         this.Progress1.CopyCalculatorProperties(calculator.Progress1);
         this.Progress1.CopyTotalMN1Progress1Properties(
             this.Progress1, calculator.Progress1);
     }
     else
     {
         //this handles subobjects (calparams, subp1stock, subp2stock)
         this.Total1 = new MN1Total1(this.CalcParameters);
         this.CopyCalculatorProperties(calculator);
         this.Total1.CopyCalculatorProperties(calculator.Total1);
         this.Total1.CopyTotalMN1Total1Properties(
             this.Total1, calculator.Total1);
     }
 }
Пример #5
0
        private bool SetAnalyses(MN1Stock mn1Stock, List <Calculator1> calcs)
        {
            bool bHasAnalysis = false;
            bool bHasTotals   = false;

            //only the totStocks are used in results
            //calcs holds a collection of calculators
            //so input.calc not used here but used in parent

            foreach (Calculator1 calc in calcs)
            {
                if (calc.GetType().Equals(mn1Stock.GetType()))
                {
                    MN1Stock stock = (MN1Stock)calc;
                    if (stock != null)
                    {
                        if (stock.Total1 != null)
                        {
                            //tps start substracting outcomes from op/comps
                            if (mn1Stock.CalcParameters.CurrentElementNodeName == BudgetInvestment.BUDGET_TYPES.budgettimeperiod.ToString() ||
                                mn1Stock.CalcParameters.CurrentElementNodeName == BudgetInvestment.INVESTMENT_TYPES.investmenttimeperiod.ToString())
                            {
                                //subtract stock2 (outputs) from stock1 (inputs) and display stock1 net only
                                stock.Total1.SubApplicationType = stock.SubApplicationType;
                                bHasTotals = AddandSubtractSubTotalToTotalStock(mn1Stock.Total1, stock.Multiplier, stock.Total1);
                            }
                            else
                            {
                                //multiplier is found in stock, not mn1Stock, to ensure that correct before-aggregated element multiplier is used
                                bHasTotals = AddSubTotalToTotalStock(mn1Stock.Total1, stock.Multiplier, stock.Total1);
                            }
                            if (bHasTotals)
                            {
                                bHasAnalysis = true;
                            }
                        }
                    }
                }
            }
            return(bHasAnalysis);
        }
Пример #6
0
 //copy constructor
 public MN1Stock(MN1Stock calculator)
 {
     CopyTotalMN1StockProperties(calculator);
 }