protected void Page_Init(object sender, EventArgs e) { HttpRequest request = base.Request; this.Page.EnableViewState = true; ipAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"]; SuspendedIPController objSuspendedIP = new SuspendedIPController(); bool IsSuspended = objSuspendedIP.IsSuspendedIP(ipAddress); if (IsSuspended) { AlreadySuspendedIPAddress(); MultiView1.Visible = false; } }
private void LoginUser() { MembershipController member = new MembershipController(); RoleController role = new RoleController(); SuspendedIPController objSuspendedIP = new SuspendedIPController(); UserInfo user = member.GetUserDetails(GetPortalID, UserName.Text); HttpContext.Current.Session[SessionKeys.IsLoginClick] = false; if (user.UserExists && user.IsApproved) { if (!(string.IsNullOrEmpty(UserName.Text) && string.IsNullOrEmpty(Password.Text))) { if (PasswordHelper.ValidateUser(user.PasswordFormat, Password.Text, user.Password, user.PasswordSalt)) { SucessFullLogin(user); } else { if (Session[SessionKeys.LoginHitCount] == null) { Session[SessionKeys.LoginHitCount] = 1; } else { loginhit = Convert.ToInt32(Session[SessionKeys.LoginHitCount]); loginhit++; Session[SessionKeys.LoginHitCount] = loginhit; } FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UsernameandPasswordcombinationdoesntmatched"));//"Username and Password combination doesn't matched!"; CaptchaValue.Text = string.Empty; if (loginhit == 3) { Page.Response.Redirect(Page.Request.Url.ToString(), true); } if (loginhit > 3 && loginhit < 6) { InitializeCaptcha(); CaptchaValue.Text = string.Empty; } else if (loginhit >= 6) { objSuspendedIP.SaveSuspendedIP(ipAddress); SuspendedIPAddressException(); Session[SessionKeys.LoginHitCount] = 0; MultiView1.Visible = false; } } } } else { if (Session[SessionKeys.LoginHitCount] == null) { Session[SessionKeys.LoginHitCount] = 1; } else { loginhit = Convert.ToInt32(Session[SessionKeys.LoginHitCount]); loginhit++; Session[SessionKeys.LoginHitCount] = loginhit; } FailureText.Text = string.Format("<p class='sfError'>{0}</p>", GetSageMessage("UserLogin", "UserDoesnotExist")); CaptchaValue.Text = string.Empty; if (loginhit == 3) { Page.Response.Redirect(Page.Request.Url.ToString(), true); } if (loginhit > 3 && loginhit < 6) { InitializeCaptcha(); CaptchaValue.Text = string.Empty; } else if (loginhit >= 6) { objSuspendedIP.SaveSuspendedIP(ipAddress); SuspendedIPAddressException(); Session[SessionKeys.LoginHitCount] = 0; MultiView1.Visible = false; } } }
protected void btnSaveChanges_Click(object sender, EventArgs e) { try { string selectedSuspendedIPID = string.Empty; string IsSuspended = string.Empty; for (int i = 0; i < gdvSuspendedIP.Rows.Count; i++) { HtmlInputCheckBox chkBoxItem = (HtmlInputCheckBox)gdvSuspendedIP.Rows[i].FindControl("chkBoxIsSuspendedItem"); HiddenField hdnSuspendedIPID = (HiddenField)gdvSuspendedIP.Rows[i].FindControl("hdnIPAddressID"); selectedSuspendedIPID = hdnSuspendedIPID.Value.Trim(); IsSuspended = chkBoxItem.Checked ? "1" : "0"; SuspendedIPController objSuspendedCon = new SuspendedIPController(); objSuspendedCon.UpdateSuspendedIP(selectedSuspendedIPID, IsSuspended); hideSubmit(); } LoadSuspendedIp(); ShowMessage("", GetSageMessage("UserManagement", "SelectedChangesAreSavedSuccessfully"), "", SageMessageType.Success); } catch (Exception ex) { ProcessException(ex); } }
private void hideSubmit() { List<SuspendedIPInfo> lstSuspendedIP = new List<SuspendedIPInfo>(); SuspendedIPController objSuspendedIP = new SuspendedIPController(); lstSuspendedIP = objSuspendedIP.GetSuspendedIP(); if (lstSuspendedIP.Count == 0) { divSave.Visible = false; } }
public void LoadSuspendedIp() { SuspendedIPController objSuspendedIP = new SuspendedIPController(); gdvSuspendedIP.DataSource = objSuspendedIP.GetSuspendedIP(); gdvSuspendedIP.DataBind(); }