示例#1
0
        protected void lbtnDisable_Click(object sender, EventArgs e)
        {
            Dictionary <int, int> dicIDs = new Dictionary <int, int>();

            // Get userid of current selected row
            foreach (GridViewRow row in gridUserList.Rows)
            {
                if (DataControlRowType.DataRow == row.RowType)
                {
                    CheckBox ckbChecked = row.FindControl("ckbSelected") as CheckBox;
                    if (null != ckbChecked && ckbChecked.Checked)
                    {
                        dicIDs.Add(row.RowIndex, (int)gridUserList.DataKeys[row.RowIndex].Value);
                    }
                }
            }
            if (dicIDs.Count > 0)
            {
                try
                {
                    UsersManager.SetUsersDisable(dicIDs.Select(i => i.Value).ToList());
                }
                catch (Exception ex)
                {
                    ClientFun(this.updatePanel, "failedtodisableuser", "alert('Failed to disable the selected user account(s), please try it again.');");
                    //PageCommon.AlertMsg(this, "Failed to disable the selected users, please try it again.");
                    LPLog.LogMessage(LogType.Logerror, "Failed to disable the selected user account(s): " + ex.Message);
                    return;
                }
                BindGrid();
                try
                {
                    UpdateAD(dicIDs, UserMgrCommandType.DisableUser);
                }
                catch (Exception ex)
                {
                    ClientFun(this.updatePanel, "failedtodisableuserinad", string.Format("alert('Failed to disable the selected user account(s) in AD, Exception: {0}');", ex.Message.Replace("'", "\"")));
                    //PageCommon.AlertMsg(this, "Failed to disable the user account in AD.");
                    LPLog.LogMessage(LogType.Logerror, "Failed to disable the selected user account(s), exception: " + ex.Message);
                    return;
                }
            }
        }