From b690250002ee04f4309e6a90fd16fbfd9bd959e2 Mon Sep 17 00:00:00 2001
From: wanshenmean <cathay_xy@163.com>
Date: 星期五, 01 五月 2026 23:11:23 +0800
Subject: [PATCH] feat(router): 添加托盘操作页面路由
---
Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs | 79 ++++++++++++++++++++++++++++++++++-----
1 files changed, 69 insertions(+), 10 deletions(-)
diff --git a/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs b/Code/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Program.cs
index 8ea1382..d2e1d7a 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;
@@ -12,6 +10,10 @@
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using Serilog;
+using Serilog.Events;
+using Serilog.Formatting.Json;
+using System.Reflection;
+using System.Text;
using WIDESEA_Core;
using WIDESEA_Core.Authorization;
using WIDESEA_Core.BaseServices;
@@ -19,6 +21,7 @@
using WIDESEA_Core.Extensions;
using WIDESEA_Core.Filter;
using WIDESEA_Core.Helper;
+
//using WIDESEA_Core.HostedService;
using WIDESEA_Core.Middlewares;
using WIDESEA_WMSServer.BackgroundServices;
@@ -35,6 +38,7 @@
hostingContext.Configuration.ConfigureApplication();
config.Sources.Clear();
config.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);
+ config.AddJsonFile("outbound_time_config.json", optional: true, reloadOnChange: true);
});
builder.Host.UseSerilog((context, services, loggerConfiguration) =>
@@ -42,13 +46,64 @@
loggerConfiguration
.ReadFrom.Configuration(context.Configuration)
.ReadFrom.Services(services)
- .Enrich.FromLogContext()
- .WriteTo.Console()
+ //.Enrich.FromLogContext()
+ .WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}")
.WriteTo.File(
- "logs/serilog-.log.txt",
+ //new JsonFormatter(renderMessage: true),
+ "logs/serilog-.log",
+ outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
rollingInterval: RollingInterval.Day,
retainedFileCountLimit: 30,
- shared: true);
+ // 姣忎釜鏃ュ織鏂囦欢鏈�澶уぇ灏忥紙瀛楄妭锛夛紝姝ゅ璁剧疆涓�10MB
+ fileSizeLimitBytes: 10 * 1024 * 1024,
+ shared: true
+ )
+ // 鍒嗗鏌滄帴鍙g嫭绔嬫棩蹇楁枃浠�
+ .WriteTo.Logger(lc => lc
+ .Filter.ByIncludingOnly(e => e.Properties.TryGetValue("SourceContext", out var sc) && sc is ScalarValue sv && sv.Value?.ToString() == "鍒嗗鏌滃畬鎴愪俊鍙�")
+ .WriteTo.File(
+ "logs/鍒嗗鏌滃畬鎴愪俊鍙�-.log",
+ outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+ rollingInterval: RollingInterval.Day,
+ retainedFileCountLimit: 30,
+ fileSizeLimitBytes: 10 * 1024 * 1024,
+ shared: true))
+ .WriteTo.Logger(lc => lc
+ .Filter.ByIncludingOnly(e => e.Properties.TryGetValue("SourceContext", out var sc) && sc is ScalarValue sv && sv.Value?.ToString() == "鍒嗗鏌滅姸鎬佹洿鏂�")
+ .WriteTo.File(
+ "logs/鍒嗗鏌滅姸鎬佹洿鏂�-.log",
+ outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+ rollingInterval: RollingInterval.Day,
+ retainedFileCountLimit: 30,
+ fileSizeLimitBytes: 10 * 1024 * 1024,
+ shared: true))
+ .WriteTo.Logger(lc => lc
+ .Filter.ByIncludingOnly(e => e.Properties.TryGetValue("SourceContext", out var sc) && sc is ScalarValue sv && sv.Value?.ToString() == "鍒嗗鏌滃嚭搴撹姹�")
+ .WriteTo.File(
+ "logs/鍒嗗鏌滃嚭搴撹姹�-.log",
+ outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+ rollingInterval: RollingInterval.Day,
+ retainedFileCountLimit: 30,
+ fileSizeLimitBytes: 10 * 1024 * 1024,
+ shared: true))
+ .WriteTo.Logger(lc => lc
+ .Filter.ByIncludingOnly(e => e.Properties.TryGetValue("SourceContext", out var sc) && sc is ScalarValue sv && sv.Value?.ToString() == "鍒嗗鏌滅數鑺煡璇�")
+ .WriteTo.File(
+ "logs/鍒嗗鏌滅數鑺煡璇�-.log",
+ outputTemplate: "[{Timestamp:HH:mm:ss} {Level:u3}] {Message:lj}{NewLine}{Exception}",
+ rollingInterval: RollingInterval.Day,
+ retainedFileCountLimit: 30,
+ 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();
@@ -60,12 +115,15 @@
builder.Services.AddSingleton<RoundRobinService>();
builder.Services.Configure<AutoOutboundTaskOptions>(
builder.Configuration.GetSection("AutoOutboundTask"));
+builder.Services.Configure<OutboundTimeConfigOptions>(
+ builder.Configuration.GetSection(OutboundTimeConfigOptions.SectionName));
builder.Services.AddMemoryCacheSetup(); // 缂撳瓨鏈嶅姟
builder.Services.AddWebSocketSetup();
builder.Services.AddSqlsugarSetup(); // SqlSugar 鏁版嵁搴撻厤缃�
builder.Services.AddDbSetup(); // Db 鏁版嵁搴撻厤缃�
builder.Services.AddInitializationHostServiceSetup(); // 搴旂敤绋嬪簭鍒濆鍖栨湇鍔℃敞鍐�
builder.Services.AddHostedService<AutoOutboundTaskBackgroundService>(); // 鍚姩鑷姩鍑哄簱浠诲姟鍚庡彴鏈嶅姟
+builder.Services.AddHostedService<StockMonitorBackgroundService>(); // 鍚姩搴撳瓨鐩戞帶鍚庡彴鏈嶅姟
// builder.Services.AddHostedService<PermissionDataHostService>(); // 鏉冮檺鏁版嵁鏈嶅姟
builder.Services.AddAutoMapperSetup();
@@ -77,12 +135,13 @@
builder.Services.AddHttpContextSetup();
-
builder.Services.AddMvc(options =>
{
options.Filters.Add(typeof(ApiAuthorizeFilter));
options.Filters.Add(typeof(ActionExecuteFilter));
});
+
+builder.Services.AddSignalR();
builder.Services.AddScoped<HttpClientHelper>();
@@ -116,7 +175,6 @@
builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>());
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
-
var app = builder.Build();
// 3. 閰嶇疆涓棿浠�
@@ -133,7 +191,6 @@
app.UseApiLogMiddleware();
// todo
// app.UseRecordAccessLogsMiddle();
-
DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions();
defaultFilesOptions.DefaultFileNames.Clear();
@@ -159,4 +216,6 @@
app.MapControllers();
-app.Run();
+app.MapHub<WIDESEA_WMSServer.Hubs.StockHub>("/stockHub");
+
+app.Run();
\ No newline at end of file
--
Gitblit v1.9.3