private static void SetupDashboard() { // Atoms DashboardRoutes.Routes.AddRazorPage("/jobs/atoms", x => new AtomsPage()); DashboardRoutes.Routes.AddClientBatchCommand("/jobs/atoms/delete", (client, jobId) => client.Delete(jobId)); DashboardRoutes.Routes.AddRazorPage("/jobs/atoms/(?<JobId>.+)", x => new AtomDetailsPage(x.Groups["JobId"].Value)); JobHistoryRenderer.AddBackgroundStateColor(AtomCreatingState.StateName, "#e0f7fa"); JobHistoryRenderer.AddForegroundStateColor(AtomCreatingState.StateName, "#00acc1"); JobHistoryRenderer.AddBackgroundStateColor(SubAtomCreatedState.StateName, "#e0f7fa"); JobHistoryRenderer.AddForegroundStateColor(SubAtomCreatedState.StateName, "#0097a7"); JobHistoryRenderer.AddBackgroundStateColor(AtomCreatedState.StateName, "#e0f7fa"); JobHistoryRenderer.AddForegroundStateColor(AtomCreatedState.StateName, "#00838f"); JobHistoryRenderer.AddBackgroundStateColor(AtomRunningState.StateName, "#fff3e0"); JobHistoryRenderer.AddForegroundStateColor(AtomRunningState.StateName, "#ef6c00"); JobHistoryRenderer.Register(SubAtomCreatedState.StateName, AtomJobHistoryRenderer.AtomRender); JobHistoryRenderer.Register(AtomCreatingState.StateName, JobHistoryRenderer.NullRenderer); JobHistoryRenderer.Register(AtomCreatedState.StateName, AtomJobHistoryRenderer.AtomRender); JobHistoryRenderer.Register(AtomRunningState.StateName, AtomJobHistoryRenderer.AtomRender); JobsSidebarMenu.Items.Add(AtomJobSidebar.RenderMenu); // Triggers JobHistoryRenderer.AddBackgroundStateColor(TriggerWaitingState.StateName, "#e6f7ff"); JobHistoryRenderer.AddForegroundStateColor(TriggerWaitingState.StateName, "#e91e63"); JobHistoryRenderer.Register(TriggerWaitingState.StateName, JobHistoryRenderer.NullRenderer); DashboardRoutes.Routes.AddRazorPage("/jobs/triggers", x => new TriggersPage()); JobsSidebarMenu.Items.Add(TriggerJobSidebar.RenderMenu); }
/// <summary> /// Configures Hangfire to use Console. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="options">Options for console</param> public static IGlobalConfiguration UseConsole(this IGlobalConfiguration configuration, ConsoleOptions options = null) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } options = options ?? new ConsoleOptions(); options.Validate(nameof(options)); // register server filter for jobs GlobalJobFilters.Filters.Add(new ConsoleServerFilter(options)); // replace renderer for Processing state JobHistoryRenderer.Register(ProcessingState.StateName, new ProcessingStateRenderer(options).Render); // register dispatcher to serve console updates DashboardRoutes.Routes.Add("/console/([0-9a-f]{11}.+)", new ConsoleDispatcher(options)); // register additional dispatchers for CSS and JS var assembly = typeof(ConsoleRenderer).GetTypeInfo().Assembly; DashboardRoutes.Routes.Append("/js[0-9]{3}", new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.resize.min.js")); DashboardRoutes.Routes.Append("/js[0-9]{3}", new DynamicJsDispatcher(options)); DashboardRoutes.Routes.Append("/js[0-9]{3}", new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.script.js")); DashboardRoutes.Routes.Append("/css[0-9]{3}", new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.style.css")); DashboardRoutes.Routes.Append("/css[0-9]{3}", new DynamicCssDispatcher(options)); return(configuration); }
/// <summary> /// Configures Hangfire to use Console. /// </summary> /// <param name="configuration">Global configuration</param> public static IGlobalConfiguration UseStackTrace(this IGlobalConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } JobHistoryRenderer.Register(FailedState.StateName, new FailedStateRenderer().Render); return(configuration); }
/// <summary> /// Configures Hangfire to use Console. /// </summary> /// <param name="configuration">Global configuration</param> /// <param name="options">Options for console</param> public static IGlobalConfiguration UseConsole(this IGlobalConfiguration configuration, ConsoleOptions options = null) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } options = options ?? new ConsoleOptions(); options.Validate(nameof(options)); if (DashboardRoutes.Routes.Contains("/console/([0-9a-f]{11}.+)")) { throw new InvalidOperationException("Console is already initialized"); } // register server filter for jobs GlobalJobFilters.Filters.Add(new ConsoleServerFilter(options)); // register apply state filter for jobs // (context may be altered by other state filters, so make it the very last filter in chain to use final context values) GlobalJobFilters.Filters.Add(new ConsoleApplyStateFilter(options), int.MaxValue); // replace renderer for Processing state JobHistoryRenderer.Register(ProcessingState.StateName, new ProcessingStateRenderer(options).Render); // register dispatchers to serve console data DashboardRoutes.Routes.Add("/console/progress", new JobProgressDispatcher(options)); DashboardRoutes.Routes.Add("/console/([0-9a-f]{11}.+)", new ConsoleDispatcher(options)); // register additional dispatchers for CSS and JS var assembly = typeof(ConsoleRenderer).GetTypeInfo().Assembly; var jsPath = DashboardRoutes.Routes.Contains("/js[0-9]+") ? "/js[0-9]+" : "/js[0-9]{3}"; DashboardRoutes.Routes.Append(jsPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.resize.min.js")); DashboardRoutes.Routes.Append(jsPath, new DynamicJsDispatcher(options)); DashboardRoutes.Routes.Append(jsPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.script.js")); var cssPath = DashboardRoutes.Routes.Contains("/css[0-9]+") ? "/css[0-9]+" : "/css[0-9]{3}"; DashboardRoutes.Routes.Append(cssPath, new EmbeddedResourceDispatcher(assembly, "Hangfire.Console.Resources.style.css")); DashboardRoutes.Routes.Append(cssPath, new DynamicCssDispatcher(options)); return(configuration); }
public static IGlobalConfiguration UseJobsLogger(this IGlobalConfiguration configuration, JobsLoggerOptions options = null) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } options = options ?? new JobsLoggerOptions(); //Add Filter Job to register logs during execution GlobalJobFilters.Filters.Add(new JobsLoggerFilter(options)); //Add Page to see logs DashboardRoutes.Routes.AddRazorPage(Dashboard.Pages.LoggerPage.PageRoute, x => new Dashboard.Pages.Html.Logging()); JobHistoryRenderer.Register(EnqueuedState.StateName, new EnqueuedStateRenderer().Render); return(configuration); }
public static IGlobalConfiguration UseObjectRecognitionConsole(this IGlobalConfiguration configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } var fi = typeof(JobHistoryRenderer).GetField("Renderers", BindingFlags.NonPublic | BindingFlags.Static); if (fi != null) { var val = fi.GetValue(null) as IDictionary <string, Func <HtmlHelper, IDictionary <string, string>, NonEscapedString> >; var originalRenderer = val.ContainsKey(ProcessingState.StateName) ? val[ProcessingState.StateName] : JobHistoryRenderer.DefaultRenderer; // Chain renderers JobHistoryRenderer.Register(ProcessingState.StateName, new ProcessingStateRenderer(originalRenderer).Render); } return(configuration); }