helongyang
昨天 cb25acc46bf41863e068b6f968f1592b7a14d1c9
´úÂë¹ÜÀí/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
@@ -21,6 +21,8 @@
using Autofac.Core;
using WIDESEAWCS_QuartzJob.QuartzExtensions;
using Microsoft.AspNetCore.Builder;
using WIDESEAWCS_Server.HostedService;
using WIDESEAWCS_Tasks;
var builder = WebApplication.CreateBuilder(args);
@@ -31,12 +33,14 @@
    builder.RegisterModule<AutofacPropertityModuleReg>();//
}).ConfigureAppConfiguration((hostingContext, config) =>
{
    hostingContext.Configuration.ConfigureApplication();
    config.Sources.Clear();
    config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false);
}); ;
builder.ConfigureApplication();
//App.ExpDateTime = DateTime.Parse("2025-05-31 00:00:00");
// 2、配置服务
builder.Services.AddSingleton(new AppSettings(builder.Configuration));//注册
@@ -47,7 +51,13 @@
builder.Services.AddDbSetup();//Db å¯åŠ¨æœåŠ¡
builder.Services.AddScoped<QuartzJobCreateDataTabel>();
builder.Services.AddHostedService<WarehouseHostedService>();
builder.Services.AddHostedService<QuartzJobDataTableHostedService>();
//builder.Services.AddWebSocketSetup();
builder.Services.AddWebSocketSetup();
builder.Services.AddHostedService<WarehouseHostedService>();
builder.Services.AddAutoMapperSetup();
@@ -60,6 +70,7 @@
builder.Services.AddJobSetup();//任务调度 å¯åŠ¨æœåŠ¡
builder.Services.AddHttpContextSetup();
builder.Services.AddHostedService<QuartzJobHostedService>();
@@ -110,12 +121,14 @@
app.UseAllServicesMiddle(builder.Services);
app.UseSession();
//if (app.Environment.IsDevelopment())
if (app.Environment.IsProduction())
{
    //todo
    app.UseSwaggerAuthorized();
    app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEAWCS_Server.index.html") ?? throw new Exception("未找到WIDESEAWCS_Server.index.html文件"));
}//判断是否需要打开swagger
app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEAWCS_Server.index.html") ?? throw new Exception("未找到WIDESEAWCS_Server.index.html文件"));
app.UseIpLimitMiddle();
app.UseApiLogMiddleware();
@@ -140,4 +153,6 @@
app.MapControllers();
//BarcodeScanner.StartServer();
app.Run();