Merge pull request #6701 from abpframework/liangshiwei/hangfire

Set job name for Hangfire background job integration
pull/6722/head
maliming 4 years ago committed by GitHub
commit 6e176b6788
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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;
}
}
}
}

@ -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