From 4d5db2fa80e37839bbe2ceeb22e501afd583f8af Mon Sep 17 00:00:00 2001
From: wankeda <Administrator@DESKTOP-HAU3ST3>
Date: 星期一, 02 三月 2026 15:29:28 +0800
Subject: [PATCH] 1
---
WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs | 32 ++++++++++++++++++++------------
1 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs b/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
index 514202e..5d8bc5a 100644
--- a/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
+++ b/WCS/WIDESEAWCS_Server/WIDESEAWCS_Server/Program.cs
@@ -21,7 +21,8 @@
using Autofac.Core;
using WIDESEAWCS_QuartzJob.QuartzExtensions;
using Microsoft.AspNetCore.Builder;
-using System.Configuration;
+using WIDESEAWCS_Server.HostedService;
+using WIDESEAWCS_Tasks;
var builder = WebApplication.CreateBuilder(args);
@@ -38,17 +39,21 @@
}); ;
builder.ConfigureApplication();
+//App.ExpDateTime = DateTime.Parse("2025-05-31 00:00:00");
// 2、配置服务
builder.Services.AddSingleton(new AppSettings(builder.Configuration));//注册
builder.Services.AddAllOptionRegister();//读取配置文件
builder.Services.AddMemoryCacheSetup();//缓存
builder.Services.AddSqlsugarSetup();//SqlSugar 启动服务
-//builder.Services.AddInitializationHostServiceSetup();//应用初始化服务注入
+builder.Services.AddInitializationHostServiceSetup();//应用初始化服务注入
builder.Services.AddDbSetup();//Db 启动服务
-//builder.Services.AddScoped<QuartzJobCreateDataTabel>();
-//builder.Services.AddHostedService<QuartzJobDataTableHostedService>();
+builder.Services.AddScoped<QuartzJobCreateDataTabel>();
+builder.Services.AddHostedService<WarehouseHostedService>();
+builder.Services.AddHostedService<QuartzJobDataTableHostedService>();
+
+//builder.Services.AddWebSocketSetup();
builder.Services.AddAutoMapperSetup();
@@ -62,7 +67,7 @@
builder.Services.AddHttpContextSetup();
-builder.Services.AddHostedService<QuartzJobHostedService>();//任务调度 启动服务
+builder.Services.AddHostedService<QuartzJobHostedService>();
builder.Services.AddMvc(options =>
{
@@ -107,20 +112,21 @@
app.UseMiniProfiler();//性能分析器
app.ConfigureApplication();//配置文件
app.UseApplicationSetup();//启动配置
+
+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"));
+ app.UseSwaggerAuthorized();
+
}//判断是否需要打开swagger
+
+app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEAWCS_Server.index.html") ?? throw new Exception("未找到WIDESEAWCS_Server.index.html文件"));
app.UseIpLimitMiddle();
app.UseApiLogMiddleware();
-
//todo
//app.UseRecordAccessLogsMiddle();
@@ -142,4 +148,6 @@
app.MapControllers();
+//BarcodeScanner.StartServer();
app.Run();
+
--
Gitblit v1.9.3