* Created AzureDataModel

* Created Hangfire API
This commit is contained in:
2025-02-12 20:29:10 +01:00
parent 6800781fdb
commit e7342abadd
16 changed files with 414 additions and 0 deletions

43
HangfireApi/Program.cs Normal file
View File

@@ -0,0 +1,43 @@
using Hangfire;
using Hangfire.SqlServer;
using HangfireApi.Controllers;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHangfire(configuration => configuration
.SetDataCompatibilityLevel(CompatibilityLevel.Version_170)
.UseSimpleAssemblyNameTypeSerializer()
.UseRecommendedSerializerSettings()
.UseSqlServerStorage(builder.Configuration.GetConnectionString("HangfireConnection"), new SqlServerStorageOptions
{
CommandBatchMaxTimeout = TimeSpan.FromMinutes(5),
SlidingInvisibilityTimeout = TimeSpan.FromMinutes(5),
QueuePollInterval = TimeSpan.Zero,
UseRecommendedIsolationLevel = true,
DisableGlobalLocks = true
}));
builder.Services.AddControllers();
builder.Services.AddHangfireServer();
builder.Services.AddAuthorization();
builder.Services.AddSingleton<JobStorage>(provider =>
provider.GetRequiredService<IServiceProvider>().GetService(typeof(JobStorage)) as JobStorage ??
throw new InvalidOperationException());
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseAuthorization();
app.MapControllers();
app.MapHangfireDashboard();
await ((IApplicationBuilder)app).ApplicationServices.GetRequiredService<HangfireJobsController>().RunJobs();
await app.RunAsync();