Ejemplo n.º 1
0
        public static Authorization Load(Guid id)
        {
            Authorization result;

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

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

                if (item.ContainsKey ("token"))
                {
                    result._token = Token.FromXmlDocument ((XmlDocument)item["token"]);
                }
            }
            catch (Exception exception)
            {
                // LOG: LogDebug.ExceptionUnknown
                SorentoLib.Services.Logging.LogDebug (string.Format (SorentoLib.Strings.LogDebug.ExceptionUnknown, "SBOOK.AUTHORIZATION", exception.Message));

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

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

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

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

            if (item.ContainsKey ("token"))
            {
                    result._token = Token.FromXmlDocument ((XmlDocument)item["token"]);
            }

            return result;
        }