Пример #1
0
        public static void UseHangfire(
            [NotNull] this IAppBuilder app,
            [NotNull] Action<IBootstrapperConfiguration> configurationAction)
        {
            if (app == null) throw new ArgumentNullException("app");
            if (configurationAction == null) throw new ArgumentNullException("configurationAction");

            var configuration = new BootstrapperConfiguration();
            configurationAction(configuration);

            if (configuration.Activator != null)
            {
                JobActivator.Current = configuration.Activator;
            }

            if (configuration.Storage != null)
            {
                JobStorage.Current = configuration.Storage;
            }

            foreach (var filter in configuration.Filters)
            {
                GlobalJobFilters.Filters.Add(filter);
            }

            foreach (var server in configuration.Servers)
            {
                app.RunHangfireServer(server());
            }

            app.MapHangfireDashboard(configuration.DashboardPath, configuration.AppPath, configuration.AuthorizationFilters);
        }
        /// <summary>
        /// Bootstraps Hangfire components using the given configuration
        /// action and maps Hangfire Dashboard to the app builder pipeline
        /// at the configured path ('/hangfire' by default).
        /// </summary>
        /// <param name="app">The app builder</param>
        /// <param name="configurationAction">Configuration action</param>
        public static void UseHangfire(
            [NotNull] this IAppBuilder app,
            [NotNull] Action<IBootstrapperConfiguration> configurationAction)
        {
            if (app == null) throw new ArgumentNullException("app");
            if (configurationAction == null) throw new ArgumentNullException("configurationAction");

            var configuration = new BootstrapperConfiguration();
            configurationAction(configuration);

            if (configuration.Activator != null)
            {
                JobActivator.Current = configuration.Activator;
            }

            if (configuration.Storage == null)
            {
                throw new InvalidOperationException("Job storage was not configured. Please call either `UseStorage` method or its overloads.");
            }

            JobStorage.Current = configuration.Storage;

            foreach (var filter in configuration.Filters)
            {
                GlobalJobFilters.Filters.Add(filter);
            }

            foreach (var server in configuration.Servers)
            {
                app.RunHangfireServer(server());
            }

            app.MapHangfireDashboard(configuration.DashboardPath, configuration.AuthorizationFilters);
        }
Пример #3
0
        /// <summary>
        /// Bootstraps Hangfire components using the given configuration
        /// action and maps Hangfire Dashboard to the app builder pipeline
        /// at the configured path ('/hangfire' by default).
        /// </summary>
        /// <param name="app">The app builder</param>
        /// <param name="configurationAction">Configuration action</param>
        public static void UseHangfire(
            [NotNull] this IAppBuilder app,
            [NotNull] Action <IBootstrapperConfiguration> configurationAction)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }
            if (configurationAction == null)
            {
                throw new ArgumentNullException("configurationAction");
            }

            var configuration = new BootstrapperConfiguration();

            configurationAction(configuration);

            if (configuration.Activator != null)
            {
                JobActivator.Current = configuration.Activator;
            }

            if (configuration.Storage == null)
            {
                throw new InvalidOperationException("Job storage was not configured. Please call either `UseStorage` method or its overloads.");
            }

            JobStorage.Current = configuration.Storage;

            foreach (var filter in configuration.Filters)
            {
                GlobalJobFilters.Filters.Add(filter);
            }

            foreach (var server in configuration.Servers)
            {
                app.RunHangfireServer(server());
            }

            SignatureConversions.AddConversions(app);
            app.MapHangfireDashboard(configuration.DashboardPath, configuration.AuthorizationFilters);
        }
Пример #4
0
        public static void UseHangfire(
            [NotNull] this IAppBuilder app,
            [NotNull] Action <IBootstrapperConfiguration> configurationAction)
        {
            if (app == null)
            {
                throw new ArgumentNullException("app");
            }
            if (configurationAction == null)
            {
                throw new ArgumentNullException("configurationAction");
            }

            var configuration = new BootstrapperConfiguration();

            configurationAction(configuration);

            if (configuration.Activator != null)
            {
                JobActivator.Current = configuration.Activator;
            }

            if (configuration.Storage != null)
            {
                JobStorage.Current = configuration.Storage;
            }

            foreach (var filter in configuration.Filters)
            {
                GlobalJobFilters.Filters.Add(filter);
            }

            foreach (var server in configuration.Servers)
            {
                app.RunHangfireServer(server());
            }

            app.MapHangfireDashboard(configuration.DashboardPath, configuration.AppPath, configuration.AuthorizationFilters);
        }