fix
This commit is contained in:
parent
885e320432
commit
2d229bbedd
@ -1,3 +1,4 @@
|
|||||||
|
using Fake.UnitOfWork;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
@ -53,6 +54,9 @@ public class XhsScheduledPublishWorker : BackgroundService
|
|||||||
private async Task ProcessDueAsync(CancellationToken cancellationToken)
|
private async Task ProcessDueAsync(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
using var scope = _scopeFactory.CreateScope();
|
using var scope = _scopeFactory.CreateScope();
|
||||||
|
var unitOfWorkManager = scope.ServiceProvider.GetRequiredService<IUnitOfWorkManager>();
|
||||||
|
using var unitOfWork = unitOfWorkManager.Begin();
|
||||||
|
|
||||||
var publishRecordRepository = scope.ServiceProvider.GetRequiredService<IXhsPublishRecordRepository>();
|
var publishRecordRepository = scope.ServiceProvider.GetRequiredService<IXhsPublishRecordRepository>();
|
||||||
var publishService = scope.ServiceProvider.GetRequiredService<XhsPublishService>();
|
var publishService = scope.ServiceProvider.GetRequiredService<XhsPublishService>();
|
||||||
|
|
||||||
@ -81,5 +85,7 @@ public class XhsScheduledPublishWorker : BackgroundService
|
|||||||
record.Id,
|
record.Id,
|
||||||
task.Id);
|
task.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await unitOfWork.CompleteAsync(cancellationToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,11 +1,23 @@
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using SimpleAdmin.Api;
|
using SimpleAdmin.Api;
|
||||||
|
|
||||||
|
var builder = WebApplication.CreateSlimBuilder(args);
|
||||||
|
var configuration = builder.Configuration;
|
||||||
|
builder.Configuration.AddConsul("idwms/common", source => source.ReloadOnChange = true);
|
||||||
|
builder.Configuration.AddConsul("idwms/admin", source => source.ReloadOnChange = true);
|
||||||
|
Log.Logger = new LoggerConfiguration()
|
||||||
|
.ReadFrom.Configuration(configuration)
|
||||||
|
.CreateLogger();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var builder = SimpleAdminApiBootstrap.CreateBuilder(args);
|
builder.WebHost.UseUrls(builder.Configuration.GetSection("App:Urls").Get<string[]>() ?? []);
|
||||||
var app = SimpleAdminApiBootstrap.BuildApplication(builder);
|
builder.Host.UseAutofac().UseSerilog();
|
||||||
await app.RunAsync();
|
builder.Services.AddApplication<SimpleAdminApiModule>();
|
||||||
|
|
||||||
|
var app = builder.Build();
|
||||||
|
app.InitializeApplication();
|
||||||
|
app.Run();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -14,6 +26,4 @@ catch (Exception ex)
|
|||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
Log.CloseAndFlush();
|
Log.CloseAndFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial class Program;
|
|
||||||
@ -4,7 +4,6 @@ using Fake.Modularity;
|
|||||||
using Fake.Rbac.Application;
|
using Fake.Rbac.Application;
|
||||||
using Fake.Rbac.Infrastructure;
|
using Fake.Rbac.Infrastructure;
|
||||||
using Fake.AspNetCore.Auditing;
|
using Fake.AspNetCore.Auditing;
|
||||||
using Fake.AspNetCore.Authentication;
|
|
||||||
using Fake.AspNetCore.ExceptionHandling;
|
using Fake.AspNetCore.ExceptionHandling;
|
||||||
using Fake.AspNetCore.Newtonsoft;
|
using Fake.AspNetCore.Newtonsoft;
|
||||||
using Fake.AspNetCore.Swagger;
|
using Fake.AspNetCore.Swagger;
|
||||||
@ -25,6 +24,7 @@ namespace SimpleAdmin.Api;
|
|||||||
typeof(OmsSqlSugarCoreModule),
|
typeof(OmsSqlSugarCoreModule),
|
||||||
typeof(FakeRbacApplicationModule),
|
typeof(FakeRbacApplicationModule),
|
||||||
typeof(FakeRbacInfrastructureModule),
|
typeof(FakeRbacInfrastructureModule),
|
||||||
|
typeof(FakeAspNetCoreModule),
|
||||||
typeof(FakeSerilogModule)
|
typeof(FakeSerilogModule)
|
||||||
)]
|
)]
|
||||||
public class SimpleAdminApiModule : FakeModule
|
public class SimpleAdminApiModule : FakeModule
|
||||||
@ -90,6 +90,8 @@ public class SimpleAdminApiModule : FakeModule
|
|||||||
options.KnownNetworks.Clear();
|
options.KnownNetworks.Clear();
|
||||||
options.KnownProxies.Clear();
|
options.KnownProxies.Clear();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
services.AddFeiShuNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void ConfigureApplication(ApplicationConfigureContext context)
|
public override void ConfigureApplication(ApplicationConfigureContext context)
|
||||||
@ -122,21 +124,6 @@ public class SimpleAdminApiModule : FakeModule
|
|||||||
// 端点映射
|
// 端点映射
|
||||||
app.MapControllers();
|
app.MapControllers();
|
||||||
|
|
||||||
var shouldSendStartupNotification =
|
app.Services.GetRequiredService<IFeiShuNotificationService>().Send("Application started");
|
||||||
!app.Environment.IsEnvironment("Testing") &&
|
|
||||||
app.Configuration.GetValue("App:SendStartupNotification", true);
|
|
||||||
if (!shouldSendStartupNotification)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
app.Services.GetRequiredService<IFeiShuNotificationService>().Send("Application started");
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
app.Logger.LogWarning(ex, "Failed to send startup notification.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user