Exemplo n.º 1
0
        public static Root Load(Guid id)
        {
            Root result;

            try
            {
                Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (SorentoLib.Services.Datastore.Get<XmlDocument> (DatastoreAisle, id.ToString ()).SelectSingleNode ("(//scms.root)[1]")));
                result = new Root ();

                result._id = new Guid ((string)item["id"]);

                if (item.ContainsKey ("createtimestamp"))
                {
                    result._createtimestamp = int.Parse ((string)item["createtimestamp"]);
                }

                if (item.ContainsKey ("updatetimestamp"))
                {
                    result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]);
                }

                if (item.ContainsKey ("title"))
                {
                    result._title = (string)item["title"];
                }

                if (item.ContainsKey ("filters"))
                {
                    result._filters.Clear ();

                    foreach (XmlDocument filter in (List<XmlDocument>)item["filters"])
                    {
                        result._filters.Add (RootFilter.FromXmlDocument (filter));
                    }
                }
            }
            catch (Exception exception)
            {
                // LOG: LogDebug.ExceptionUnknown
                SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "SCMS.ROOT", exception.Message));

                // EXCEPTION: Excpetion.RootLoad
                throw new Exception (string.Format (Strings.Exception.RootLoad, id));
            }

            return result;
        }
Exemplo n.º 2
0
        public static Root FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item;
            Root result;

            try
            {
                item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (xmlDocument.SelectSingleNode ("(//scms.root)[1]")));
            }
            catch
            {
                item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);
            }

            if (item.ContainsKey ("id"))
            {
                try
                {
                    result = Load (new Guid ((string)item["id"]));
                }
                catch
                {
                    result = new Root ();
                    result._id = new Guid ((string)item["id"]);
                }
            }
            else
            {
                // EXCEPTION: Exception.RootFromXMLDocument
                throw new Exception (Strings.Exception.RootFromXMLDocument);
            }

            if (item.ContainsKey ("createtimestamp"))
            {
                result._createtimestamp = int.Parse ((string)item["createtimestamp"]);
            }

            if (item.ContainsKey ("updatetimestamp"))
            {
                result._updatetimestamp = int.Parse ((string)item["updatetimestamp"]);
            }

            if (item.ContainsKey ("title"))
            {
                result._title = (string)item["title"];
            }

            if (item.ContainsKey ("filters"))
            {
                result._filters.Clear ();

                foreach (XmlDocument filter in (List<XmlDocument>)item["filters"])
                {
                    result._filters.Add (RootFilter.FromXmlDocument (filter));
                }
            }

            return result;
        }