示例#1
0
        /// <summary>
        /// Loads a field with data from an UIField XML element
        /// </summary>
        /// <param name="field">Xml element containing the field data in the uifield xml format</param>
        internal void LoadFieldFromXml(XmlElement field)
        {
            Int32.TryParse(field.GetAttribute("UIFIELDID"), out _UIFieldID);
            Int32.TryParse(field.GetAttribute("STEP"), out _step);

            _isKeyPhrase = (field.GetAttribute("ISKEYPHRASE") == "1");
            _required = (field.GetAttribute("REQUIRED") == "1");
            _escape = (field.GetAttribute("ESCAPE") == "1");
            _rawInput = (field.GetAttribute("RAWINPUT") == "1");
            _includeInGuideEntry = (field.GetAttribute("INCLUDEINGUIDEENTRY") == "1");
            _validateEmpty = (field.GetAttribute("VALIDATEEMPTY") == "1");
            _validateNotEqualTo = (field.GetAttribute("VALIDATENOTEQUALTO") == "1");
            _validateParsesOK = (field.GetAttribute("VALIDATEPARSESOK") == "1");
            _validateCustom = (field.GetAttribute("VALIDATECUSTOM") == "1");

            _name = field.SelectSingleNode("NAME").InnerText;
            _label = field.SelectSingleNode("LABEL").InnerText;
            try
            {
                _type = (UIFieldType)Enum.Parse(typeof(UIFieldType), field.SelectSingleNode("TYPE").InnerText);
            }
            catch (Exception ex)
            {
                AddErrorXml("UIField Type Error", "UIFieldType not known or incorrect." + ex.Message, _errorXML);
                _type = UIFieldType.Unknown;
            }
            _description = field.SelectSingleNode("DESCRIPTION").InnerText;
            _keyPhraseNamespace = field.SelectSingleNode("KEYPHRASENAMESPACE").InnerText;
            _defaultValue = field.SelectSingleNode("DEFAULTVALUE").InnerText;
            _notEqualToValue = field.SelectSingleNode("NOTEQUALTOVALUE").InnerText;
            try
            {
                _permissions = (UIFieldPermissions)Enum.Parse(typeof(UIFieldPermissions), field.SelectSingleNode("PERMISSIONS").InnerText);
            }
            catch (Exception ex)
            {
                AddErrorXml("UIFieldPermissions Error", "UIFieldPermissions not known or incorrect." + ex.Message, _errorXML);
                _permissions = UIFieldPermissions.Standard;
            }
        }
示例#2
0
        /// <summary>
        /// Loads the field from the database
        /// </summary>
        /// <param name="dataReader">dataReader with the field info</param>
        public void LoadFieldFromDatabase(IDnaDataReader dataReader)
        {
            _UIFieldID = dataReader.GetInt32NullAsZero("UIFieldID");
            _name = dataReader.GetStringNullAsEmpty("Name");
            _label = dataReader.GetStringNullAsEmpty("Label");

            _type = (UIFieldType)Enum.Parse(typeof(UIFieldType), dataReader.GetStringNullAsEmpty("Type"));

            _description = dataReader.GetStringNullAsEmpty("Description");
            _isKeyPhrase = dataReader.GetBoolean("IsKeyPhrase");
            _keyPhraseNamespace = dataReader.GetStringNullAsEmpty("KeyPhraseNamespace");
            _required = dataReader.GetBoolean("Required");
            _defaultValue = dataReader.GetStringNullAsEmpty("DefaultValue");
            _escape = dataReader.GetBoolean("Escape");
            _rawInput = dataReader.GetBoolean("RawInput");
            _includeInGuideEntry = dataReader.GetBoolean("IncludeInGuideEntry");
            _validateEmpty = dataReader.GetBoolean("ValidateEmpty");
            _validateNotEqualTo = dataReader.GetBoolean("ValidateNotEqualTo");
            _validateParsesOK = dataReader.GetBoolean("ValidateParsesOK");
            _notEqualToValue = dataReader.GetStringNullAsEmpty("NotEqualToValue");
            _validateCustom = dataReader.GetBoolean("ValidateCustom");
            _step = dataReader.GetInt32NullAsZero("Step");

            _permissions = (UIFieldPermissions)Enum.Parse(typeof(UIFieldPermissions), dataReader.GetStringNullAsEmpty("Permissions"));
        }