public List <ModuleEntity> GetMenuList(string roleId) { var data = new List <ModuleEntity>(); if (OperatorProvider.Provider.GetCurrent().IsSystem) { data = moduleApp.GetList(); } else { var moduledata = moduleApp.GetList(); List <RoleAuthorizeEntity> authorizedata = new List <RoleAuthorizeEntity>(); string[] FRoleArray = roleId.Split(','); if (FRoleArray.Length > 0) { foreach (string FRoleId in FRoleArray) { if (!string.IsNullOrEmpty(FRoleId)) { authorizedata.AddRange(service.IQueryable(t => t.FObjectId == FRoleId && t.FItemType == 1).ToList()); } } } foreach (var item in authorizedata) { ModuleEntity moduleEntity = moduledata.Find(t => t.FId == item.FItemId); if (moduleEntity != null) { data.Add(moduleEntity); } } } return(data.Distinct().OrderBy(t => t.FSortCode).ToList()); }
public ActionResult GetPermissionTree(string roleId) { List <ModuleEntity> moduledata = new List <ModuleEntity>(); List <ModuleButtonEntity> buttondata = new List <ModuleButtonEntity>(); if (OperatorProvider.Provider.GetCurrent().IsSystem) { moduledata = moduleApp.GetList(); buttondata = moduleButtonApp.GetList(); } else { var current_roleId = OperatorProvider.Provider.GetCurrent().RoleId;//当前登录人角色id moduledata = moduleApp.GetList(current_roleId); buttondata = moduleButtonApp.GetListByRole(current_roleId); } var authorizedata = new List <RoleAuthorizeEntity>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = roleAuthorizeApp.GetList(roleId); } var treeList = new List <TreeViewModel>(); foreach (ModuleEntity item in moduledata) { int chkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id); 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 (ModuleButtonEntity item in buttondata) { int chkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id); 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 GetPermissionTree(string roleId, CustomerTypeEnum customerType) { var moduledata = customerType != CustomerTypeEnum.Both ? moduleApp.GetList(customerType) : OperatorProvider.Provider.GetCurrent().IsSystem ? moduleApp.GetList(CustomerTypeEnum.System) : OperatorProvider.Provider.GetCurrent().IsPlatform ? moduleApp.GetList(CustomerTypeEnum.Platform) : moduleApp.GetList(CustomerTypeEnum.Organization); var buttondata = moduleButtonApp.GetList(); var authorizedata = new List <RoleAuthorizeEntity>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = roleAuthorizeApp.GetList(roleId); } var defaultauthorizedata = new List <RoleAuthorizeEntity>(); if (!string.IsNullOrEmpty(OperatorProvider.Provider.GetCurrent().CompanyId)) { var role = roleApp.GetDefaultCompanyRole(OperatorProvider.Provider.GetCurrent().CompanyId); if (role != null) { defaultauthorizedata = roleAuthorizeApp.GetList(role.F_Id); } } var treeList = (from item in moduledata where defaultauthorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 || OperatorProvider.Provider.GetCurrent().IsSystem || customerType != CustomerTypeEnum.Both select new TreeViewModel { id = item.F_Id, text = item.F_FullName, value = item.F_EnCode, parentId = item.F_ParentId, isexpand = true, complete = true, showcheck = true, checkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id), hasChildren = true, img = item.F_Icon == "" ? "" : item.F_Icon }).ToList(); treeList.AddRange(from item in buttondata where defaultauthorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 || OperatorProvider.Provider.GetCurrent().IsSystem || customerType != CustomerTypeEnum.Both select new TreeViewModel { id = item.F_Id, text = item.F_FullName, value = item.F_EnCode, parentId = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId, isexpand = true, complete = true, showcheck = true, checkstate = authorizedata.Count(t => t.F_ItemId == item.F_Id), hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) != 0, img = item.F_Icon == "" ? "" : item.F_Icon }); return(Content(treeList.TreeViewJson())); }
public ActionResult GetTreeSelectJson() { var data = moduleApp.GetList(); var treeList = new List<TreeSelectModel>(); foreach (ModuleEntity 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 ActionResult GetPermissionTree(string roleId) { var currentUser = OperatorProvider.Provider.GetCurrent(); var moduledata = moduleApp.GetList(); if (!currentUser.IsSystem) { try { moduledata = moduledata.Where(d => d.F_IsAdminvisible == null || !(bool)d.F_IsAdminvisible).ToList(); } catch { } } var buttondata = moduleButtonApp.GetList(); var authorizedata = new List <RoleAuthorizeEntity>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = roleAuthorizeApp.GetList(roleId); } var treeList = new List <TreeViewModel>(); foreach (ModuleEntity 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 (ModuleButtonEntity 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 GetPermissionTree(string roleId) { var moduledata = moduleApp.GetList(); var buttondata = moduleButtonApp.GetList(); var authorizedata = new List <RoleAuthorizeEntity>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = roleAuthorizeApp.GetList(roleId); } var treeList = new List <TreeGridModel>(); foreach (ModuleEntity item in moduledata) { TreeGridModel tree = new TreeGridModel(); tree.id = item.F_Id; tree.title = item.F_FullName; tree.parentId = item.F_ParentId; tree.checkArr = authorizedata.Count(t => t.F_ItemId == item.F_Id) > 0?"1":"0"; treeList.Add(tree); } foreach (ModuleButtonEntity item in buttondata) { TreeGridModel tree = new TreeGridModel(); tree.id = item.F_Id; tree.title = item.F_FullName; tree.parentId = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId; tree.checkArr = authorizedata.Count(t => t.F_ItemId == item.F_Id) > 0 ?"1":"0"; treeList.Add(tree); } return(ResultDTree(treeList.TreeList())); }
public ActionResult GetCloneButtonTreeJson() { var moduledata = moduleApp.GetList(); var buttondata = moduleButtonApp.GetList(); var treeList = new List <TreeGridModel>(); foreach (ModuleEntity item in moduledata) { TreeGridModel treeModel = new TreeGridModel(); treeModel.id = item.F_Id; treeModel.title = item.F_FullName; treeModel.parentId = item.F_ParentId; treeModel.checkArr = "0"; treeModel.disabled = true; //treeModel.self = item; treeList.Add(treeModel); } foreach (ModuleButtonEntity item in buttondata) { TreeGridModel treeModel = new TreeGridModel(); treeModel.id = item.F_Id; treeModel.title = item.F_FullName; treeModel.parentId = item.F_ParentId == "0" ? item.F_ModuleId : item.F_ParentId; treeModel.checkArr = "0"; //treeModel.self = item; treeList.Add(treeModel); } return(ResultDTree(treeList.TreeList())); }
public void SubmitForm(RoleEntity roleEntity, string[] permissionIds, string keyValue) { if (!string.IsNullOrEmpty(keyValue)) { roleEntity.F_Id = keyValue; } else { roleEntity.F_Id = Common.GuId(); } var moduledata = moduleApp.GetList(); var buttondata = moduleButtonApp.GetList(); List <RoleAuthorizeEntity> roleAuthorizeEntitys = new List <RoleAuthorizeEntity>(); foreach (var itemId in permissionIds) { RoleAuthorizeEntity roleAuthorizeEntity = new RoleAuthorizeEntity(); 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; } roleAuthorizeEntitys.Add(roleAuthorizeEntity); } service.SubmitForm(roleEntity, roleAuthorizeEntitys, keyValue); }
public ActionResult GetPermissionTree(string roleId, string type = "role") { List <Sys_Module> moduledata = moduleApp.GetList(); List <Sys_ModuleButton> buttondata = moduleButtonApp.GetList(); if (type == "role") { moduledata = moduledata.Where(a => a.F_Type == 1 || a.F_Type == 0).ToList(); buttondata = buttondata.Where(a => a.F_Type == 1 || a.F_Type == 0).ToList(); } else { moduledata = moduledata.Where(a => a.F_Type == 2 || a.F_Type == 0).ToList(); buttondata = buttondata.Where(a => a.F_Type == 2 || a.F_Type == 0).ToList(); } var authorizedata = new List <Sys_RoleAuthorize>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = roleAuthorizeApp.GetList(roleId); } var treeList = new List <TreeViewModel>(); foreach (Sys_Module item in moduledata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = moduledata.Count(t => t.F_ParentId == item.F_Id) != 0; tree.id = item.F_Id; tree.text = item.F_FullName; tree.value = item.F_EnCode; tree.parentId = item.F_ParentId; tree.isexpand = false; 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; tree.img = ""; treeList.Add(tree); } foreach (Sys_ModuleButton item in buttondata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = buttondata.Count(t => t.F_ParentId == item.F_Id) != 0; 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 GetPermissionTree(string roleId) { string[] FRoleArray = roleId.Split(','); var moduledata = moduleApp.GetList(); var buttondata = moduleButtonApp.GetList(); List <RoleAuthorizeEntity> authorizedata = new List <RoleAuthorizeEntity>(); if (FRoleArray.Length > 0) { foreach (string FRoleId in FRoleArray) { if (!string.IsNullOrEmpty(FRoleId)) { authorizedata.AddRange(roleAuthorizeApp.GetList(FRoleId)); } } } var treeList = new List <TreeViewModel>(); foreach (ModuleEntity item in moduledata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = moduledata.Count(t => t.FParentId == item.FId) == 0 ? false : true; tree.id = item.FId; tree.text = item.FFullName; tree.value = item.FEnCode; tree.parentId = item.FParentId; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = authorizedata.Count(t => t.FItemId == item.FId); tree.hasChildren = true; tree.img = item.FIcon == "" ? "" : item.FIcon; treeList.Add(tree); } foreach (ModuleButtonEntity item in buttondata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = buttondata.Count(t => t.FParentId == item.FId) == 0 ? false : true; tree.id = item.FId; tree.text = item.FFullName; tree.value = item.FEnCode; tree.parentId = item.FParentId == "0" ? item.FModuleId : item.FParentId; tree.isexpand = true; tree.complete = true; tree.showcheck = true; tree.checkstate = authorizedata.Count(t => t.FItemId == item.FId); tree.hasChildren = hasChildren; tree.img = item.FIcon == "" ? "" : item.FIcon; treeList.Add(tree); } return(Content(treeList.TreeViewJson())); }
public List <ModuleEntity> GetMenuList(string roleId) { var data = new List <ModuleEntity>(); if (OperatorProvider.Provider.GetCurrent().IsSystem) { data = moduleApp.GetList(); } else { var moduledata = moduleApp.GetList(); var authorizedata = service.IQueryable(t => t.F_ObjectId == roleId && t.F_ItemType == 1).ToList(); foreach (var item in authorizedata) { ModuleEntity moduleEntity = moduledata.Find(t => t.F_Id == item.F_ItemId); if (moduleEntity != null) { data.Add(moduleEntity); } } } return(data.OrderBy(t => t.F_SortCode).ToList()); }
//[HandlerAjaxOnly] public ActionResult GetCloneButtonTreeJson() { var moduledata = moduleApp.GetList(); var buttondata = moduleButtonApp.GetList(); var treeList = new List <TreeViewModel>(); foreach (ModuleEntity 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 (ModuleButtonEntity 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 GetPermissionTree(string roleId) { var moduledata = moduleApp.GetList(); var buttondata = moduleButtonApp.GetList(); var authorizedata = new List <RoleAuthorizeEntity>(); if (!string.IsNullOrEmpty(roleId)) { authorizedata = roleAuthorizeApp.GetList(roleId); } var treeList = new List <TreeViewModel>(); foreach (ModuleEntity item in moduledata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = moduledata.Count(t => t.F_ParentId == item.IGrowID) == 0 ? false : true; tree.id = item.IGrowID; 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.IGrowID); tree.hasChildren = true; tree.img = item.F_Icon == "" ? "" : item.F_Icon; treeList.Add(tree); } foreach (ModuleButtonEntity item in buttondata) { TreeViewModel tree = new TreeViewModel(); bool hasChildren = buttondata.Count(t => t.F_ParentId == item.IGrowID) == 0 ? false : true; tree.id = item.IGrowID; 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.IGrowID); tree.hasChildren = hasChildren; tree.img = item.F_Icon == "" ? "" : item.F_Icon; treeList.Add(tree); } return(Content(treeList.TreeViewJson())); }
public string GetTreeJson(string keyword) { ModuleApp moduleApp = new ModuleApp(); var data = moduleApp.GetList(); data = data.TreeWhere(t => t.F_IsMenu.GetValueOrDefault() == true && t.F_FullName.Contains(keyword)); List <Tuple <string> > lstClass = new List <Tuple <string> >(); foreach (ModuleEntity item in data) { if (item.F_UrlAddress != null) { lstClass.Add(new Tuple <string>(item.F_FullName)); } } var jsonData = lstClass.ToJson(); return(jsonData); }