public async Task <List <ModuleEntity> > GetMenuList(string roleId) { var data = new List <ModuleEntity>(); if (currentuser.IsSystem) { data = await moduleApp.GetList(); data = data.Where(a => a.F_IsMenu == true && a.F_EnabledMark == true).ToList(); } else { var rolelist = roleId.Split(','); var moduledata = await moduleApp.GetList(); moduledata = moduledata.Where(a => a.F_IsMenu == true && a.F_EnabledMark == true).ToList(); var role = uniwork.IQueryable <RoleEntity>(a => rolelist.Contains(a.F_Id) && a.F_EnabledMark == true).ToList(); if (role.Count == 0) { return(data); } var authorizedata = (await repository.CheckCacheList(cacheKey + "list")).Where(t => rolelist.Contains(t.F_ObjectId) && t.F_ItemType == 1).GroupBy(p => p.F_Id).Select(q => q.First()).ToList(); foreach (var item in authorizedata) { ModuleEntity moduleEntity = moduledata.Find(t => t.F_Id == item.F_ItemId && t.F_IsPublic == false); if (moduleEntity != null && data.Find(a => a.F_Id == moduleEntity.F_Id) == null) { data.Add(moduleEntity); } } data.AddRange(moduledata.Where(a => a.F_IsPublic == true)); } return(data.OrderBy(t => t.F_SortCode).ToList()); }
public ActionResult GetTreeSelectJson() { var data = _moduleService.GetList(); var treeList = new List <TreeSelectModel>(); foreach (ModuleBaseEntity 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())); }
public async Task <LogEntity> CreateLog(string className, DbLogType type) { try { var moduleitem = (await moduleservice.GetList()).Where(a => a.F_IsExpand == false && a.F_EnCode == className.Substring(0, className.Length - 10)).FirstOrDefault(); if (moduleitem == null) { throw new Exception(); } var module = (await moduleservice.GetList()).Where(a => a.F_Id == moduleitem.F_ParentId).FirstOrDefault(); return(new LogEntity(await CreateModule(module), moduleitem == null ? "" : moduleitem.F_FullName, type.ToString())); } catch (Exception) { return(new LogEntity(className, "", type.ToString())); } }
public ActionResult GetPermissionTree(string roleId) { var moduledata = _moduleService.GetList(); var buttondata = _moduleButtonService.GetList(); var authorizedata = new List <RoleAuthorizeBaseEntity>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = _roleAuthorizeService.GetList(roleId); } var treeList = new List <TreeViewModel>(); foreach (ModuleBaseEntity 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 (ModuleButtonBaseEntity 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 = _moduleService.GetList(); var buttondata = _moduleButtonService.GetList(); var treeList = new List <TreeViewModel>(); foreach (ModuleBaseEntity 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 (ModuleButtonBaseEntity 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 ModuleListModel List() { return(_service.GetList()); }
public async Task SubmitForm(RoleEntity roleEntity, string[] permissionIds, string[] permissionfieldsIds, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { roleEntity.F_Id = keyValue; } else { roleEntity.F_DeleteMark = false; roleEntity.F_AllowEdit = false; roleEntity.F_AllowDelete = false; roleEntity.Create(); } var moduledata = await moduleApp.GetList(); var buttondata = await moduleButtonApp.GetList(); var fieldsdata = await moduleFieldsApp.GetList(); List <RoleAuthorizeEntity> roleAuthorizeEntitys = new List <RoleAuthorizeEntity>(); foreach (var itemId in permissionIds) { RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity(); roleAuthorizeEntity.F_Id = Utils.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; roleAuthorizeEntitys.Add(roleAuthorizeEntity); } if (buttondata.Find(t => t.F_Id == itemId) != null) { roleAuthorizeEntity.F_ItemType = 2; roleAuthorizeEntitys.Add(roleAuthorizeEntity); } } foreach (var itemId in permissionfieldsIds) { RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity(); roleAuthorizeEntity.F_Id = Utils.GuId(); roleAuthorizeEntity.F_ObjectType = 1; roleAuthorizeEntity.F_ObjectId = roleEntity.F_Id; roleAuthorizeEntity.F_ItemId = itemId; if (fieldsdata.Find(t => t.F_Id == itemId) != null) { roleAuthorizeEntity.F_ItemType = 3; roleAuthorizeEntitys.Add(roleAuthorizeEntity); } } uniwork.BeginTrans(); if (!string.IsNullOrEmpty(keyValue)) { await repository.Update(roleEntity); } else { roleEntity.F_Category = 1; await repository.Insert(roleEntity); } await uniwork.Delete <RoleAuthorizeEntity>(t => t.F_ObjectId == roleEntity.F_Id); await uniwork.Insert(roleAuthorizeEntitys); uniwork.Commit(); await CacheHelper.Remove(cacheKey + keyValue); await CacheHelper.Remove(cacheKey + "list"); await CacheHelper.Remove(authorizecacheKey + "list"); await CacheHelper.Remove(authorizecacheKey + "authorize_list"); await CacheHelper.Remove(initcacheKey + "modulebutton_list"); await CacheHelper.Remove(initcacheKey + "modulefields_list"); await CacheHelper.Remove(initcacheKey + "list"); }