Esempio n. 1
0
        //methods
        public ANALYZER_TYPES GetAnalyzerType()
        {
            ANALYZER_TYPES eAnalyzerType = ANALYZER_TYPES.none;
            string         sAnalyzerType = CalculatorHelpers.GetAnalyzerType(
                this.HCCalculatorParams.LinkedViewElement);

            eAnalyzerType = GetAnalyzerType(sAnalyzerType);
            return(eAnalyzerType);
        }
        public bool SetOpOrCompMachinery2StockJointCalculations(ref XElement currentCalculationsElement,
                                                                ref XElement currentElement)
        {
            bool bHasCalculations = false;

            if (this.GCCalculatorParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.operationprices ||
                this.GCCalculatorParams.SubApplicationType == Constants.SUBAPPLICATION_TYPES.componentprices)
            {
                string sAnalyzerType = CalculatorHelpers.GetAnalyzerType(currentCalculationsElement);
                if (sAnalyzerType != this.GCCalculatorParams.AnalyzerParms.AnalyzerType)
                {
                    //standard getally calcs may retrieve resource 01 calculator
                    //(because finds relatedcalculatortype=agmachinery)
                    //which must not be overwritten if UseSameCalcInChildren = true
                    currentCalculationsElement = CalculatorHelpers.GetChildLinkedViewUsingAttribute(currentElement,
                                                                                                    Calculator1.cAnalyzerType, this.GCCalculatorParams.AnalyzerParms.AnalyzerType);
                    //CalculatorHelpers.ReplaceAnalyzerCalculator(this.GCCalculatorParams, currentElement,
                    //   this.GCCalculatorParams.AnalyzerParms.AnalyzerType,
                    //    ref currentCalculationsElement);
                }
            }
            //step 4. Run both mach1stock and mach2stock calculations keeping both indices synch
            string sCalculatorType = CalculatorHelpers.CALCULATOR_TYPES.operation2.ToString();

            if (currentElement.Name.LocalName.EndsWith(OperationComponent.OPERATION_PRICE_TYPES.operation.ToString()))
            {
                sCalculatorType = CalculatorHelpers.CALCULATOR_TYPES.operation2.ToString();
            }
            else if (currentElement.Name.LocalName.EndsWith(OperationComponent.COMPONENT_PRICE_TYPES.component.ToString()))
            {
                sCalculatorType = CalculatorHelpers.CALCULATOR_TYPES.component2.ToString();
            }
            if (currentCalculationsElement == null)
            {
                //either a base resource01 calculation was not run
                //or it was never added to base npv calculator
                currentCalculationsElement = new XElement(this.GCCalculatorParams.LinkedViewElement);
            }
            //i.e. make sure to use the baseNPV linked view holding base machinery cost and timeliness penalty information
            XElement baseNPVCalculation = CalculatorHelpers.GetChildLinkedViewUsingAttribute(currentElement,
                                                                                             Calculator1.cCalculatorType, sCalculatorType);

            if (baseNPVCalculation == null)
            {
                //the display will point out bad params if currentCalcEl is wrong
                baseNPVCalculation = currentCalculationsElement;
            }
            ////set machinery cost totals
            //int iFPIndex = this.GCCalculatorParams.AnalyzerParms.FilePositionIndex;
            //when this method is called from opcomp or input group
            if (this.TimelinessOpComp == null)
            {
                this.TimelinessOpComp = new TimelinessOpComp1();
            }
            //note that the machnpvoc calculator can not change Operation properties
            //but needs several properties from the Operation (i.e. Id, Amount)
            this.TimelinessOpComp.SetOperationComponentProperties(this.GCCalculatorParams,
                                                                  currentCalculationsElement, currentElement);
            //init mach2Stock props
            this.Machinery2Stock.SetCalculatorProperties(currentCalculationsElement);
            this.TimelinessOpComp.SetTimelinessOC1Properties(baseNPVCalculation);
            //baseNPVCalc must be used to set machinery calcs
            this.SetOpOrCompMachineryStockCalculations(ref currentCalculationsElement, ref currentElement);
            //reset opcomp.amount to base (not the stored linkedview amount)
            this.TimelinessOpComp.SetTimelinessBaseProperties(currentElement);
            //set machinery cost totals
            int iFPIndex = this.GCCalculatorParams.AnalyzerParms.FilePositionIndex;

            this.GCCalculatorParams.AnalyzerParms.FilePositionIndex = iFPIndex;
            //set timeliness penalty totals
            bHasCalculations = SetOpOrCompMachinery2StockCalculations(ref currentCalculationsElement, ref currentElement);
            //keep the newly set fileposition index
            return(bHasCalculations);
        }