protected void btnRemoveFromUser_Click(object sender, EventArgs e)
    {
        IList<int> groupIds = new List<int>();
        foreach (RepeaterItem item in this.rptUserToGroup.Items)
        {
            HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
            if (chk != null && chk.Checked)
                groupIds.Add(Magic.Framework.Utils.Cast.Int(chk.Value, 0));
        }
        if (groupIds.Count > 0)
        {
            int[] arrayIds = new int[groupIds.Count];
            groupIds.CopyTo(arrayIds, 0);
            using (_session = new Session())
            {
                UserBase user = Magic.Sys.User.Retrieve(_session, this._userId);

                try
                {
                    AuthorizationRepository repository = new AuthorizationRepository(_session);
                    repository.RemoveUsersFromGroups(new UserBase[] { user }, arrayIds);
                    LoadUserToGroup();
                }
                catch (UnauthorizedException ex)
                {
                    WebUtil.ShowMsg(this, ex.Message, "警告");
                }
                catch (ApplicationException ex)
                {
                    WebUtil.ShowMsg(this, ex.Message, "提示");
                }
                catch (Exception ex)
                {
                    logger.Info("AddUsersToGroups", ex);
                    WebUtil.ShowError(this, ex);
                }
            }
        }
    }
    protected void btnRemoveFromGroup_Click(object sender, EventArgs e)
    {
        IList<int> userIds = new List<int>();
        foreach (RepeaterItem item in this.rptUserInGroup.Items)
        {
            HtmlInputCheckBox chk = item.FindControl("checkbox") as HtmlInputCheckBox;
            if (chk != null)
            {
                if (chk.Checked)
                {
                    userIds.Add(int.Parse(chk.Value));
                }
            }
        }
        if (userIds.Count > 0)
        {
            int[] arrayIds = new int[userIds.Count];
            userIds.CopyTo(arrayIds, 0);
            using (_session = new Session())
            {

                try
                {
                    AuthorizationRepository repository = new AuthorizationRepository(_session);

                    repository.RemoveUsersFromGroups(arrayIds, new int[] { _groupId });

                    LoadUserInGroup();
                }
                catch (UnauthorizedException ex)
                {
                    WebUtil.ShowMsg(this, ex.Message, "警告");
                }
                catch (ApplicationException ex)
                {
                    WebUtil.ShowMsg(this, ex.Message, "提示");
                }
                catch (Exception ex)
                {
                    logger.Info("从用户组中移出用户", ex);
                    WebUtil.ShowError(this, ex);
                }
            }
        }
    }