From 5af11cc200dd5ebe474b9c0475883b0e6d1e3759 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期三, 11 三月 2026 10:00:49 +0800
Subject: [PATCH] 重构整个项目:改进代码质量和架构

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs |   47 ++++++++++++++++++++++++++---------------------
 1 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
index 26e3d14..1d708bf 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
@@ -20,33 +20,38 @@
 using WIDESEA_Core.Helper;
 //using WIDESEA_Core.HostedService;
 using WIDESEA_Core.Middlewares;
+using WIDESEA_WMSServer.BackgroundServices;
 using WIDESEA_WMSServer.Filter;
 
 var builder = WebApplication.CreateBuilder(args);
 
 builder.Host.UseServiceProviderFactory(new AutofacServiceProviderFactory()).ConfigureContainer<ContainerBuilder>(builder =>
 {
-    builder.RegisterModule<AutofacModuleRegister>();//带有接口层的服务注入
-    builder.RegisterModule<AutofacPropertityModuleReg>();//
+    builder.RegisterModule<AutofacModuleRegister>(); // 娉ㄥ唽鎺ュ彛渚濊禆娉ㄥ叆
+    builder.RegisterModule<AutofacPropertityModuleReg>(); // 娉ㄥ唽灞炴�ф敞鍏�
 }).ConfigureAppConfiguration((hostingContext, config) =>
 {
     hostingContext.Configuration.ConfigureApplication();
     config.Sources.Clear();
     config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
-}); ;
+});
 builder.ConfigureApplication();
 
-//App.ExpDateTime = DateTime.Parse("2025-03-31 00:00:00");//过期时间
+// App.ExpDateTime = DateTime.Parse("2025-03-31 00:00:00"); // 璁剧疆杩囨湡鏃堕棿
 
-// 2、配置服务
-builder.Services.AddSingleton(new AppSettings(builder.Configuration));//注册
-builder.Services.AddAllOptionRegister();//读取配置文件
-builder.Services.AddMemoryCacheSetup();//缓存
+// 2. 閰嶇疆鏈嶅姟
+builder.Services.AddSingleton(new AppSettings(builder.Configuration)); // 娉ㄥ唽閰嶇疆
+builder.Services.AddAllOptionRegister(); // 鑾峰彇閰嶇疆鏂囦欢
+builder.Services.AddSingleton<RoundRobinService>();
+builder.Services.Configure<AutoOutboundTaskOptions>(
+    builder.Configuration.GetSection("AutoOutboundTask"));
+builder.Services.AddMemoryCacheSetup(); // 缂撳瓨鏈嶅姟
 builder.Services.AddWebSocketSetup();
-builder.Services.AddSqlsugarSetup();//SqlSugar 启动服务
-builder.Services.AddDbSetup();//Db 启动服务
-builder.Services.AddInitializationHostServiceSetup();//应用初始化服务注入
-//builder.Services.AddHostedService<PermissionDataHostService>();//数据权限
+builder.Services.AddSqlsugarSetup(); // SqlSugar 鏁版嵁搴撻厤缃�
+builder.Services.AddDbSetup(); // Db 鏁版嵁搴撻厤缃�
+builder.Services.AddInitializationHostServiceSetup(); // 搴旂敤绋嬪簭鍒濆鍖栨湇鍔℃敞鍐�
+builder.Services.AddHostedService<AutoOutboundTaskBackgroundService>();
+// builder.Services.AddHostedService<PermissionDataHostService>(); // 鏉冮檺鏁版嵁鏈嶅姟
 builder.Services.AddAutoMapperSetup();
 
 builder.Services.AddCorsSetup();
@@ -68,7 +73,7 @@
 
 builder.Services.AddAuthorizationSetup();
 
-builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration);//IPLimit限流 启动服务
+builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration); // IP闄愭祦 涓棿浠舵敞鍐�
 
 builder.Services.AddScoped<UseServiceDIAttribute>();
 
@@ -78,7 +83,7 @@
 
 builder.Services.AddControllers(o =>
 {
-    o.Filters.Add(typeof(GlobalExceptionsFilter));//全局异常
+    o.Filters.Add(typeof(GlobalExceptionsFilter)); // 鍏ㄥ眬寮傚父澶勭悊
 })
 .AddNewtonsoftJson(options =>
 {
@@ -99,20 +104,20 @@
 
 var app = builder.Build();
 
-// 3、配置中间件
-app.UseMiniProfiler();//性能分析器
-app.ConfigureApplication();//配置文件
-app.UseApplicationSetup();//启动配置
+// 3. 閰嶇疆涓棿浠�
+app.UseMiniProfiler(); // 鎬ц兘鍒嗘瀽
+app.ConfigureApplication(); // 搴旂敤閰嶇疆
+app.UseApplicationSetup(); // 搴旂敤鍚姩
 
 app.UseAllServicesMiddle(builder.Services);
 
 app.UseSession();
 app.UseSwaggerAuthorized();
-app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEA_WMSServer.index.html") ?? throw new Exception("WIDESEA_WMSServer.index.html文件"));
+app.UseSwaggerMiddle(() => Assembly.GetExecutingAssembly().GetManifestResourceStream("WIDESEA_WMSServer.index.html") ?? throw new Exception("WIDESEA_WMSServer.index.html鏂囦欢涓嶅瓨鍦�"));
 app.UseIpLimitMiddle();
 app.UseApiLogMiddleware();
-//todo
-//app.UseRecordAccessLogsMiddle();
+// todo
+// app.UseRecordAccessLogsMiddle();
 
 
 DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions();

--
Gitblit v1.9.3