Exemple #1
0
        private HashSet<string> mRights = new HashSet<string>(); // A collection of fuse rights in this group.

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Creates a new instance of FuseGroup and loads the group infomation from the database.
        /// </summary>
        /// <param name="ID">The numerical ID of the group.</param>
        /// <param name="Name">The name of the group.</param>
        /// <param name="dbClient">The database connection to use to.</param>
        public FuseGroup(ushort ID, string Name, DatabaseClient dbClient)
        {
            this.mName = Name;
            this.mChildGroups = new HashSet<ushort>(); ;

            dbClient.ClearParams(); // Remove any previous parameters from the database connection.
            dbClient.AddParamWithValue("id", ID); // Add ID as a parameter

            DataColumn dCol = dbClient.ReadDataColumn("SELECT valueid FROM fuse_item WHERE type = 'group' AND groupid = @id"); // Get all child groups of this group.
            if (dCol != null) // If any exist...
                for (int i = 0; i < dCol.Table.Rows.Count; i++) // Loop through them all...
                    this.mChildGroups.Add((ushort)(uint)dCol.Table.Rows[i]["valueid"]); // And add each one to the collection of child groups.

            dCol = dbClient.ReadDataColumn("SELECT `fuse_right`.`right` AS `right` FROM `fuse_right`,`fuse_item` WHERE `fuse_item`.`type` = 'right' AND `fuse_item`.`groupid` = @id AND `fuse_item`.`valueid` = `fuse_right`.`id`"); // Get all fuse rights in this group from the database.

            if (dCol != null) // If there is fuse rights in this group...
                for (int i = 0; i < dCol.Table.Rows.Count; i++) // Loop through them all...
                    mRights.Add((string)dCol.Table.Rows[i]["right"]); // And add each one to the collection of fuse rights
        }