Пример #1
0
        public static string GetNewValue(string fromAttName,
                                         XElement fromElement, string toAttName, string dataType,
                                         XElement toElement, bool needsUpdateList)
        {
            string sNewAttValue = string.Empty;

            //if the attribute doesn't exist in toElement, don't add it (don't add join fields to base docs)
            if (toElement.Attribute(toAttName) != null)
            {
                sNewAttValue = EditHelpers.XmlLinq.GetAttributeValue(fromElement, fromAttName);
                string sOldAttValue = EditHelpers.XmlLinq.GetAttributeValue(toElement, toAttName);
                if (string.IsNullOrEmpty(sNewAttValue) == false)
                {
                    if (sNewAttValue.Equals(sOldAttValue) == false)
                    {
                        if (!needsUpdateList)
                        {
                            //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,
                                                                      toAttName, sNewAttValue);
                            }
                        }
                        else
                        {
                            sNewAttValue = AddInHelper.NoFormattingOnly(
                                sNewAttValue, sOldAttValue, dataType);
                        }
                    }
                    else
                    {
                        sNewAttValue = string.Empty;
                    }
                }
                else
                {
                    sNewAttValue = string.Empty;
                }
            }
            return(sNewAttValue);
        }
Пример #2
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);
            }
        }