Exemplo n.º 1
0
        public static DataTypeDefinition Import(XmlNode xmlData)
        {
            string _name = xmlData.Attributes["Name"].Value;
            string _id   = xmlData.Attributes["Id"].Value;
            string _def  = xmlData.Attributes["Definition"].Value;


            //Make sure that the dtd is not already present
            if (!CMSNode.IsNode(new Guid(_def)))
            {
                BusinessLogic.User u = BusinessLogic.User.GetCurrent();

                if (u == null)
                {
                    u = BusinessLogic.User.GetUser(0);
                }

                controls.Factory   f   = new controls.Factory();
                DataTypeDefinition dtd = MakeNew(u, _name, new Guid(_def));
                var dataType           = f.DataType(new Guid(_id));
                if (dataType == null)
                {
                    throw new NullReferenceException("Could not resolve a data type with id " + _id);
                }

                dtd.DataType = dataType;
                dtd.Save();

                //add prevalues
                foreach (XmlNode xmlPv in xmlData.SelectNodes("PreValues/PreValue"))
                {
                    XmlAttribute val = xmlPv.Attributes["Value"];

                    if (val != null)
                    {
                        PreValue p = new PreValue(0, 0, val.Value);
                        p.DataTypeId = dtd.Id;
                        p.Save();
                    }
                }

                return(dtd);
            }

            return(null);
        }
Exemplo n.º 2
0
        public static DataTypeDefinition Import(XmlNode xmlData)
        {
            string _name = xmlData.Attributes["Name"].Value;
            string _id = xmlData.Attributes["Id"].Value;
            string _def = xmlData.Attributes["Definition"].Value;


            //Make sure that the dtd is not already present
            if (!CMSNode.IsNode(new Guid(_def)))
            {
                BusinessLogic.User u = BusinessLogic.User.GetCurrent();

                if (u == null)
                    u = BusinessLogic.User.GetUser(0);

                controls.Factory f = new controls.Factory();
                DataTypeDefinition dtd = MakeNew(u, _name, new Guid(_def));
                var dataType = f.DataType(new Guid(_id));
                if (dataType == null)
                    throw new NullReferenceException("Could not resolve a data type with id " + _id);

                dtd.DataType = dataType;
                dtd.Save();

                //add prevalues
                foreach (XmlNode xmlPv in xmlData.SelectNodes("PreValues/PreValue"))
                {
                    XmlAttribute val = xmlPv.Attributes["Value"];

                    if (val != null)
                    {
                        PreValue p = new PreValue(0, 0, val.Value);
                        p.DataTypeId = dtd.Id;
                        p.Save();
                    }
                }

                return dtd;
            }

            return null;
        }