예제 #1
0
        public static Newsletter Load(Guid Id)
        {
            Newsletter result;

            try
            {
                Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (SNDK.Convert.XmlNodeToXmlDocument (SorentoLib.Services.Datastore.Get<XmlDocument> (DatastoreAisle, Id.ToString ()).SelectSingleNode ("(//didius.newsletter)[1]")));
                result = new Newsletter ();

                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 ("content"))
                {
                    result._content = (string)item["content"];
                }
            }
            catch (Exception exception)
            {
                // LOG: LogDebug.ExceptionUnknown
                SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "DIDIUS.NEWSLETTER", exception.Message));

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

            return result;
        }
예제 #2
0
        public static Newsletter FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item;
            Newsletter result = new Newsletter ();

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

            if (item.ContainsKey ("id"))
            {
                result._id = new Guid ((string)item["id"]);
            }
            else
            {
                // EXCEPTION: Excpetion.NewsletterFromXmlDocument
                throw new Exception (string.Format (Strings.Exception.NewsletterFromXmlDocument, "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 ("content"))
            {
                result._content = (string)item["content"];
            }

            return result;
        }