| | |
| | | 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.Extensions; |
| | | using WIDESEA_Core.Filter; |
| | | using WIDESEA_Core.Helper; |
| | | |
| | | //using WIDESEA_Core.HostedService; |
| | | using WIDESEA_Core.Middlewares; |
| | | using WIDESEA_WMSServer.BackgroundServices; |
| | |
| | | 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) => |
| | |
| | | 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)) |
| | | .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. 可选:输出到Seq日志服务器(结构化日志服务器) |
| | | // 需要安装 Serilog.Sinks.Seq NuGet包,并确保Seq服务在 http://localhost:5341 运行 |
| | | // 如不需要Seq日志,注释掉下方代码即可 |
| | |
| | | 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.AddSwaggerSetup(); |
| | | |
| | | builder.Services.AddHttpContextSetup(); |
| | | |
| | | |
| | | builder.Services.AddMvc(options => |
| | | { |
| | |
| | | builder.Services.Replace(ServiceDescriptor.Transient<IControllerActivator, ServiceBasedControllerActivator>()); |
| | | Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); |
| | | |
| | | |
| | | var app = builder.Build(); |
| | | |
| | | // 3. 配置中间件 |
| | |
| | | app.UseApiLogMiddleware(); |
| | | // todo |
| | | // app.UseRecordAccessLogsMiddle(); |
| | | |
| | | |
| | | DefaultFilesOptions defaultFilesOptions = new DefaultFilesOptions(); |
| | | defaultFilesOptions.DefaultFileNames.Clear(); |
| | |
| | | |
| | | app.MapHub<WIDESEA_WMSServer.Hubs.StockHub>("/stockHub"); |
| | | |
| | | app.Run(); |
| | | app.Run(); |