| | |
| | | using System.Reflection; |
| | | using System.Text; |
| | | using Autofac; |
| | | using Autofac.Core; |
| | | using Autofac.Extensions.DependencyInjection; |
| | |
| | | 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; |
| | |
| | | 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. 可选:输出到Seq日志服务器(结构化日志服务器) |
| | | // 需要安装 Serilog.Sinks.Seq NuGet包,并确保Seq服务在 http://localhost:5341 运行 |
| | | // 如不需要Seq日志,注释掉下方代码即可 |
| | | .WriteTo.Seq( |
| | | serverUrl: "http://localhost:5341", |
| | | apiKey: "CWVa8UWQ9CdUp9GWXCPL", // 如Seq需要ApiKey则配置真实密钥 |
| | | batchPostingLimit: 1000, // 批量发送数量 |
| | | period: TimeSpan.FromSeconds(2) // 发送间隔 |
| | | ); |
| | | }); |
| | | builder.ConfigureApplication(); |
| | | |
| | | // App.ExpDateTime = DateTime.Parse("2025-03-31 00:00:00"); // 设置过期时间 |
| | |
| | | builder.Services.AddSqlsugarSetup(); // SqlSugar 数据库配置 |
| | | builder.Services.AddDbSetup(); // Db 数据库配置 |
| | | builder.Services.AddInitializationHostServiceSetup(); // 应用程序初始化服务注册 |
| | | builder.Services.AddHostedService<AutoOutboundTaskBackgroundService>(); |
| | | builder.Services.AddHostedService<AutoOutboundTaskBackgroundService>(); // 启动自动出库任务后台服务 |
| | | // builder.Services.AddHostedService<PermissionDataHostService>(); // 权限数据服务 |
| | | builder.Services.AddAutoMapperSetup(); |
| | | |
| | |
| | | options.Filters.Add(typeof(ApiAuthorizeFilter)); |
| | | options.Filters.Add(typeof(ActionExecuteFilter)); |
| | | }); |
| | | |
| | | builder.Services.AddSignalR(); |
| | | |
| | | builder.Services.AddScoped<HttpClientHelper>(); |
| | | |
| | |
| | | |
| | | app.MapControllers(); |
| | | |
| | | app.MapHub<WIDESEA_WMSServer.Hubs.StockHub>("/stockHub"); |
| | | |
| | | app.Run(); |