You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.9 KiB
58 lines
1.9 KiB
using Hangfire; |
|
using Hangfire.Dashboard; |
|
using Microsoft.Extensions.DependencyInjection; |
|
using Sanhe.Abp.Hangfire.Dashboard.Authorization; |
|
using Sanhe.Abp.Hangfire.Dashboard.Localization; |
|
using Sanhe.Abp.Hangfire.Dashboard.Permissions; |
|
using Volo.Abp.Authorization; |
|
using Volo.Abp.Hangfire; |
|
using Volo.Abp.Localization; |
|
using Volo.Abp.Modularity; |
|
using Volo.Abp.VirtualFileSystem; |
|
|
|
namespace Sanhe.Abp.Hangfire.Dashboard |
|
{ |
|
[DependsOn( |
|
typeof(AbpAuthorizationModule), |
|
typeof(AbpHangfireModule))] |
|
public class AbpHangfireDashboardModule : AbpModule |
|
{ |
|
public override void PreConfigureServices(ServiceConfigurationContext context) |
|
{ |
|
PreConfigure<DashboardOptions>(options => |
|
{ |
|
options.AsyncAuthorization = new IDashboardAsyncAuthorizationFilter[] |
|
{ |
|
new DashboardAuthorizationFilter( |
|
HangfireDashboardPermissions.Dashboard) |
|
}; |
|
}); |
|
} |
|
|
|
public override void ConfigureServices(ServiceConfigurationContext context) |
|
{ |
|
Configure<AbpVirtualFileSystemOptions>(options => |
|
{ |
|
options.FileSets.AddEmbedded<AbpHangfireDashboardModule>(); |
|
}); |
|
|
|
Configure<AbpLocalizationOptions>(options => |
|
{ |
|
options.Resources |
|
.Add<HangfireDashboardResource>("en") |
|
.AddVirtualJson("/Sanhe/Abp/Hangfire/Dashboard/Localization/Resources"); |
|
}); |
|
|
|
var preActions = context.Services.GetPreConfigureActions<DashboardOptions>(); |
|
context.Services.AddTransient(serviceProvider => |
|
{ |
|
var options = serviceProvider.GetRequiredService<AbpHangfireDashboardOptionsProvider>().Get(); |
|
preActions.Configure(options); |
|
|
|
return options; |
|
}); |
|
|
|
context.Services.AddHangfireServer(); |
|
} |
|
} |
|
}
|
|
|