public ActionResult GetSubOfMenu(string siteName) { var siteMap = new XmlSiteMap(); if (HttpContext.Cache["SiteMap"] == null) { siteMap.LoadFrom("~/Mvc.sitemap"); HttpContext.Cache["SiteMap"] = siteMap; } else if (HttpContext.Cache["ChangeLanguage"] != null && HttpContext.Cache["ChangeLanguage"].ToString() == bool.TrueString) { siteMap.LoadFrom("~/Mvc.sitemap"); HttpContext.Cache["SiteMap"] = siteMap; HttpContext.Cache["ChangeLanguage"] = false; } else { siteMap = (HRM.Presentation.UI.Controls.Menu.XmlSiteMap)HttpContext.Cache["SiteMap"]; } var listMenu = siteMap.RootNode.ChildNodes.Where(w => w.ModuleName == siteName).FirstOrDefault(); if (listMenu == null) { return(null); } return(Json(listMenu.ChildNodes)); }
private List <Entities.sys_category> GetCategories() { List <Entities.sys_category> list = new List <Entities.sys_category>(); var xmlSiteMap = new XmlSiteMap(); xmlSiteMap.LoadFrom(Path.Combine(_webHostEnvironment.ContentRootPath, "sitemap.xml")); xmlSiteMap.SiteMapNodes.ForEach(item => { list.Add(new Entities.sys_category() { id = CombGuid.NewGuidAsString(), name = item.Name, route_template = item.RouteTemplate ?? "", code = item.Code, father_code = item.FatherCode, uid = item.UID, target = item.Target ?? "", is_menu = item.IsMenu == "1" ? true : false, sort = item.Sort, action = item.Action ?? "", controller = item.Controller ?? "", icon_class = item.IconClass ?? "", route_name = item.RouteName ?? "" }); }); return(list); }
/// <summary> /// 接口初始化 /// </summary> public void Install() { var xmlSiteMap = new XmlSiteMap(); xmlSiteMap.LoadFrom(Path.Combine(_environment.ContentRootPath, "sitemap.xml")); List <Entities.Sys_Category> sysApis = new List <Entities.Sys_Category>(); xmlSiteMap.SiteMapNodes.ForEach(item => { sysApis.Add(new Entities.Sys_Category() { Id = CombGuid.NewGuid(), Name = item.Name, RouteTemplate = item.RouteTemplate ?? "", Code = item.Code, FatherCode = item.FatherCode, UID = item.UID, Target = item.Target ?? "", IsMenu = item.IsMenu ?? "", Sort = item.Sort, Action = item.Action ?? "", Controller = item.Controller ?? "", IconClass = item.IconClass ?? "", RouteName = item.RouteName ?? "" }); }); _sysCategoryService.Init(sysApis); _settingService.Init(); }
/// <summary> /// 接口初始化 /// </summary> public void Install() { var xmlSiteMap = new XmlSiteMap(); xmlSiteMap.LoadFrom(Path.Combine(_environment.ContentRootPath, "sitemap.xml")); List <Entities.sys_category> sysApis = new List <Entities.sys_category>(); xmlSiteMap.SiteMapNodes.ForEach(item => { sysApis.Add(new Entities.sys_category() { id = CombGuid.NewGuidAsString(), name = item.Name, route_template = item.RouteTemplate ?? "", code = item.Code, father_code = item.FatherCode, uid = item.UID, target = item.Target ?? "", is_menu = item.IsMenu == "1" ? true : false, sort = item.Sort, action = item.Action ?? "", controller = item.Controller ?? "", icon_class = item.IconClass ?? "", route_name = item.RouteName ?? "" }); }); _sysCategoryService.Init(sysApis); _settingService.Init(); }
/// <summary> /// Инициализирует SiteMap и добавляет его в коллекцию карт сайта /// </summary> /// <param name="siteMapPath">Путь до карты сайта(меню)</param> /// <param name="needSortMenuItems">Нужно ли отсортировать элементы меню</param> public static void ConfigureSiteMap(string siteMapPath, bool needSortMenuItems = true) { var map = new XmlSiteMap(); map.LoadFrom(siteMapPath); ConfigureSiteMap(map, needSortMenuItems); }
private TreeNode <MenuItem> PrepareAdminMenu() { XmlSiteMap siteMap = new XmlSiteMap(this._cache("static")); siteMap.LoadFrom(_webHelper.MapPath("~/Administrator/sitemap.config")); var rootNode = ConvertSitemapNodeToMenuItemNode(siteMap.RootNode); _menuPublisher.Value.RegisterMenus(rootNode, "admin"); // hide based on permissions rootNode.TraverseTree(x => { if (!x.IsRoot) { if (!MenuItemAccessPermitted(x.Value)) { x.Value.Visible = false; } } }); // hide dropdown nodes when no child is visible rootNode.TraverseTree(x => { if (!x.IsRoot) { var item = x.Value; if (!item.IsGroupHeader && !item.HasRoute()) { if (!x.Children.Any(child => child.Value.Visible)) { item.Visible = false; } } } }); return(rootNode); }
private TreeNode<MenuItem> PrepareAdminMenu() { XmlSiteMap siteMap = new XmlSiteMap(); siteMap.LoadFrom("~/Administration/sitemap.config"); var rootNode = ConvertSitemapNodeToMenuItemNode(siteMap.RootNode); _menuPublisher.Value.RegisterMenus(rootNode, "admin"); // hide based on permissions rootNode.TraverseTree(x => { if (!x.IsRoot) { if (!MenuItemAccessPermitted(x.Value)) { x.Value.Visible = false; } } }); // hide dropdown nodes when no child is visible rootNode.TraverseTree(x => { if (!x.IsRoot) { var item = x.Value; if (!item.IsGroupHeader && !item.HasRoute()) { if (!x.Children.Any(child => child.Value.Visible)) { item.Visible = false; } } } }); return rootNode; }
private TreeNode<MenuItem> PrepareAdminMenu() { XmlSiteMap siteMap = new XmlSiteMap(); siteMap.LoadFrom("~/Administration/sitemap.config"); var rootNode = ConvertSitemapNodeToMenuItemNode(siteMap.RootNode); _menuPublisher.Value.RegisterMenus(rootNode, "admin"); //TreeNode<MenuItem> pluginNode = null; //// "collect" menus from plugins //var providers = new List<IMenuProvider>(); //var providerTypes = _typeFinder.FindClassesOfType<IMenuProvider>(ignoreInactivePlugins: true); //foreach (var type in providerTypes) //{ // try // { // var provider = Activator.CreateInstance(type) as IMenuProvider; // if (provider.MenuName.IsCaseInsensitiveEqual("admin")) // { // providers.Add(provider); // } // } // catch { } //} //if (providers.Any()) //{ // pluginNode = rootNode.Children.FirstOrDefault(x => x.Value.Id == "plugins"); // providers.Each(x => x.BuildMenu(pluginNode)); //} // hide based on permissions rootNode.TraverseTree(x => { if (!x.IsRoot) { if (!MenuItemAccessPermitted(x.Value)) { x.Value.Visible = false; } } }); // hide dropdown nodes when no child is visible rootNode.TraverseTree(x => { if (!x.IsRoot) { var item = x.Value; if (!item.IsGroupHeader && !item.HasRoute()) { if (!x.Children.Any(child => child.Value.Visible)) { item.Visible = false; } } } }); return rootNode; }
private TreeNode <MenuItem> PrepareAdminMenu() { XmlSiteMap siteMap = new XmlSiteMap(); siteMap.LoadFrom("~/Administration/sitemap.config"); var rootNode = ConvertSitemapNodeToMenuItemNode(siteMap.RootNode); _menuPublisher.Value.RegisterMenus(rootNode, "admin"); //TreeNode<MenuItem> pluginNode = null; //// "collect" menus from plugins //var providers = new List<IMenuProvider>(); //var providerTypes = _typeFinder.FindClassesOfType<IMenuProvider>(ignoreInactivePlugins: true); //foreach (var type in providerTypes) //{ // try // { // var provider = Activator.CreateInstance(type) as IMenuProvider; // if (provider.MenuName.IsCaseInsensitiveEqual("admin")) // { // providers.Add(provider); // } // } // catch { } //} //if (providers.Any()) //{ // pluginNode = rootNode.Children.FirstOrDefault(x => x.Value.Id == "plugins"); // providers.Each(x => x.BuildMenu(pluginNode)); //} // hide based on permissions rootNode.TraverseTree(x => { if (!x.IsRoot) { if (!MenuItemAccessPermitted(x.Value)) { x.Value.Visible = false; } } }); // hide dropdown nodes when no child is visible rootNode.TraverseTree(x => { if (!x.IsRoot) { var item = x.Value; if (!item.IsGroupHeader && !item.HasRoute()) { if (!x.Children.Any(child => child.Value.Visible)) { item.Visible = false; } } } }); return(rootNode); }