public ActionResult GetTreeSelectJson() { var data = SysModuleService.GetList(); var treeList = new List <TreeSelectModel>(); foreach (var item in data) { TreeSelectModel treeModel = new TreeSelectModel(); treeModel.id = item.Id; treeModel.text = item.FullName; treeModel.parentId = item.ParentId; treeList.Add(treeModel); } return(Content(treeList.TreeSelectJson())); }
public void SubmitForm(SysRole SysRole, string[] permissionIds, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { SysRole.Id = keyValue; } else { SysRole.Id = Common.GuId(); } var moduledata = _SysModuleService.GetList(); var buttondata = _SysModuleButtonService.GetList(); List <SysRoleAuthorize> SysRoleAuthorizes = new List <SysRoleAuthorize>(); foreach (var itemId in permissionIds) { SysRoleAuthorize SysRoleAuthorize = new SysRoleAuthorize(); SysRoleAuthorize.Id = Common.GuId(); SysRoleAuthorize.ObjectType = 1; SysRoleAuthorize.ObjectId = SysRole.Id; SysRoleAuthorize.ItemId = itemId; if (moduledata.Find(t => t.Id == itemId) != null) { SysRoleAuthorize.ItemType = 1; } if (buttondata.Find(t => t.Id == itemId) != null) { SysRoleAuthorize.ItemType = 2; } SysRoleAuthorizes.Add(SysRoleAuthorize); } _Respository.SubmitForm(SysRole, SysRoleAuthorizes, keyValue); }
public List <SysModule> GetMenuList(string roleId) { var data = _SysModuleService.GetList().Where(w => w.EnabledMark != null && w.EnabledMark.Value).ToList(); if (!CoreContextProvider.CurrentSysUser.IsSystem) { var authorizedata = _Respository.Get(t => t.ObjectId == roleId && t.ItemType == 1).ToList(); foreach (var item in authorizedata) { SysModule SysModule = data.Find(t => t.Id == item.ItemId); if (SysModule != null) { data.Add(SysModule); } } } return(data.OrderBy(t => t.SortCode).ToList()); }
public ActionResult GetPermissionTree(string roleId) { var moduledata = SysModuleService.GetList(); var buttondata = SysModuleButtonService.GetList(); var authorizedata = new List <SysRoleAuthorize>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = SysRoleAuthorizeService.GetList(roleId); } var treeList = new List <TreeViewModel>(); foreach (SysModule item in moduledata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = moduledata.Count(t => t.ParentId == item.Id) == 0 ? false : true; tree.id = item.Id; tree.text = item.FullName; tree.value = item.EnCode; tree.parentId = item.ParentId; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = authorizedata.Count(t => t.ItemId == item.Id); tree.hasChildren = true; tree.img = item.Icon == "" ? "" : item.Icon; treeList.Add(tree); } foreach (SysModuleButton item in buttondata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = buttondata.Count(t => t.ParentId == item.Id) == 0 ? false : true; tree.id = item.Id; tree.text = item.FullName; tree.value = item.EnCode; tree.parentId = item.ParentId == "0" ? item.ModuleId : item.ParentId; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = authorizedata.Count(t => t.ItemId == item.Id); tree.hasChildren = hasChildren; tree.img = item.Icon == "" ? "" : item.Icon; treeList.Add(tree); } return(Content(treeList.TreeViewJson())); }
public ActionResult GetCloneButtonTreeJson() { var moduledata = SysModuleService.GetList(); var buttondata = ModuleButtonService.GetList(); var treeList = new List <TreeViewModel>(); foreach (var item in moduledata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = moduledata.Count(t => t.ParentId == item.Id) == 0 ? false : true; tree.id = item.Id; tree.text = item.FullName; tree.value = item.EnCode; tree.parentId = item.ParentId; tree.isexpand = true; tree.complete = true; tree.hasChildren = true; treeList.Add(tree); } foreach (SysModuleButton item in buttondata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = buttondata.Count(t => t.ParentId == item.Id) == 0 ? false : true; tree.id = item.Id; tree.text = item.FullName; tree.value = item.EnCode; if (item.ParentId == "0") { tree.parentId = item.ModuleId; } else { tree.parentId = item.ParentId; } tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.hasChildren = hasChildren; if (item.Icon != "") { tree.img = item.Icon; } treeList.Add(tree); } return(Content(treeList.TreeViewJson())); }