Пример #1
0
        public static void UpdateNewValue(bool needsDbUpdate,
                                          string uriPattern, string attName, string attValue,
                                          string dataType, string stepNumber, XElement toElement,
                                          IDictionary <string, string> updates)
        {
            string sNewAttValue = string.Empty;

            //if the attribute doesn't exist in toElement, don't add it (don't add join fields to base docs)
            //this is safe because the toElement was generated from a db schema
            if (toElement.Attribute(attName) != null)
            {
                sNewAttValue = attValue;
                string sOldAttValue = EditHelpers.XmlLinq.GetAttributeValue(toElement, attName);
                if (string.IsNullOrEmpty(sNewAttValue) == false)
                {
                    if (sNewAttValue.Equals(sOldAttValue) == false)
                    {
                        //don't allow formatting-only changes to numbers (schemas ignore anyway)
                        sNewAttValue = AddInHelper.NoFormattingOnly(
                            sNewAttValue, sOldAttValue, dataType);
                        if (sNewAttValue != string.Empty)
                        {
                            EditHelpers.XmlLinq.SetAttributeValue(toElement,
                                                                  attName, sNewAttValue);
                        }
                    }
                    else
                    {
                        sNewAttValue = string.Empty;
                    }
                }
                else
                {
                    sNewAttValue = string.Empty;
                }
            }
            if (needsDbUpdate)
            {
                AddInHelper.AddToDbList(uriPattern, attName, sNewAttValue,
                                        dataType, stepNumber, updates);
            }
        }