Esempio n. 1
0
        public bool AddCalculationsToCurrentElement(
            CalculatorParameters calcParameters, ref XElement currentCalculationsElement, ref XElement currentElement)
        {
            bool bHasCalculations = false;

            if (currentElement.Name.LocalName
                == Input.INPUT_PRICE_TYPES.inputgroup.ToString() &&
                calcParameters.ExtensionDocToCalcURI.URINodeName
                != Constants.LINKEDVIEWS_TYPES.linkedview.ToString())
            {
                bHasCalculations = BIGC1Calculator.SetTotalMachineryStockCalculations(
                    ref currentCalculationsElement, ref currentElement);
            }
            else
            {
                if (currentCalculationsElement != null)
                {
                    GeneralCapital1Input machInput = new GeneralCapital1Input();
                    machInput.SetGeneralCapital1InputProperties(calcParameters,
                                                                currentCalculationsElement, currentElement);
                    //init analyzer props
                    machInput.SetCalculatorProperties(currentCalculationsElement);
                    //run the calculations
                    bHasCalculations = RunGeneralCapitalStockCalculations(machInput,
                                                                          calcParameters);
                    //serialize object back to xml (note that the base calc is not run here)
                    string sAttNameExtension = string.Empty;
                    //update the calculator attributes
                    machInput.SetAndRemoveCalculatorAttributes(sAttNameExtension,
                                                               ref currentCalculationsElement);
                    machInput.SetGeneralCapital1InputAttributes(calcParameters,
                                                                ref currentCalculationsElement, ref currentElement);
                    //set calculatorid (primary way to display calculation attributes)
                    CalculatorHelpers.SetCalculatorId(
                        currentCalculationsElement, currentElement);
                    //input groups only aggregate inputs (not input series)
                    if (currentElement.Name.LocalName
                        == Input.INPUT_PRICE_TYPES.input.ToString())
                    {
                        //the count is 1-based, while iNodePosition is 0-based
                        //so the count is the correct next index position
                        int iNodePosition = BIGC1Calculator.GeneralCapitalStock
                                            .GetNodePositionCount(calcParameters.AnalyzerParms.FilePositionIndex,
                                                                  machInput);
                        if (iNodePosition < 0)
                        {
                            iNodePosition = 0;
                        }
                        bHasCalculations = BIGC1Calculator.GeneralCapitalStock
                                           .AddGeneralCapital1StocksToDictionary(
                            calcParameters.AnalyzerParms.FilePositionIndex, iNodePosition,
                            machInput);
                    }
                }
            }
            return(bHasCalculations);
        }