protected void tvCategory_SelectedNodeChanged(object sender, EventArgs e) { TreeNode node = this.tvCategory.SelectedNode; node.Expand(); HHCookie.AddCookie(nodeState + Profile.AccountInfo.UserName, node.Value, DateTime.Now.AddMinutes(1)); BindDetail(Convert.ToInt32(node.Value)); }
public void tvOganize_SelectedNodeChanged(object sender, EventArgs e) { TreeNode node = tvOganize.SelectedNode; node.Expand(); HHCookie.AddCookie(nodeState + Profile.AccountInfo.UserName, node.Value, DateTime.Now.AddMinutes(1)); BindUserDept(int.Parse(node.Value)); SetValue(); }
protected void tvwCategory_SelectedNodeChanged(object sender, EventArgs e) { TreeNode node = tvwCategory.SelectedNode; node.Expand(); HHCookie.AddCookie(nodeState + Profile.AccountInfo.UserName, node.Value, DateTime.Now.AddMinutes(1)); LoadChildArticles(int.Parse(node.Value)); SetValue(); }
protected void lnkChildDept_Click(object sender, EventArgs e) { LinkButton lnk = sender as LinkButton; int orgID = int.Parse(lnk.Attributes["OrgID"]); HHCookie.AddCookie(nodeState + Profile.AccountInfo.UserName, orgID.ToString(), DateTime.Now.AddSeconds(20)); CheckNode(tvOganize.Nodes, orgID.ToString()); SetValue(); BindUserDept(orgID); }
public void ProcessRequest(HttpContext context) { string c = GetValidCode(); HHCookie.AddCookie("HHOnline_ValidateCode", GlobalSettings.Encrypt(c), DateTime.Now.AddMinutes(5)); Bitmap bmp = DrawValidCode(c, 30, 2); context.Response.ClearContent(); context.Response.ContentType = "image/gif"; MemoryStream ms = new MemoryStream(); bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); context.Response.BinaryWrite(ms.ToArray()); bmp.Dispose(); context.Response.End(); }
string ValidUser(HttpContext context, ref bool result) { result = false; HttpRequest req = context.Request; string userName = req["userName"]; string pwd = req["password"]; bool rememberMe = bool.Parse(req["rememberMe"]); string validCode = req["validCode"]; string oldUrl = req["url"]; HttpCookie __cookie = HHCookie.GetCookie("HHOnline_ValidateCode"); if (__cookie == null || string.IsNullOrEmpty(__cookie.Value)) { throw new Exception("验证码已过期,请点击刷新!"); } else { if (GlobalSettings.Decrypt(__cookie.Value).Equals(validCode, StringComparison.CurrentCultureIgnoreCase)) { __cookie.Expires = DateTime.Now.AddMinutes(-1); User u = new User() { UserName = userName, Password = pwd }; switch (Users.ValidateUser(ref u)) { case LoginUserStatus.InvalidCredentials: throw new Exception("用户名密码不匹配,请重新登录!"); case LoginUserStatus.Success: result = true; HttpCookie cookie = FormsAuthentication.GetAuthCookie(u.UserName, true); FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value); FormsAuthenticationTicket newticket = new FormsAuthenticationTicket( ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, DateTime.Now.ToShortDateString()); cookie.Value = FormsAuthentication.Encrypt(newticket); HHCookie.AddCookie(cookie); string url = FormsAuthentication.GetRedirectUrl(u.UserName, true); if (rememberMe) { string userInfo = userName + ";" + pwd; userInfo = GlobalSettings.Encrypt(userInfo); HttpCookie c = new HttpCookie("HHOnline-UserInfo"); c.Values.Add("UserName", GlobalSettings.Encrypt(userName)); c.Values.Add("Password", GlobalSettings.Encrypt(pwd)); c.Expires = DateTime.Now.AddDays(365); HHCookie.AddCookie(c); } if (string.IsNullOrEmpty(oldUrl)) { switch (u.UserType) { case UserType.CompanyUser: return(GlobalSettings.RelativeWebRoot + "main.aspx"); case UserType.InnerUser: return(GlobalSettings.RelativeWebRoot + "controlpanel/controlpanel.aspx"); } } else { return(oldUrl); } break; case LoginUserStatus.AccountPending: throw new Exception("账号正在审核中,请稍后重试!"); case LoginUserStatus.AccountBanned: throw new Exception("账号已经被禁止使用!"); case LoginUserStatus.AccountDisapproved: throw new Exception("账号未通过审核,无法使用!"); case LoginUserStatus.Deleted: throw new Exception("账号已经被删除,无法使用!"); case LoginUserStatus.UnknownError: throw new Exception("登录过程中发生了异常,请联系管理员!"); } } else { throw new Exception("验证码错误,请重新输入!"); } } return(""); }
protected void btnRegister_Click(object sender, EventArgs e) { User u = new User(); u.UserName = txtLoginName.Text.Trim(); if (Users.GetUser(u.UserName) != null) { base.ExecuteJs("alert('用户名重复,要完成注册,请尝试其它的用户名!')", false); return; } u.Password = txtPassword.Text.Trim(); u.DisplayName = txtDisplayName.Text.Trim(); u.UserType = UserType.CompanyUser; u.PasswordQuestion = txtQuestion.Text.Trim(); u.PasswordAnswer = txtAnswer.Text.Trim(); u.Email = txtEmail.Text.Trim(); u.Phone = txtPhone.Text.Trim(); u.Mobile = txtMobile.Text.Trim(); u.Fax = txtFax.Text.Trim(); u.Title = txtTitle.Text.Trim(); u.Remark = txtMemo.Text.Trim(); u.AccountStatus = AccountStatus.Authenticated; u.IsManager = 1; Company com = new Company(); com.CompanyName = txtCompanyName.Text.Trim(); com.CompanyRegion = int.Parse(hfRegionCode.Value); com.Phone = txtCompanyPhone.Text.Trim(); com.Fax = txtCompanyFax.Text.Trim(); com.Address = txtCompanyAddress.Text.Trim(); com.Zipcode = txtZipCode.Text.Trim(); com.Website = txtCompanyWebsite.Text.Trim(); com.Orgcode = txtOrgCode.Text.Trim(); com.Regcode = txtIcpCode.Text.Trim(); com.Remark = txtCompanyMemo.Text.Trim(); com.CompanyStatus = CompanyStatus.ApprovalPending; com.CompanyType = CompanyType.Ordinary; CreateUserStatus status = Users.Create(u, com, true); switch (status) { case CreateUserStatus.Success: HttpCookie cookie = FormsAuthentication.GetAuthCookie(u.UserName, true); FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(cookie.Value); FormsAuthenticationTicket newticket = new FormsAuthenticationTicket( ticket.Version, ticket.Name, ticket.IssueDate, ticket.Expiration, ticket.IsPersistent, DateTime.Now.ToShortDateString()); cookie.Value = FormsAuthentication.Encrypt(newticket); HHCookie.AddCookie(cookie); string url = FormsAuthentication.GetRedirectUrl(u.UserName, true); throw new HHException(ExceptionType.Success, "注册成功,请返回首页继续浏览!"); break; case CreateUserStatus.DisallowedUsername: base.ExecuteJs("注册失败,不能使用此登录名注册,请使用其他名称!", false); break; case CreateUserStatus.DuplicateUserName: base.ExecuteJs("注册失败,此登录名已经被注册,请使用其他名称!", false); break; case CreateUserStatus.DuplicateEmail: base.ExecuteJs("注册失败,此Email已经被注册,请使用其他Email!", false); break; case CreateUserStatus.UnknownFailure: base.ExecuteJs("注册失败,发生了未知的错误,请联系管理员!", false); break; } }