Exemple #1
0
        public static ServerService Load(Guid Id)
        {
            bool success = false;
            ServerService result = new ServerService ();

            QueryBuilder qb = new QueryBuilder (QueryBuilderType.Select);
            qb.Table (DatabaseTableName);
            qb.Columns
                (
                    "id",
                    "name"
                );

            qb.AddWhere ("id", "=", Id);

            Query query = Runtime.DBConnection.Query (qb.QueryString);

            if (query.Success)
            {
                if (query.NextRow ())
                {
                    result._id = query.GetGuid (qb.ColumnPos ("id"));
                    result._name = query.GetString (qb.ColumnPos ("name"));

                    success = true;
                }
            }

            query.Dispose ();
            query = null;
            qb = null;

            if (!success)
            {
                throw new Exception (string.Format (Strings.Exception.CountryCodeLoad, Id));
            }

            return result;
        }
Exemple #2
0
        public static ServerService FromXmlDocument(XmlDocument xmlDocument)
        {
            Hashtable item = (Hashtable)SNDK.Convert.FromXmlDocument (xmlDocument);

            ServerService result;

            if (item.ContainsKey ("id"))
            {
                try
                {
                    result = ServerService.Load (new Guid ((string)item["id"]));
                }
                catch
                {
                    result = new ServerService ();
                    result._id = new Guid ((string)item["id"]);
                }
            }
            else
            {
                result = new ServerService ();
            }

            if (item.ContainsKey ("name"))
            {
                result.Name = (string)item["name"];
            }

            return result;
        }