From 484a4aa4e856f60d177294a1503d141781a92ed0 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期一, 30 三月 2026 09:55:31 +0800
Subject: [PATCH] fix(WIDESEA_StockService): 添加缺失的WIDESEA_IBasicService项目引用

---
 Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs |   79 +++++++++++++++++++++++++++------------
 1 files changed, 55 insertions(+), 24 deletions(-)

diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
index 32e4349..e5332e1 100644
--- a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
+++ b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
@@ -1,5 +1,3 @@
-using System.Reflection;
-using System.Text;
 using Autofac;
 using Autofac.Core;
 using Autofac.Extensions.DependencyInjection;
@@ -11,6 +9,10 @@
 using Newtonsoft.Json;
 using Newtonsoft.Json.Converters;
 using Newtonsoft.Json.Serialization;
+using Serilog;
+using Serilog.Formatting.Json;
+using System.Reflection;
+using System.Text;
 using WIDESEA_Core;
 using WIDESEA_Core.Authorization;
 using WIDESEA_Core.BaseServices;
@@ -27,30 +29,59 @@
 
 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.Host.UseSerilog((context, services, loggerConfiguration) =>
+{
+    loggerConfiguration
+        .ReadFrom.Configuration(context.Configuration)
+        .ReadFrom.Services(services)
+        //.Enrich.FromLogContext()
+        .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
+        .WriteTo.File(
+            //new JsonFormatter(renderMessage: true),
+            "logs/serilog-.log",
+            outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+            rollingInterval: RollingInterval.Day,
+            retainedFileCountLimit: 30,
+            // 姣忎釜鏃ュ織鏂囦欢鏈�澶уぇ灏忥紙瀛楄妭锛夛紝姝ゅ璁剧疆涓�10MB
+            fileSizeLimitBytes: 10 * 1024 * 1024,
+            shared: true
+            )
+         // 6. 鍙�夛細杈撳嚭鍒癝eq鏃ュ織鏈嶅姟鍣紙缁撴瀯鍖栨棩蹇楁湇鍔″櫒锛�
+         // 闇�瑕佸畨瑁� Serilog.Sinks.Seq NuGet鍖咃紝骞剁‘淇漇eq鏈嶅姟鍦� http://localhost:5341 杩愯
+         // 濡備笉闇�瑕丼eq鏃ュ織锛屾敞閲婃帀涓嬫柟浠g爜鍗冲彲
+         .WriteTo.Seq(
+             serverUrl: "http://localhost:5341",
+             apiKey: "CWVa8UWQ9CdUp9GWXCPL", // 濡係eq闇�瑕丄piKey鍒欓厤缃湡瀹炲瘑閽�
+             batchPostingLimit: 1000, // 鎵归噺鍙戦�佹暟閲�
+             period: TimeSpan.FromSeconds(2) // 鍙戦�侀棿闅�
+         );
+});
 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();//锟斤拷取锟斤拷锟斤拷锟侥硷拷
+// 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.AddMemoryCacheSetup(); // 缂撳瓨鏈嶅姟
 builder.Services.AddWebSocketSetup();
-builder.Services.AddSqlsugarSetup();//SqlSugar 锟斤拷锟斤拷锟斤拷锟斤拷
-builder.Services.AddDbSetup();//Db 锟斤拷锟斤拷锟斤拷锟斤拷
-builder.Services.AddInitializationHostServiceSetup();//应锟矫筹拷始锟斤拷锟斤拷锟斤拷注锟斤拷
-builder.Services.AddHostedService<AutoOutboundTaskBackgroundService>();
-//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();
@@ -72,7 +103,7 @@
 
 builder.Services.AddAuthorizationSetup();
 
-builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration);//IPLimit锟斤拷锟斤拷 锟斤拷锟斤拷锟斤拷锟斤拷
+builder.Services.AddIpPolicyRateLimitSetup(builder.Configuration); // IP闄愭祦 涓棿浠舵敞鍐�
 
 builder.Services.AddScoped<UseServiceDIAttribute>();
 
@@ -82,7 +113,7 @@
 
 builder.Services.AddControllers(o =>
 {
-    o.Filters.Add(typeof(GlobalExceptionsFilter));//全锟斤拷锟届常
+    o.Filters.Add(typeof(GlobalExceptionsFilter)); // 鍏ㄥ眬寮傚父澶勭悊
 })
 .AddNewtonsoftJson(options =>
 {
@@ -103,20 +134,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