// 分页控件数据绑定 private void SplitDataBind() { Dictionary <string, string> dicWhere = new Dictionary <string, string>(); KingTop.Model.Pager p = new KingTop.Model.Pager(); if (StrKeySearch != "") { dicWhere.Add("UserName", Utils.UrlDecode(StrKeySearch)); txtSearch.Text = StrKeySearch; } //如果不是超级管理员,则只显示自己用户组以下的用户 string userId = LoginInfoHelper.GetLoginAccountId(Session, Response); if (userId != "0") { UserGroup bllUserGrop = new UserGroup(); DataTable dt = bllUserGrop.GetList("LOGINUSERGROP", Utils.getTwoParams(SiteID.ToString(), userId)).Tables[0]; if (dt.Rows.Count > 0) { dicWhere.Add("NumCode", dt.Rows[0]["NumCode"].ToString()); ourNumCode = dt.Rows[0]["NumCode"].ToString(); //strUserGrop = dt.Rows[0]["UserGroupCode"].ToString(); } dicWhere.Add("UserID", userId); } dicWhere.Add("SiteID", this.SiteID.ToString()); p.DicWhere = dicWhere; p.Aspnetpage = Split; p.RptControls = RptUser; BllAccount.PageData(p, 2); }
/// <summary> /// 判断当前控制器下用户是否有对应的权限 /// <para>True : 有</para> /// <para>False : 没有</para> /// </summary> /// <param name="RouteData">当前目录信息</param> /// <param name="permission">要判断的权限点</param> /// <returns></returns> public static bool CheckRole(this RouteData RouteData, AdminLTE.Enum.PermissionType permission) { var loginInfo = LoginInfoHelper.Current(); if (loginInfo.IsAdmin) { return(true); } //var areaName = RouteData.DataTokens["area"] + ""; var controllerName = RouteData.Values["controller"].ToString().ToLower() + ""; var menuCache = MvcBase.Unity.Get <AdminLTE.Domain.Services.IMenuService>().ListCache(); string menuID = string.Empty; foreach (var menu in menuCache) { menuID = menu.Children.SingleAndInit(m => m.Url.ToLower().Contains(controllerName)).ID; if (!string.IsNullOrEmpty(menuID)) { break; } } if (loginInfo.MenuIDs.Contains(menuID)) { return(((int)permission).IntPare(loginInfo.Permissions[menuID])); } return(false); }
public ArticleController(IMainDBTool dbTool, IArticleService articleService, IArticleClassifyService articleClassifyService) { this._dbTool = dbTool; this._articleService = articleService; this._articleClassifyService = articleClassifyService; this._loginInfo = LoginInfoHelper.Current(); }
// 分页控件数据绑定 private void SplitDataBind() { Dictionary <string, string> dicWhere = new Dictionary <string, string>(); KingTop.Model.Pager p = new KingTop.Model.Pager(); KingTop.BLL.SysManage.UserGropManage objUserGrop = new KingTop.BLL.SysManage.UserGropManage(); if (StrKeySearch != "") { dicWhere.Add("UserGroupName", Utils.UrlDecode(StrKeySearch)); txtSearch.Text = StrKeySearch; } //如果不是超级管理员,则只显示自己用户组以下的用户 string userId = LoginInfoHelper.GetLoginAccountId(Session, Response); if (userId != "0") { DataTable dt = bllUserGrop.GetList("LOGINUSERGROP", Utils.getTwoParams(SiteID.ToString(), userId)).Tables[0]; if (dt.Rows.Count > 0) { dicWhere.Add("NumCode", dt.Rows[0]["NumCode"].ToString()); } } dicWhere.Add("SiteID", SiteID.ToString()); p.Aspnetpage = Split; p.RptControls = rptUserGropeList; p.DicWhere = dicWhere; //把表保存到临时内存中 dsUserGroupRole = bllUserGrop.GetList("GROUPANDROLENAME", Utils.getOneParams(SiteID.ToString())); //dsUserGroupName = BllgroupRole.GetUserGroupRole(p); objUserGrop.PageData(p, 1); }
public CustomUser LoginCustomUser(LoginInfoHelper loginInfo) { try { var customUser = _offlineMessagingDbContext.CustomUsers.Where(x => (x.Email == loginInfo.UserNameOrEmail || x.UserName == loginInfo.UserNameOrEmail) && x.Password == loginInfo.Md5Password && x.IsActive).FirstOrDefault(); if (customUser != null) { customUser.IsOnline = true; _offlineMessagingDbContext.CustomUsers.Update(customUser); _offlineMessagingDbContext.SaveChanges(); return(customUser); } else { return(null); } } catch (Exception ex) { PublicLogs publicLog = new PublicLogs(); publicLog.LogContent = ex.ToString(); publicLog.LogTime = DateTime.Now; InsertPublicLog(publicLog); return(null); } }
public void oparate() { UserGroup BllUserG = new UserGroup(); string userId = LoginInfoHelper.GetLoginAccountId(Session, Response); dtUserGroup = BllUserG.GetList("ALL", Utils.getOneParams(SiteID.ToString())).Tables[0]; ddlUserGroup.DataSource = dtUserGroup.DefaultView; ddlUserGroup.DataTextField = "UserGroupName"; ddlUserGroup.DataValueField = "userGroupCode"; ddlUserGroup.DataBind(); ListItem ls = new ListItem("请选择", "0");//追加一项 this.ddlUserGroup.Items.Insert(0, ls); if (userId != "0") { DataTable dt = BllUserG.GetList("LOGINUSERGROP", Utils.getTwoParams(SiteID.ToString(), userId)).Tables[0]; ourNumCode = dt.Rows[0]["numCode"].ToString(); } string temp_str = ""; int numCode = 0; string strCode = ""; for (int i = 0; i < dtUserGroup.Rows.Count; i++) { strCode = dtUserGroup.Rows[i]["numCode"].ToString(); if (strCode.IndexOf(ourNumCode) == 0 && strCode != ourNumCode) { numCode = strCode.Length / 3; if (numCode == 1) { } else { for (int p = 1; p < numCode; p++) { if (p == numCode - 1) { temp_str = temp_str + "├"; } else { temp_str = temp_str + " "; } } } dtUserGroup.Rows[i]["UserGroupName"] = temp_str + dtUserGroup.Rows[i]["UserGroupName"].ToString(); temp_str = ""; } else { dtUserGroup.Rows[i].Delete(); } } }
public ActionResult <CustomUser> LoginCustomUser(LoginInfoHelper loginInfo) { var customUser = _customUserServices.LoginCustomUser(loginInfo); if (customUser == null) { return(NotFound()); } return(customUser); }
public void oparate() { UserGroup BllUserG = new UserGroup(); string userId = LoginInfoHelper.GetLoginAccountId(Session, Response); dtUserGroup = BllUserG.GetList("ALL", Utils.getOneParams(SiteID.ToString())).Tables[0]; DataTable opdt = dtUserGroup.Copy(); if (userId != "0") { DataTable dt = BllUserG.GetList("LOGINUSERGROP", Utils.getTwoParams(SiteID.ToString(), userId)).Tables[0]; ourNumCode = dt.Rows[0]["numCode"].ToString(); } string temp_str = ""; int numCode = 0; string strCode = ""; for (int i = 0; i < opdt.Rows.Count; i++) { strCode = opdt.Rows[i]["numCode"].ToString(); if (strCode.IndexOf(ourNumCode) == 0) { numCode = strCode.Length / 3; if (numCode == 1) { } else { for (int p = 1; p < numCode; p++) { if (p == numCode - 1) { temp_str = temp_str + "├"; } else { temp_str = temp_str + " "; } } } opdt.Rows[i]["UserGroupName"] = temp_str + opdt.Rows[i]["UserGroupName"].ToString(); temp_str = ""; } else { opdt.Rows[i].Delete(); } } }
protected override bool AuthorizeCore(HttpContextBase httpContext) { //不是Get方法过来的请求,都不能跨站操作。防止管理员登录本站后去访问一些带有攻击本站代码的网站 if (httpContext.Request.HttpMethod.ToUpper() != "GET") { if (httpContext.Request.Url.Authority != httpContext.Request.UrlReferrer.Authority) { //throw new Exception("不允许跨站操作"); return(false); } } if (LoginInfoHelper.Current() != null) { return(true); } return(false); }
private List <MenuCacheModel> CurrentMenu() { var loginInfo = LoginInfoHelper.Current(); List <MenuCacheModel> result = new List <MenuCacheModel>(); var menus = _menuService.ListCache(); if (loginInfo.IsAdmin) { return(menus); } foreach (var rootMenu in menus) { if (loginInfo.MenuIDs.Contains(rootMenu.ID)) { MenuCacheModel root = new MenuCacheModel() { Name = rootMenu.Name, Url = rootMenu.Url, ID = rootMenu.ID, Children = new List <MenuCacheModel>() }; foreach (var menu in rootMenu.Children) { if (loginInfo.MenuIDs.Contains(menu.ID)) { MenuCacheModel child = new MenuCacheModel() { Name = menu.Name, ID = menu.ID, Url = menu.Url, Permissions = loginInfo.Permissions[menu.ID] }; root.Children.Add(child); } } result.Add(root); } } return(result); }
/// <summary> /// 确认付款 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button1_Click(object sender, EventArgs e) { #region 数据操作 try { #region 操作变量,权限验证 int flagType = 0; string error = Utils.GetResourcesValue("model", "AddError"); if (Action == "NEW") { if (!IsHaveRightByOperCode("New")) { Utils.AlertMessage(this, "你没有添加权限!"); return; } } else { if (!IsHaveRightByOperCode("Edit")) { Utils.AlertMessage(this, "你没有修改权限!"); return; } } #endregion #region 获取提交数据 model.ID = Utils.ParseInt(hidID.Value, 0); model.Name = txtName.Text; model.ParentID = Utils.ParseInt(ddlParentCategory.SelectedValue, 0); if (model.ParentID < 1) { model.ArrayParentID = model.ParentID.ToString(); model.Depth = 1; } else { dt = bcategory.GetCategoryCache(); if (dt != null && dt.Rows.Count > 0) { DataRow[] dr = dt.Select("ID=" + model.ParentID); if (dr.Length > 0) { model.ArrayParentID = dr[0]["ArrayParentID"].ToString() + "," + model.ParentID; model.Depth = Utils.ParseInt(dr[0]["Depth"].ToString(), 0) + 1; model.ParentName = dr[0]["Name"].ToString(); } } else { model.Depth = 1; } } model.IsIndex = Utils.ParseInt(rblIsIndex.SelectedValue, 1); model.IsValid = Utils.ParseInt(rblIsVaild.SelectedValue, 1); model.Orders = Utils.ParseInt(txtOrders.Text, 0); model.Description = Editor1.Content; model.PageTitle = txtPageTitle.Text; model.PageKeywords = txtPageKeywords.Text; model.PageDescription = txtPageDescription.Text; model.URLRewriter = txtURLRewriter.Text; model.Img = txtImg.Text; model.IsDel = 0; model.SiteID = 1; model.AddDate = DateTime.Now; model.UpdateDate = DateTime.Now; model.AddMan = LoginInfoHelper.GetLoginAccount(Session, Response).UserName.ToString(); model.ColumnID = "commodity";//商品分类 model.NodeCode = KingTop.Common.Utils.CheckSql(Request["NodeCode"]); #endregion if (Action.Equals("EDIT") && model.ID > 0) { Dictionary <string, object> dic = new Dictionary <string, object>(); dic.Add("Name", model.Name); dic.Add("ParentID", model.ParentID.ToString()); dic.Add("ParentName", model.ParentName); dic.Add("ArrayParentID", model.ArrayParentID); dic.Add("Orders", model.Orders.ToString()); dic.Add("AddDate", model.AddDate.ToString()); dic.Add("IsValid", model.IsValid.ToString()); dic.Add("IsIndex", model.IsIndex.ToString()); dic.Add("Description", model.Description); dic.Add("UpdateDate", model.UpdateDate.ToString()); dic.Add("PageTitle", model.PageTitle); dic.Add("PageKeywords", model.PageKeywords); dic.Add("PageDescription", model.PageDescription); dic.Add("URLRewriter", model.URLRewriter); dic.Add("Img", model.Img); int counts = InfoHelper.Edit("K_Category", dic, "ID=" + model.ID); if (counts > 0) { bcategory.SetCategoryCache(); //更新成功,提示 flagType = 1; WriteLog(GetLogValue(model.ID.ToString(), Action, "Orders", true), "", 2); Utils.RunJavaScript(this, "type=" + flagType + "" + ";title='" + Utils.AlertMessage(model.ID.ToString()) + "';id='" + model.ID.ToString() + "';msg();"); } else { //并发冲突提示 WriteLog(GetLogValue(model.ID.ToString(), Action, "Orders", false), "修改失败!", 3); Utils.RunJavaScript(this, "alert({msg:'保存失败!',title:'提示信息'})"); } } else { Dictionary <string, string> dic = new Dictionary <string, string>(); dic.Add("Name", model.Name); dic.Add("ParentID", model.ParentID.ToString()); dic.Add("ParentName", model.ParentName); dic.Add("ArrayParentID", model.ArrayParentID); dic.Add("Orders", model.Orders.ToString()); dic.Add("AddMan", model.AddMan); dic.Add("AddDate", model.AddDate.ToString()); dic.Add("IsValid", model.IsValid.ToString()); dic.Add("IsIndex", model.IsIndex.ToString()); dic.Add("SiteID", model.SiteID.ToString()); dic.Add("Description", model.Description); dic.Add("IsDel", model.IsDel.ToString()); dic.Add("Depth", model.Depth.ToString()); dic.Add("UpdateDate", model.UpdateDate.ToString()); dic.Add("ColumnID", model.ColumnID); dic.Add("NodeCode", model.NodeCode); dic.Add("PageTitle", model.PageTitle); dic.Add("PageKeywords", model.PageKeywords); dic.Add("PageDescription", model.PageDescription); dic.Add("URLRewriter", model.URLRewriter); dic.Add("Img", model.Img); int counts = InfoHelper.Add1("K_Category", dic); if (counts > 0) { bcategory.SetCategoryCache(); //添加成功,提示 flagType = 0; WriteLog(GetLogValue(model.ID.ToString(), Action, "Category", true), "", 2); //Utils.UrlRedirect(this.Page, "list.aspx", "添加成功"); Utils.RunJavaScript(this, "type=" + flagType + "" + ";title='" + Utils.AlertMessage(model.Name.ToString()) + "';id='" + counts.ToString() + "';msg();"); } else { //并发冲突提示 WriteLog(GetLogValue(model.ID.ToString(), Action, "Category", false), "添加失败!", 3); Utils.RunJavaScript(this, "alert({msg:'添加失败!',title:'提示信息'})"); } } } catch (Exception ex) { Utils.AlertMessage(this, ex.Message); } BindData(); #endregion }
public void LogOutCustomUser(LoginInfoHelper logoutInfo) { _customUserServices.LoginCustomUser(logoutInfo); }
public ActionResult Logout() { LoginInfoHelper.Logout(); return(Redirect(FormsAuthentication.LoginUrl)); }
/// <summary> /// 得到当前登录的用户账号的用户组(表Account中的UserGroupCode) /// </summary> /// <returns></returns> protected string GetLoginUserGroupCode() { return(LoginInfoHelper.GetLoginAccount(HttpContext.Current.Session, HttpContext.Current.Response).UserGroupCode); }
/// <summary> /// 得到当前登录的用户账号的主键(表Account中的主键) /// </summary> /// <returns></returns> protected string GetLoginAccountId() { return(LoginInfoHelper.GetLoginAccountId(HttpContext.Current.Session, HttpContext.Current.Response)); }