Files
jinko.yikatong/Src/Dlhis.Middle/Program.cs
2024-06-26 18:23:06 +08:00

64 lines
2.1 KiB
C#

using Dlhis.Entity.Basic.Entity;
using Dlhis.Entity.Device.Entities;
using Dlhis.Middle.Entities;
using Dlhis.Middle.Services;
using Dlhis.Middle.Services.Implements;
using Kurisu.AspNetCore.Startup;
using Microsoft.IdentityModel.Logging;
namespace Dlhis.Middle;
class Program
{
static void Main(string[] args)
{
KurisuHost.Run<Startup>(args);
}
}
public class Startup : DefaultStartup
{
public Startup(IConfiguration configuration) : base(configuration)
{
IdentityModelEventSource.ShowPII = true;
}
public override void ConfigureServices(IServiceCollection services)
{
base.ConfigureServices(services);
services.AddHttpClient("face").ConfigurePrimaryHttpMessageHandler(() =>
{
var handler = new HttpClientHandler
{
ClientCertificateOptions = ClientCertificateOption.Manual,
ServerCertificateCustomValidationCallback = (_, _, _, _) => true
};
return handler;
});
services.AddHostedService<HealthCheckBackgroundService>();
services.AddMemoryCache();
}
/// <inheritdoc />
public override void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
base.Configure(app, env);
using var scope = app.ApplicationServices.CreateScope();
var factory = Configuration.GetSection("Factory").Value;
var ds = scope.ServiceProvider.GetService<IDataDownloadService>();
ds.TruncateAsync().Wait();
ds.DownloadAsync<LocalDepartmentEntity>(factory).Wait();
ds.DownloadAsync<LocalDeviceEntity>(factory).Wait();
ds.DownloadAsync<LocalDeviceRegistryEntity>(factory).Wait();
ds.DownloadAsync<LocalBusinessPlaceEntity>(factory).Wait();
ds.DownloadAsync<LocalBusinessShiftEntity>(factory).Wait();
ds.DownloadAsync<LocalBusinessPlaceShiftRelationshipEntity>(factory).Wait();
ds.DownloadAsync<LocalBusinessShiftMealRelationshipEntity>(factory).Wait();
ds.DownloadAsync<LocalGainfoEntity>(factory).Wait();
ds.DownloadAsync<LocalGainfoMealEntity>(factory).Wait();
}
}