protected override void InitVM() { SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList()); SelectedUsersID.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.UserId != null && x.Allowed == true).Select(x => x.UserId.Value).ToList()); SelectedRolesID2.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == false).Select(x => x.RoleId.Value).ToList()); SelectedUsersID2.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.UserId != null && x.Allowed == false).Select(x => x.UserId.Value).ToList()); var data = DC.Set <FrameworkMenu>().ToList(); var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder); var pids = Entity.GetAllChildrenIDs(DC); AllParents = topMenu.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID)).ToList().ToListItems(y => y.PageName, x => x.ID); foreach (var p in AllParents) { Guid temp = Guid.Parse(p.Value); var m = topMenu.Where(x => x.ID == temp).SingleOrDefault(); if (m != null && m.ActionId != null) { p.Text = p.Text + "(" + m.ModuleName + ")"; } } AllModules = DC.Set <FrameworkModule>().GetSelectListItems(LoginUserInfo.DataPrivileges, null, y => y.ModuleName); if (Entity.ModuleId != null) { AllActions = DC.Set <FrameworkAction>().GetSelectListItems(LoginUserInfo.DataPrivileges, x => x.ModuleId == Entity.ModuleId, y => y.ActionName); } }
protected override void InitVM() { SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList()); var data = DC.Set <FrameworkMenu>().ToList(); var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder); var pids = Entity.GetAllChildrenIDs(DC); AllParents = topMenu.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID); var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule; var m = modules.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").ToList(); List <FrameworkModule> toremove = new List <FrameworkModule>(); foreach (var item in m) { var f = modules.Where(x => x.ClassName == item.ClassName && x.Area?.AreaName == item.Area?.AreaName).FirstOrDefault(); if (f?.IgnorePrivillege == true) { toremove.Add(item); } } toremove.ForEach(x => m.Remove(x)); AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName); if (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true) { SelectedModule = modules.Where(x => x.IsApi == false && (x.ClassName == Entity.ClassName || x.FullName == Entity.ClassName)).SelectMany(x => x.Actions).FirstOrDefault().Module.FullName; var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList(); AllActions = mm.ToListItems(y => y.ActionName, y => y.Url); SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList(); } }
protected override void InitVM() { SelectedRolesIDs.AddRange(DC.Set<FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList()); var data = DC.Set<FrameworkMenu>().ToList(); var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x=>x.DisplayOrder); var pids = Entity.GetAllChildrenIDs(DC); AllParents = topMenu.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID); foreach (var p in AllParents) { Guid temp = Guid.Parse(p.Value); var m = topMenu.Where(x => x.ID == temp).SingleOrDefault(); if (m != null && m.ActionId != null) { p.Text = p.Text + "(" + m.ModuleName + ")"; } } var modules = GlobalServices.GetRequiredService<GlobalData>().AllModule; if (ControllerName.Contains("WalkingTec.Mvvm.Mvc.Admin.Controllers")) { var m = DC.Set<FrameworkModule>().Include(x=>x.Area).Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").ToList(); List<FrameworkModule> toremove = new List<FrameworkModule>(); foreach (var item in m) { var f = modules.Where(x => x.ClassName == item.ClassName && x.Area?.AreaName == item.Area?.AreaName).FirstOrDefault(); if (f?.IgnorePrivillege == true) { toremove.Add(item); } } toremove.ForEach(x => m.Remove(x)); AllModules = m.ToListItems(y => y.ModuleName, y=>y.ID); } if (Entity.ModuleId != null) { var m = DC.Set<FrameworkAction>().Include(x=>x.Module.Area).Where(x => x.ModuleId == Entity.ModuleId && x.MethodName != "Index").ToList(); List<FrameworkAction> toremove = new List<FrameworkAction>(); foreach (var item in m) { var f = modules.Where(x => x.ClassName == item.Module.ClassName && x.Area?.AreaName == item.Module.Area?.AreaName).FirstOrDefault(); var a = f?.Actions.Where(x => x.MethodName == item.MethodName).FirstOrDefault(); if (a?.IgnorePrivillege == true) { toremove.Add(item); } } toremove.ForEach(x => m.Remove(x)); AllActions = m.ToListItems(y => y.ActionName, y => y.ID); SelectedActionIDs = DC.Set<FrameworkMenu>().Where(x => x.ModuleId == this.Entity.ModuleId && x.ActionId != null).Select(x => x.ActionId.Value).ToList(); } }
protected override void InitVM() { SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList()); var data = DC.Set <FrameworkMenu>().AsNoTracking().ToList(); var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder); var pids = Entity.GetAllChildrenIDs(DC); AllParents = data.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID); foreach (var p in AllParents) { if (p.Text.StartsWith("MenuKey.")) { p.Text = Localizer[p.Text]; } } var modules = KnifeVirgo.GlobaInfo.AllModule; var toRemove = new List <SimpleModule>(); foreach (var item in modules) { if (item.IgnorePrivillege) { toRemove.Add(item); } } var m = modules.ToList(); toRemove.ForEach(x => m.Remove(x)); AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName); if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true)) { if (string.IsNullOrEmpty(SelectedModule)) { SelectedModule = modules.Where(x => (x.FullName == Entity.ClassName)).FirstOrDefault()?.FullName; } var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList(); AllActions = mm.ToListItems(y => y.ActionName, y => y.Url); if (SelectedActionIDs == null) { SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList(); } } }
protected override void InitVM() { if (!string.IsNullOrEmpty(Entity.ICon)) { var res = Entity.ICon.Split(' '); IconFont = res[0]; IconFontItem = res[1]; } IConSelectItems = !string.IsNullOrEmpty(IconFont) && IconFontsHelper .IconFontDicItems .ContainsKey(IconFont) ? IconFontsHelper .IconFontDicItems[IconFont] .Select(x => new ComboSelectListItem() { Text = x.Text, Value = x.Value, ICon = x.ICon }).ToList() : new List <ComboSelectListItem>(); SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList()); var data = DC.Set <FrameworkMenu>().AsNoTracking().ToList(); var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder); var pids = Entity.GetAllChildrenIDs(DC); AllParents = data.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID); foreach (var p in AllParents) { if (p.Text.StartsWith("MenuKey.")) { if (Localizer[p.Text].ResourceNotFound == true) { p.Text = Core.Program._localizer[p.Text]; } else { p.Text = Localizer[p.Text]; } } } var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule; var toRemove = new List <FrameworkModule>(); foreach (var item in modules) { if (item.IgnorePrivillege) { toRemove.Add(item); } else { if (!item.IsApi) { continue; } if (item.NameSpace == "WalkingTec.Mvvm.Admin.Api") { if (!item.ModuleName.EndsWith($"({Program._localizer["BuildinApi"]})")) { item.ModuleName += $"({Program._localizer["BuildinApi"]})"; } } else if (!item.ModuleName.EndsWith("(api)")) { item.ModuleName += "(api)"; } } } var m = modules.ToList(); toRemove.ForEach(x => m.Remove(x)); AllModules = m.ToListItems(y => y.ModuleName, y => y.FullName); if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true)) { if (string.IsNullOrEmpty(SelectedModule)) { SelectedModule = modules.Where(x => (x.FullName == Entity.ClassName)).FirstOrDefault()?.FullName; } var mm = modules.Where(x => x.FullName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList(); AllActions = mm.ToListItems(y => y.ActionName, y => y.Url); if (SelectedActionIDs == null) { SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList(); } } }
protected override void InitVM() { if (!string.IsNullOrEmpty(Entity.ICon)) { var res = Entity.ICon.Split(' '); IconFont = res[0]; IconFontItem = res[1]; } IConSelectItems = !string.IsNullOrEmpty(IconFont) && IconFontsHelper .IconFontDicItems .ContainsKey(IconFont) ? IconFontsHelper .IconFontDicItems[IconFont] .Select(x => new ComboSelectListItem() { Text = x.Text, Value = x.Value, ICon = x.ICon }).ToList() : new List <ComboSelectListItem>(); SelectedRolesIDs.AddRange(DC.Set <FunctionPrivilege>().Where(x => x.MenuItemId == Entity.ID && x.RoleId != null && x.Allowed == true).Select(x => x.RoleId.Value).ToList()); var data = DC.Set <FrameworkMenu>().ToList(); var topMenu = data.Where(x => x.ParentId == null).ToList().FlatTree(x => x.DisplayOrder); var pids = Entity.GetAllChildrenIDs(DC); AllParents = topMenu.Where(x => x.ID != Entity.ID && !pids.Contains(x.ID) && x.FolderOnly == true).ToList().ToListItems(y => y.PageName, x => x.ID); var modules = GlobalServices.GetRequiredService <GlobalData>().AllModule; var m = modules.Where(x => x.NameSpace != "WalkingTec.Mvvm.Admin.Api").ToList(); List <FrameworkModule> toremove = new List <FrameworkModule>(); foreach (var item in m) { var f = modules.Where(x => x.ClassName == item.ClassName && x.Area?.AreaName == item.Area?.AreaName).FirstOrDefault(); if (f?.IgnorePrivillege == true) { toremove.Add(item); } } toremove.ForEach(x => m.Remove(x)); var m2 = modules.Where(x => x.NameSpace == "WalkingTec.Mvvm.Admin.Api").ToList(); foreach (var item in m2) { if (item.ModuleName.EndsWith("(内置api)") == false) { item.ModuleName += "(内置api)"; } } m.AddRange(m2); AllModules = m.ToListItems(y => y.ModuleName, y => y.ClassName); if (string.IsNullOrEmpty(SelectedModule) == false || (string.IsNullOrEmpty(Entity.Url) == false && Entity.IsInside == true)) { if (string.IsNullOrEmpty(SelectedModule)) { SelectedModule = modules.Where(x => (x.ClassName == Entity.ClassName)).FirstOrDefault()?.ClassName; } var mm = modules.Where(x => x.ClassName == SelectedModule).SelectMany(x => x.Actions).Where(x => x.MethodName != "Index" && x.IgnorePrivillege == false).ToList(); AllActions = mm.ToListItems(y => y.ActionName, y => y.Url); if (SelectedActionIDs == null) { SelectedActionIDs = DC.Set <FrameworkMenu>().Where(x => AllActions.Select(y => y.Value).Contains(x.Url) && x.IsInside == true && x.FolderOnly == false).Select(x => x.Url).ToList(); } } }