private static void CreateManagement() { foreach (var pageInfo in JobsHelper.Pages) { ManagementBasePage.AddCommands(pageInfo.Category); ManagementSidebarMenu.Items.Add(p => new MenuItem(pageInfo.MenuName, p.Url.To($"{ManagementPage.UrlRoute}/{pageInfo.Category}")) { Active = p.RequestPath.StartsWith($"{ManagementPage.UrlRoute}/{pageInfo.Category}") }); DashboardRoutes.Routes.AddRazorPage($"{ManagementPage.UrlRoute}/{pageInfo.Category}", x => new ManagementBasePage(pageInfo.MenuName, pageInfo.Title, pageInfo.Category, pageInfo.Queue)); } //note: have to use new here as the pages are dispatched and created each time. If we use an instance, the page gets duplicated on each call DashboardRoutes.Routes.AddRazorPage(ManagementPage.UrlRoute, x => new ManagementPage()); // can't use the method of Hangfire.Console as it's usage overrides any similar usage here. Thus // we have to add our own endpoint to load it and call it from our code. Actually is a lot less work DashboardRoutes.Routes.Add("/jsm", new EmbeddedResourceDispatcher(Assembly.GetExecutingAssembly(), "Hangfire.Dashboard.Management.Extension.Content.management.js")); NavigationMenu.Items.Add(page => new MenuItem(ManagementPage.Title, page.Url.To(ManagementPage.UrlRoute)) { Active = page.RequestPath.StartsWith(ManagementPage.UrlRoute) }); }
private static void CreateManagement() { var pageSet = new List <string>(); foreach (var pageInfo in JobsHelper.Pages) { ManagementBasePage.AddCommands(pageInfo.MenuName); if (!pageSet.Contains(pageInfo.MenuName)) { pageSet.Add(pageInfo.MenuName); ManagementSidebarMenu.Items.Add(p => new MenuItem(pageInfo.MenuName, p.Url.To($"{ManagementPage.UrlRoute}/{pageInfo.MenuName.ScrubURL()}")) { Active = p.RequestPath.StartsWith($"{ManagementPage.UrlRoute}/{pageInfo.MenuName.ScrubURL()}") }); } DashboardRoutes.Routes.AddRazorPage($"{ManagementPage.UrlRoute}/{pageInfo.MenuName.ScrubURL()}", x => new ManagementBasePage(pageInfo.MenuName)); } //note: have to use new here as the pages are dispatched and created each time. If we use an instance, the page gets duplicated on each call DashboardRoutes.Routes.AddRazorPage(ManagementPage.UrlRoute, x => new ManagementPage()); // can't use the method of Hangfire.Console as it's usage overrides any similar usage here. Thus // we have to add our own endpoint to load it and call it from our code. Actually is a lot less work DashboardRoutes.Routes.Add($"{ManagementPage.UrlRoute}/jsmcss", new CombinedResourceDispatcher( "text/css", typeof(GlobalConfigurationExtension).GetTypeInfo().Assembly, $"{typeof(GlobalConfigurationExtension).Namespace}.Content", new[] { "Libraries.dateTimePicker.bootstrap-datetimepicker.min.css", "Libraries.inputmask.inputmask.min.css", "management.css" } ) ); DashboardRoutes.Routes.Add($"{ManagementPage.UrlRoute}/jsm", new CombinedResourceDispatcher( "application/javascript", typeof(GlobalConfigurationExtension).GetTypeInfo().Assembly, $"{typeof(GlobalConfigurationExtension).Namespace}.Content", new[] { "Libraries.dateTimePicker.bootstrap-datetimepicker.min.js", "Libraries.inputmask.jquery.inputmask.bundle.min.js", "management.js", "cron.js" } ) ); NavigationMenu.Items.Add(page => new MenuItem(ManagementPage.Title, page.Url.To(ManagementPage.UrlRoute)) { Active = page.RequestPath.StartsWith(ManagementPage.UrlRoute) }); }
private static void InitJobs(Assembly assembly) { var jobs = JobsHelper.GetAllJobs(assembly); var methodMeta = jobs.Item1; var pages = jobs.Item2; pages.ForEach(x => JobCategories.Add(x)); methodMeta.ForEach(x => Jobs.Add(x)); Jobs.CollectionChanged += (sender, e) => { if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Add) { foreach (JobMetadata v in e.NewItems) { //Add item to manager //ManagementBasePage.Jobs.Add(v); ManagementBasePage.AddCommands(v); } } }; }