void BindOrganize() { List <Organization> orgs = Organizations.GetAllOrganizations(); TreeNode tn = null; foreach (Organization o in orgs) { if (o.ParentID == 0) { tn = new TreeNode(o.OrganizationName, o.OrganizationID.ToString(), GlobalSettings.RelativeWebRoot + "images/default/company.gif"); tn.ToolTip = o.OrganizationDesc; tn.CollapseAll(); LoadChild(tn); tvOganize.Nodes.Add(tn); } } HttpCookie cache = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName); if (cache != null) { CheckNode(tvOganize.Nodes, cache.Value); SetValue(); BindUserDept(int.Parse(cache.Value)); } }
/// <summary> /// 加载数据 /// </summary> void BindCategory() { TreeNode root = new TreeNode("所有分类", "0", GlobalSettings.RelativeWebRoot + "images/default/cat.gif"); TreeNode tn = null; this.tvCategory.Nodes.Add(root); List <ProductCategory> categories = ProductCategories.GetChidCategories(0); foreach (ProductCategory category in categories) { tn = new TreeNode(category.CategoryName, category.CategoryID.ToString(), GlobalSettings.RelativeWebRoot + "images/default/cat.gif"); tn.ToolTip = category.CategoryDesc; //tn.CollapseAll(); LoadChild(tn); root.ChildNodes.Add(tn); //mbMsg.ShowMsg("请在产品分类树中选择您将要执行操作的分类"); } HttpCookie cache = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName); int categoryID = 0; if (cache != null) { categoryID = Convert.ToInt32(cache.Value); } CheckNode(tvCategory.Nodes, categoryID.ToString()); BindDetail(categoryID); }
/// <summary> /// 绑定分类集合 /// </summary> private void BindCategories() { List <ArticleCategory> categories = ArticleManager.GetAllCategories(); foreach (ArticleCategory info in categories) { if (info.ParentID == null || info.ParentID == 0) { TreeNode newNode = MakeCategoryNode(info); newNode.ExpandAll(); LoadChild(newNode); tvwCategory.Nodes.Add(newNode); } } HttpCookie cache = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName); if (cache != null) { CheckNode(tvwCategory.Nodes, cache.Value); SetValue(); LoadChildArticles(int.Parse(cache.Value)); } if (tvwCategory.Nodes.Count != 0) { HttpCookie hhcache = HHCookie.GetCookie(nodeState + Profile.AccountInfo.UserName); if (hhcache != null) { CheckNode(tvwCategory.Nodes, hhcache.Value); SetValue(); //BindUserDept(int.Parse(hhcache.Value)); } else { tvwCategory.Nodes[0].Selected = true; } tvwCategory_SelectedNodeChanged(tvwCategory, null); } }
protected void Page_Load(object sender, EventArgs e) { if (User.Identity.IsAuthenticated) { throw new HHException(ExceptionType.Failed, "您已经登录,请勿重复操作!"); } HttpCookie c = HHCookie.GetCookie("HHOnline-UserInfo"); if (c != null) { string uid = GlobalSettings.Decrypt(c.Values["UserName"]); string pwd = GlobalSettings.Decrypt(c.Values["Password"]); base.ExecuteJs("window.$userinfo={uid:'" + uid + "',pwd:'" + pwd + "'};", false); } string oldUrl = string.Empty; if (Request.UrlReferrer != null) { oldUrl = Request.UrlReferrer.ToString(); } base.ExecuteJs("window.$url='" + oldUrl + "';", true); }
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(""); }