public List <Sys_ModuleModel> GetMenuList(string roleId) { Sys_ModuleBLL mbll = new Sys_ModuleBLL(); Sys_RoleAuthorizeBLL rhbll = new Sys_RoleAuthorizeBLL(); var data = new List <Sys_ModuleModel>(); if (OperatorProvider.Provider.GetCurrent().IsSystem) { data = mbll.GetModelList(""); } else { var moduledata = mbll.GetModelList(""); var authorizedata = rhbll.GetModelList("F_ObjectId = '" + roleId + "' and F_ItemType = 1"); foreach (var item in authorizedata) { Sys_ModuleModel moduleEntity = mbll.GetModel(item.F_ItemId); if (moduleEntity != null) { data.Add(moduleEntity); } } } return(data.OrderBy(t => t.F_SortCode).ToList()); }
public ActionResult GetTreeSelectJson() { var data = mbll.GetModelList(""); var treeList = new List <TreeSelectModel>(); foreach (var item in data) { TreeSelectModel treeModel = new TreeSelectModel(); treeModel.id = item.F_Id; treeModel.text = item.F_FullName; treeModel.parentId = item.F_ParentId; treeList.Add(treeModel); } return(Content(treeList.TreeSelectJson())); }
private bool ActionValidate(string roleId, string moduleId, string action) { Sys_ModuleBLL modulebll = new Sys_ModuleBLL(); Sys_ModuleButtonBLL moduleButtonbll = new Sys_ModuleButtonBLL(); Sys_RoleAuthorizeBLL roleAuthorizebll = new Sys_RoleAuthorizeBLL(); var authorizeurldata = new List <AuthorizeActionModel>(); var cachedata = CacheFactory.Cache().GetCache <List <AuthorizeActionModel> >("authorizeurldata_" + roleId); if (cachedata == null) { var moduledata = modulebll.GetModelList(""); var buttondata = moduleButtonbll.GetModelList(""); var authorizedata = roleAuthorizebll.GetModelList("F_ObjectId ='" + roleId + "'"); foreach (var item in authorizedata) { if (item.F_ItemType == 1) { var moduleEntity = moduledata.Find(t => t.F_Id == item.F_ItemId); authorizeurldata.Add(new AuthorizeActionModel { F_Id = moduleEntity.F_Id, F_UrlAddress = moduleEntity.F_UrlAddress }); } else if (item.F_ItemType == 2) { var moduleButtonEntity = buttondata.Find(t => t.F_Id == item.F_ItemId); authorizeurldata.Add(new AuthorizeActionModel { F_Id = moduleButtonEntity.F_ModuleId, F_UrlAddress = moduleButtonEntity.F_UrlAddress }); } } CacheFactory.Cache().WriteCache(authorizeurldata, "authorizeurldata_" + roleId, DateTime.Now.AddMinutes(5)); } else { authorizeurldata = cachedata; } authorizeurldata = authorizeurldata.FindAll(t => t.F_Id.Equals(moduleId)); foreach (var item in authorizeurldata) { if (!string.IsNullOrEmpty(item.F_UrlAddress)) { string[] url = item.F_UrlAddress.Split('?'); if (item.F_Id == moduleId && url[0] == action) { return(true); } } } return(false); }
public ActionResult GetPermissionTree(string roleId) { var moduledata = modulebll.GetModelList(""); var buttondata = moduleButtonbll.GetModelList(""); var authorizedata = new List <Sys_RoleAuthorizeModel>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = roleAuthorizebll.GetModelList("F_ObjectId='" + roleId + "'"); } var treeList = new List <TreeViewModel>(); foreach (var item in moduledata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = moduledata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true; tree.id = item.F_Id; tree.text = item.F_FullName; tree.value = item.F_EnCode; tree.parentId = item.F_ParentId; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id); tree.hasChildren = true; tree.img = item.F_Icon == "" ? "" : item.F_Icon; treeList.Add(tree); } foreach (var item in buttondata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true; tree.id = item.F_Id; tree.text = item.F_FullName; tree.value = item.F_EnCode; tree.parentId = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id); tree.hasChildren = hasChildren; tree.img = item.F_Icon == "" ? "" : item.F_Icon; treeList.Add(tree); } return(Content(treeList.TreeViewJson())); }
public ActionResult GetCloneButtonTreeJson() { var moduledata = mbll.GetModelList(""); var buttondata = mbbll.GetModelList(""); var treeList = new List <TreeViewModel>(); foreach (var item in moduledata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = moduledata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true; tree.id = item.F_Id; tree.text = item.F_FullName; tree.value = item.F_EnCode; tree.parentId = item.F_ParentId; tree.isexpand = true; tree.complete = true; tree.hasChildren = true; treeList.Add(tree); } foreach (var item in buttondata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) == 0 ? false : true; tree.id = item.F_Id; tree.text = item.F_FullName; tree.value = item.F_EnCode; if (item.F_ParentId == "0") { tree.parentId = item.F_ModuleId; } else { tree.parentId = item.F_ParentId; } tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.hasChildren = hasChildren; if (item.F_Icon != "") { tree.img = item.F_Icon; } treeList.Add(tree); } return(Content(treeList.TreeViewJson())); }
public ActionResult SubmitForm(Sys_RoleModel roleEntity, string permissionIds, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { roleEntity.F_Id = keyValue; rolebll.Update(roleEntity); } else { roleEntity.F_Id = Common.GuId(); roleEntity.F_Category = 1; rolebll.Add(roleEntity); } var moduledata = modulebll.GetModelList(""); var buttondata = moduleButtonbll.GetModelList(""); var authorizedata = new List <Sys_RoleAuthorizeModel>(); var perIds = permissionIds.Split(','); roleAuthorizebll.DeleteByObjectId(roleEntity.F_Id); foreach (var itemId in perIds) { Sys_RoleAuthorizeModel roleAuthorizeEntity = new Sys_RoleAuthorizeModel(); roleAuthorizeEntity.F_Id = Common.GuId(); roleAuthorizeEntity.F_ObjectType = 1; roleAuthorizeEntity.F_ObjectId = roleEntity.F_Id; roleAuthorizeEntity.F_ItemId = itemId; if (moduledata.Find(t => t.F_Id == itemId) != null) { roleAuthorizeEntity.F_ItemType = 1; } if (buttondata.Find(t => t.F_Id == itemId) != null) { roleAuthorizeEntity.F_ItemType = 2; } authorizedata.Add(roleAuthorizeEntity); roleAuthorizebll.Add(roleAuthorizeEntity); } return(Success("操作成功。")); }