コード例 #1
0
 public void AddGroup(Group grp)
 {
     groups.Add(grp);
     groupsByMaster.Add(grp.Master.Name, grp);
     groupsById.Add(grp.Id, grp);
     updateQueue.Enqueue(grp);
 }
コード例 #2
0
        public static Group LoadGroupFromDatabaseById(long pId)
        {
            //--------------------------------------------------
            // Queries used in this function
            //--------------------------------------------------
            const string read_group_query =
                "USE `fiesta_world`; "	+
                "SELECT `Id`, `Member1`, `Member2`, `Member3`, `Member4`, `Member5` " +
                "FROM `groups` " +
                "WHERE Id = {0}";

            //--------------------------------------------------
            // Reading the group out of the database
            //--------------------------------------------------

            Group grp = new Group();
            grp.Id = pId;

            using (var client = Program.DatabaseManager.GetClient())
            {
                string query = string.Format(read_group_query, pId);
                using(var cmd = new MySqlCommand(query, client.GetConnection()))
                using(var reader = cmd.ExecuteReader())
             	    {
                    while(reader.Read ())
                    {
                        for(int i = 1; i < 6; i++)
                        {
                            if(!reader.IsDBNull(i))
                                grp.Members.Add(ReadGroupMemberFromDatabase(reader.GetInt64(i)));
                        }
                    }
                }
            }

            return grp;
        }
コード例 #3
0
 private void UpdateGroup(Group grp)
 {
     if(!groups.Contains(grp))
         return;
     grp.Update();
     updateQueue.Enqueue(grp);
 }
コード例 #4
0
 private void RemoveGroup(Group grp)
 {
     this.groups.Remove(grp);
     this.groupsByMaster.Remove(grp.Master.Name);
     this.groupsById.Remove(grp.Id);
 }