コード例 #1
0
 public override void ConfigureHangfireServer(TenantBuilderContext context, BackgroundJobServerOptions options)
 {
 }
コード例 #2
0
 public override void ConfigureHangfire(TenantBuilderContext context, HangfireConfiguration configuration)
 {
 }
コード例 #3
0
 public override void ConfigureAppConfiguration(TenantBuilderContext context, IConfigurationBuilder builder)
 {
 }
コード例 #4
0
 public override void ConfigureHangfireDashboard(TenantBuilderContext context, DashboardOptions options)
 {
 }
 public abstract void ConfigureHangfire(TenantBuilderContext context, HangfireConfiguration configuration);
コード例 #6
0
 public override void ConfigureBackgroundProcesses(TenantBuilderContext context, IServiceCollection services)
 {
     services.AddSingleton <IBackgroundProcess, BackgroundProcess>();
 }
 public abstract void ConfigureHangfireServer(TenantBuilderContext context, BackgroundJobServerOptions options);
 public abstract void ConfigureHangfireDashboard(TenantBuilderContext context, DashboardOptions options);
 public abstract void ConfigureBackgroundProcesses(TenantBuilderContext context, IServiceCollection services);
        public virtual void ConfigureServices(TenantBuilderContext context, IServiceCollection services)
        {
            var hangfireServicesAdded = context.RootServiceProvider.GetService <IGlobalConfiguration>() != null;

            //configuration
            var configuration = new HangfireConfiguration();

            context.Configuration.Bind("Hangfire", configuration);
            ConfigureHangfire(context, configuration);
            services.AddSingleton(configuration);

            //dashboard options
            var dashboardOptions = context.RootServiceProvider.GetService <DashboardOptions>()?.Clone() ?? new DashboardOptions();

            ConfigureHangfireDashboard(context, dashboardOptions);
            services.AddSingleton(dashboardOptions);

            //background processing server
            IBackgroundProcessingServer processingServer = null;

            //Storage
            if (configuration.Enabled)
            {
                var storageDetails = HangfireJobStorage.GetJobStorage(configuration.ConnectionString, options => {
                    options.PrepareSchemaIfNecessary = false;
                    options.EnableHeavyMigrations    = false;
                    options.EnableLongPolling        = configuration.EnableLongPolling;
                    options.SchemaName = configuration.SchemaName;
                });

                JobStorage storage = storageDetails.JobStorage;
                configuration.ExistingConnection = storageDetails.ExistingConnection;

                services.AddSingleton(storage);
                services.AddHangfireServerServices();

                Func <IServiceProvider, Action <IBackgroundProcessingServer> > processingServerSetter = ((sp) => (x) => { processingServer = x; });
                services.AddSingleton(processingServerSetter);
                Func <IServiceProvider, IBackgroundProcessingServer> processingServerAccessor = ((sp) => processingServer);
                services.AddSingleton(processingServerAccessor);

                var backgroundServerOptions = context.RootServiceProvider.GetService <BackgroundJobServerOptions>()?.Clone() ?? new BackgroundJobServerOptions();

                backgroundServerOptions.ServerName     = configuration.ServerName ?? backgroundServerOptions.ServerName;
                backgroundServerOptions.Activator      = new MultiTenantJobActivator(context.RootServiceProvider.GetRequiredService <MultitenantContainer>(), context.TenantId);
                backgroundServerOptions.FilterProvider = context.RootServiceProvider.GetService <IJobFilterProvider>() ?? new JobFilterCollection();

                ConfigureHangfireServer(context, backgroundServerOptions);

                services.AddSingleton(backgroundServerOptions);
            }
            else
            {
                if (hangfireServicesAdded)
                {
                    services.AddSingleton((JobStorage) new NoopJobStorage());
                    services.AddHangfireServerServices();
                }
            }

            //background processes
            ConfigureBackgroundProcesses(context, services);
        }
 public abstract void ConfigureAppConfiguration(TenantBuilderContext context, IConfigurationBuilder builder);