public bool AddUsersToGroups(UserBase[] users, int[] groupIds)
        {
            if (ArrayIsNullOrEmpty(users) || ArrayIsNullOrEmpty(groupIds))
            {
                throw new ArgumentNullException("users,groupIds", "Users or UserGroups can not be null or empty!");
            }
            bool flag = false;

            _session.BeginTransaction();
            try
            {
                foreach (int gid in groupIds)
                {
                    UserGroup grp = UserGroup.Retrieve(_session, gid);

                    flag = AddUsersToGroup(users, grp);
                    _session.Commit();
                }
            }
            catch
            {
                _session.Rollback();
                throw;
            }
            return(flag);
        }
 public void RemoveUsersFromGroups(UserBase[] users, int[] groupIds)
 {
     if (ArrayIsNullOrEmpty(users) || ArrayIsNullOrEmpty(groupIds))
     {
         throw new ArgumentNullException("users,groupIds", "Users or UserGroups can not be null or empty!");
     }
     this._session.BeginTransaction();
     try
     {
         foreach (int gid in groupIds)
         {
             UserGroup group = UserGroup.Retrieve(_session, gid);
             if (!group.RemoveUserFromGroup(users, this._session))
             {
                 throw new ApplicationException(string.Format("从用户组{0}中移出用户失败!", group.Name));
             }
         }
         _session.Commit();
     }
     catch
     {
         this._session.Rollback();
         throw;
     }
 }