You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

112 lines
5.3 KiB
C#

using EntrustSettle.Common;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Text;
using EntrustSettle.Common.DB;
using System.Collections.Generic;
using System;
namespace EntrustSettle.Extensions
{
/// <summary>
/// 项目 启动服务
/// </summary>
public static class AppConfigSetup
{
public static void AddAppTableConfigSetup(this IServiceCollection services, IHostEnvironment env)
{
if (services == null) throw new ArgumentNullException(nameof(services));
if (AppSettings.app(new string[] { "Startup", "AppConfigAlert", "Enabled" }).ObjToBool())
{
if (env.IsDevelopment())
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.OutputEncoding = Encoding.GetEncoding("GB2312");
}
#region 程序配置
List<string[]> configInfos = new()
{
new string[] { "当前环境", Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") },
new string[] { "当前的授权方案", Permissions.IsUseIds4 ? "Ids4" : "JWT" },
new string[] { "CORS跨域", AppSettings.app("Startup", "Cors", "EnableAllIPs") },
new string[] { "RabbitMQ消息列队", AppSettings.app("RabbitMQ", "Enabled") },
new string[] { "事件总线(必须开启消息列队)", AppSettings.app("EventBus", "Enabled") },
new string[] { "Redis", AppSettings.app("Redis", "Enabled") },
new string[] { "Redis消息队列", AppSettings.app("Startup", "RedisMq", "Enabled") },
new string[] { "读写分离", BaseDBConfig.MainConfig.SlaveConnectionConfigs.AnyNoException()? "True" : "False" },
new string[] { "Quartz定时任务", AppSettings.app("QuartzNetJob", "Enabled") },
new string[] { "Timed定时任务", AppSettings.app("TimedJob", "Enabled") },
new string[] { "日志记录到库总开关", AppSettings.app("AppSettings", "LogToDb") },
};
new ConsoleTable()
{
TitleString = "EntrustSettle 配置集",
Columns = new string[] { "配置名称", "配置信息/是否启动" },
Rows = configInfos,
EnableCount = false,
Alignment = Alignment.Left,
ColumnBlankNum = 4,
TableStyle = TableStyle.Alternative
}.Writer(ConsoleColor.Blue);
Console.WriteLine();
#endregion 程序配置
#region AOP
List<string[]> aopInfos = new()
{
new string[] { "缓存AOP", AppSettings.app("AppSettings", "CachingAOP", "Enabled") },
new string[] { "事务AOP", AppSettings.app("AppSettings", "TranAOP", "Enabled") },
new string[] { "服务层AOP日志", AppSettings.app("AppSettings", "ServiceAOPLog", "Enabled") },
new string[] { "Sql执行AOP日志", AppSettings.app("AppSettings", "SqlAOPLog", "Enabled") },
new string[] { "Sql执行AOP日志记录到文件", AppSettings.app("AppSettings", "SqlAOPLog", "LogToFile", "Enabled") },
new string[] { "Sql执行AOP日志记录控制台", AppSettings.app("AppSettings", "SqlAOPLog", "LogToConsole", "Enabled") },
};
new ConsoleTable
{
TitleString = "AOP",
Columns = new string[] { "配置名称", "配置信息/是否启动" },
Rows = aopInfos,
EnableCount = false,
Alignment = Alignment.Left,
ColumnBlankNum = 7,
TableStyle = TableStyle.Alternative
}.Writer(ConsoleColor.Blue);
Console.WriteLine();
#endregion AOP
#region 中间件
List<string[]> MiddlewareInfos = new()
{
new string[] { "请求日志记录中间件", AppSettings.app("Middleware", "RecordAccessLogs", "Enabled") },
new string[] { "请求响应日志记录中间件", AppSettings.app("Middleware", "RequestResponseLog", "Enabled") },
new string[] { "SingnalR实时发送请求数据中间件", AppSettings.app("Middleware", "SignalR", "Enabled") },
new string[] { "IP限流中间件", AppSettings.app("Middleware", "IpRateLimit", "Enabled") },
};
new ConsoleTable
{
TitleString = "中间件",
Columns = new string[] { "配置名称", "配置信息/是否启动" },
Rows = MiddlewareInfos,
EnableCount = false,
Alignment = Alignment.Left,
ColumnBlankNum = 3,
TableStyle = TableStyle.Alternative
}.Writer(ConsoleColor.Blue);
Console.WriteLine();
#endregion 中间件
}
}
}
}