public static async Task <bool> AddConstants(CONSTANTS_TYPES constantType,
                                                     CalculatorParameters calcParameters)
        {
            bool   bHasAdded             = false;
            string sConstantsIdAttName   = string.Empty;
            string sConstantsFullDocPath = string.Empty;
            string sConstantsId          = string.Empty;
            string sConstantsNodeQry     = string.Empty;

            switch (constantType)
            {
            case CONSTANTS_TYPES.machineryconstant:
                sConstantsIdAttName = Constants.MACHINERY_CONSTANTS_ID;
                break;

            case CONSTANTS_TYPES.randmconstant:
                sConstantsIdAttName = Constants.RANDM_ID;
                break;

            default:
                break;
            }
            sConstantsFullDocPath = CalculatorHelpers.GetLinkedListPath(
                calcParameters, constantType.ToString());
            //use the calculator node constant id fields to find the correct node
            sConstantsId
                = CalculatorHelpers.GetAttribute(
                      calcParameters.LinkedViewElement, sConstantsIdAttName);
            if (!string.IsNullOrEmpty(sConstantsId))
            {
                string sURIPath = await CalculatorHelpers.GetResourceURIPath(calcParameters.ExtensionDocToCalcURI,
                                                                             sConstantsFullDocPath);

                calcParameters.ErrorMessage += calcParameters.ExtensionDocToCalcURI.ErrorMessage;
                if (string.IsNullOrEmpty(calcParameters.ErrorMessage))
                {
                    XElement rootConstants = CalculatorHelpers.LoadXElement(calcParameters.ExtensionDocToCalcURI,
                                                                            sConstantsFullDocPath);
                    if (rootConstants != null)
                    {
                        //add the remaining constants attributes
                        CalculatorHelpers.AddAttributesWithoutIdNameDesc(
                            constantType.ToString(), sConstantsId,
                            rootConstants, calcParameters.LinkedViewElement);
                    }
                    bHasAdded = true;
                }
            }
            return(bHasAdded);
        }
Exemple #2
0
        public static void AddConstants(CONSTANTS_TYPES constantType,
                                        CalculatorParameters calcParameters)
        {
            string sConstantsIdAttName   = string.Empty;
            string sConstantsFullDocPath = string.Empty;
            string sConstantsId          = string.Empty;

            switch (constantType)
            {
            case CONSTANTS_TYPES.priceconstant:
                sConstantsIdAttName = Constants.PRICE_CONSTANTS_ID;
                break;

            default:
                break;
            }
            sConstantsFullDocPath = CalculatorHelpers.GetLinkedListPath(
                calcParameters, constantType.ToString());
            //use the calculator node constant id fields to find the correct node
            sConstantsId
                = CalculatorHelpers.GetAttribute(
                      calcParameters.LinkedViewElement, sConstantsIdAttName);
            if (!string.IsNullOrEmpty(sConstantsId))
            {
                string sErrorMsg = string.Empty;
                CalculatorHelpers.GetResourceURIPath(calcParameters.ExtensionDocToCalcURI,
                                                     sConstantsFullDocPath, sErrorMsg);
                calcParameters.ErrorMessage = sErrorMsg;
                if (string.IsNullOrEmpty(sErrorMsg))
                {
                    XElement rootConstants = CalculatorHelpers.LoadXElement(calcParameters.ExtensionDocToCalcURI,
                                                                            sConstantsFullDocPath);
                    if (rootConstants != null)
                    {
                        //add the remaining constants attributes
                        CalculatorHelpers.AddAttributesWithoutIdNameDesc(
                            constantType.ToString(), sConstantsId,
                            rootConstants, calcParameters.LinkedViewElement);
                    }
                }
            }
        }