示例#1
0
文件: Data.cs 项目: Gachl/RustMan-C-
        public List <string> GetKit(string kit, Auth permission)
        {
            using (MySqlConnection connection = connect())
            {
                MySqlCommand query = new MySqlCommand("SELECT `command`, `permission` FROM `kits` WHERE `name` LIKE ?kit;", connection);
                query.Prepare();
                query.Parameters.Add("?kit", kit);


                using (MySqlDataReader reader = query.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        return(null);
                    }

                    List <string> result = new List <string>();
                    while (reader.Read())
                    {
                        if (permission.Hierarchy >= Auth.Parse(reader["permission"].ToString()).Hierarchy)
                        {
                            result.Add(reader["command"].ToString());
                        }
                    }

                    return(result);
                }
            }
        }
示例#2
0
文件: Data.cs 项目: Gachl/RustMan-C-
 internal List <string> GetTeleportNamesByAccessRights(Auth right)
 {
     using (MySqlConnection connection = connect())
     {
         MySqlCommand query = new MySqlCommand("SELECT `name`, `permission` FROM `teleports`;", connection);
         using (MySqlDataReader reader = query.ExecuteReader())
         {
             List <string> result = new List <string>();
             while (reader.Read())
             {
                 Auth permission = Auth.Parse(reader["permission"].ToString());
                 if (right.Hierarchy >= permission.Hierarchy)
                 {
                     result.Add(reader["name"].ToString());
                 }
             }
             return(result);
         }
     }
 }
示例#3
0
文件: Data.cs 项目: Gachl/RustMan-C-
        internal string GetTeleport(string name, Auth auth)
        {
            using (MySqlConnection connection = connect())
            {
                MySqlCommand query = new MySqlCommand("SELECT `location`, `permission` FROM `teleports` WHERE `name` LIKE ?name;", connection);
                query.Prepare();
                query.Parameters.Add("?name", name);

                using (MySqlDataReader reader = query.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        return(null);
                    }
                    reader.Read();

                    if (auth.Hierarchy >= Auth.Parse(reader["permission"].ToString()).Hierarchy)
                    {
                        return(reader["location"].ToString());
                    }
                }
            }
            return(null);
        }
示例#4
0
文件: Data.cs 项目: Gachl/RustMan-C-
        public User GetUserById(string id)
        {
            UInt64 proper_id = 0;

            if (!UInt64.TryParse(id, out proper_id))
            {
                return(null);
            }

            using (MySqlConnection connection = connect())
            {
                MySqlCommand query = new MySqlCommand("SELECT `id`, `name`, `time`, `ip`, `online`, `last`, `member`, `karma`, `vac`, `first`, `votes`, `auth`, `watched`, `warn` FROM `users` WHERE `id` = ?id;", connection);
                query.Prepare();
                query.Parameters.Add("?id", proper_id);


                using (MySqlDataReader reader = query.ExecuteReader())
                {
                    if (!reader.HasRows)
                    {
                        return(null);
                    }

                    reader.Read();

                    User result = new User(reader["id"].ToString(), reader["name"].ToString(), (UInt32)reader["time"], reader["ip"].ToString(), (sbyte)reader["online"] == 1, (long)(UInt64)reader["last"], (UInt32)reader["member"], (int)reader["karma"], (sbyte)reader["vac"] == 1, (DateTime)reader["first"], (UInt32)reader["votes"], (String.IsNullOrEmpty(reader["auth"].ToString()) ? Auth.None : Auth.Parse(reader["auth"].ToString())), (sbyte)reader["watched"] == 1, (int)reader["warn"]);
                    return(result);
                }
            }
        }