public ActionResult ModuleButtonTreeJson(string roleId) { var existModuleButton = permissionBLL.GetModuleButtonList(roleId).ToList(); string userId = OperatorProvider.Provider.Current().UserId; var moduleData = moduleBll.GetModuleList(userId).ToList(); var moduleButtonData = moduleButtonBll.GetListByUserId(userId).ToList(); var treeList = new List <TreeEntity>(); foreach (ModuleEntity item in moduleData) { if (item.IsMenu == true) { bool hasChildren = moduleButtonData.Count(t => t.ModuleId == item.Id) != 0; if (hasChildren == false) { continue; } } TreeEntity tree = new TreeEntity(); tree.id = item.Id; tree.text = item.FullName; tree.value = item.Id; tree.checkstate = existModuleButton.Count(t => t.ItemId == item.Id); tree.showcheck = true; tree.isexpand = true; tree.complete = true; tree.hasChildren = true; tree.parentId = item.ParentId; tree.img = item.Icon; treeList.Add(tree); } foreach (ModuleButtonEntity item in moduleButtonData) { TreeEntity tree = new TreeEntity(); bool hasChildren = moduleButtonData.Count(t => t.ParentId == item.Id) != 0; tree.id = item.Id; tree.text = item.FullName; tree.value = item.Id; if (item.ParentId == "0") { tree.parentId = item.ModuleId; } else { tree.parentId = item.ParentId; } tree.checkstate = existModuleButton.Count(t => t.ItemId == item.Id); tree.showcheck = true; tree.isexpand = true; tree.complete = true; tree.img = "fa fa-wrench " + item.ModuleId; tree.hasChildren = hasChildren; treeList.Add(tree); } return(Content(treeList.TreeToJson())); }
public ActionResult ModuleButtonTreeJson(string roleId) { var existModuleButton = permissionBLL.GetModuleButtonList(roleId); var moduleData = authorizeBLL.GetModuleList(SystemInfo.CurrentUserId); var moduleButtonData = authorizeBLL.GetModuleButtonList(SystemInfo.CurrentUserId); var treeList = new List <TreeEntity>(); foreach (ModuleEntity item in moduleData) { //if (item.IsMenu == 1) //{ // bool hasChildren = moduleButtonData.Count(t => t.ModuleId == item.ModuleId) == 0 ? false : true; // if (hasChildren == false) // { // continue; // } //} TreeEntity tree = new TreeEntity(); tree.id = item.ModuleId; tree.text = item.FullName; tree.value = item.ModuleId; tree.checkstate = existModuleButton.Count(t => t.ItemId == item.ModuleId); tree.showcheck = true; tree.isexpand = true; tree.complete = true; tree.hasChildren = true; tree.parentId = item.ParentId; tree.img = item.Icon; treeList.Add(tree); } foreach (ModuleButtonEntity item in moduleButtonData) { TreeEntity tree = new TreeEntity(); bool hasChildren = moduleButtonData.Count(t => t.ParentId == item.ModuleButtonId) == 0 ? false : true; tree.id = item.ModuleButtonId; tree.text = item.FullName; tree.value = item.ModuleButtonId; if (item.ParentId == "0") { tree.parentId = item.ModuleId; } else { tree.parentId = item.ParentId; } tree.checkstate = existModuleButton.Count(t => t.ItemId == item.ModuleButtonId); tree.showcheck = true; tree.isexpand = true; tree.complete = true; tree.img = "fa fa-wrench " + item.ModuleId; tree.hasChildren = hasChildren; treeList.Add(tree); } return(Content(treeList.TreeToJson())); }
public ActionResult ModuleButtonTreeJson(string userId) { var existModuleButton = permissionBLL.GetModuleButtonList(userId); var moduleData = moduleBLL.GetList(); var moduleButtonData = moduleButtonBLL.GetList(); var treeList = new List <TreeEntity>(); foreach (ModuleEntity item in moduleData) { TreeEntity tree = new TreeEntity(); tree.id = item.F_ModuleId; tree.text = item.F_FullName; tree.value = item.F_ModuleId; tree.checkstate = existModuleButton.Count(t => t.F_ItemId == item.F_ModuleId); tree.showcheck = true; tree.isexpand = true; tree.complete = true; tree.hasChildren = true; tree.parentId = item.F_ParentId; tree.img = item.F_Icon; treeList.Add(tree); } foreach (ModuleButtonEntity item in moduleButtonData) { TreeEntity tree = new TreeEntity(); bool hasChildren = moduleButtonData.Count(t => t.F_ParentId == item.F_ModuleButtonId) == 0 ? false : true; tree.id = item.F_ModuleButtonId; tree.text = item.F_FullName; tree.value = item.F_ModuleButtonId; if (item.F_ParentId == "0") { tree.parentId = item.F_ModuleId; } else { tree.parentId = item.F_ParentId; } tree.checkstate = existModuleButton.Count(t => t.F_ItemId == item.F_ModuleButtonId); tree.showcheck = true; tree.isexpand = true; tree.complete = true; tree.img = "fa fa-wrench " + item.F_ModuleId; tree.hasChildren = hasChildren; treeList.Add(tree); } return(Content(treeList.TreeToJson())); }