Browse Source

Merge pull request #6701 from abpframework/liangshiwei/hangfire

Set job name for Hangfire background job integration
pull/6722/head
maliming 6 years ago
committed by GitHub
parent
commit
6e176b6788
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      framework/src/Volo.Abp.BackgroundJobs.HangFire/Volo/Abp/BackgroundJobs/Hangfire/AbpBackgroundJobsHangfireModule.cs
  2. 26
      framework/src/Volo.Abp.BackgroundJobs.HangFire/Volo/Abp/BackgroundJobs/Hangfire/AbpDashboardOptionsProvider.cs

9
framework/src/Volo.Abp.BackgroundJobs.HangFire/Volo/Abp/BackgroundJobs/Hangfire/AbpBackgroundJobsHangfireModule.cs

@ -1,4 +1,5 @@
using System;
using System.Linq;
using Hangfire;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
@ -13,6 +14,12 @@ namespace Volo.Abp.BackgroundJobs.Hangfire
)]
public class AbpBackgroundJobsHangfireModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddTransient(serviceProvider =>
serviceProvider.GetRequiredService<AbpDashboardOptionsProvider>().Get());
}
public override void OnPreApplicationInitialization(ApplicationInitializationContext context)
{
var options = context.ServiceProvider.GetRequiredService<IOptions<AbpBackgroundJobOptions>>().Value;
@ -29,4 +36,4 @@ namespace Volo.Abp.BackgroundJobs.Hangfire
return null;
}
}
}
}

26
framework/src/Volo.Abp.BackgroundJobs.HangFire/Volo/Abp/BackgroundJobs/Hangfire/AbpDashboardOptionsProvider.cs

@ -0,0 +1,26 @@
using System.Linq;
using Hangfire;
using Microsoft.Extensions.Options;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.BackgroundJobs.Hangfire
{
public class AbpDashboardOptionsProvider : ITransientDependency
{
protected AbpBackgroundJobOptions AbpBackgroundJobOptions { get; }
public AbpDashboardOptionsProvider(IOptions<AbpBackgroundJobOptions> abpBackgroundJobOptions)
{
AbpBackgroundJobOptions = abpBackgroundJobOptions.Value;
}
public virtual DashboardOptions Get()
{
return new DashboardOptions
{
DisplayNameFunc = (dashboardContext, job) =>
AbpBackgroundJobOptions.GetJob(job.Args.First().GetType()).JobName
};
}
}
}
Loading…
Cancel
Save