From 0ce13a736c2c6037267516922ee1b2e818556fb4 Mon Sep 17 00:00:00 2001 From: wanggang <76527413@qq.com> Date: Mon, 29 Mar 2021 15:33:54 +0800 Subject: [PATCH] update Former-commit-id: 3a12e0951606c910ec0e1b639fe61d0baaf5d512 Former-commit-id: 19e5e6b62a8e2fbacf43042f73ece2596fb4bb6f --- .../Extensions/ConfigurationExtensions.cs | 12 ++++++++---- projects/Infrastructure/Infrastructure.csproj | 12 ++++++------ projects/IoTDameon/IoTDameon.csproj | 2 +- projects/Platform/Controllers/HomeController.cs | 1 + projects/Platform/Platform.csproj | 6 +++--- projects/Platform/Program.cs | 2 +- projects/Platform/Startup.cs | 3 +++ projects/Platform/appsettings.Development.json | 4 +++- projects/Platform/appsettings.json | 1 + 9 files changed, 27 insertions(+), 16 deletions(-) diff --git a/projects/Infrastructure/Extensions/ConfigurationExtensions.cs b/projects/Infrastructure/Extensions/ConfigurationExtensions.cs index 0f3d6852..1035712d 100644 --- a/projects/Infrastructure/Extensions/ConfigurationExtensions.cs +++ b/projects/Infrastructure/Extensions/ConfigurationExtensions.cs @@ -12,14 +12,18 @@ namespace Infrastructure.Extensions .ToDictionary(o => o.Split('=')[0], o => o.Split('=')[1]); } - public static string GetAppSetting(this IConfiguration configuration, string name, string defaultValue = null) + public static string GetAppSetting(this IConfiguration configuration, string name) { - return configuration.GetSection("AppSettings").GetValue(name, defaultValue); + return configuration.GetSection("AppSettings").GetValue(name); + } + public static T GetAppSetting(this IConfiguration configuration, string name, T defaultValue) + { + return configuration.GetSection("AppSettings").GetValue(name, defaultValue); } - public static Dictionary GetAppSettings(this IConfiguration configuration, string name, string defaultValue = null) + public static Dictionary GetAppSettings(this IConfiguration configuration, string name) { - return configuration.GetAppSetting(name).Split(';') + return configuration.GetAppSetting(name,"").Split(';') .ToDictionary(o => o.Split('=')[0], o => o.Split('=')[1]); } } diff --git a/projects/Infrastructure/Infrastructure.csproj b/projects/Infrastructure/Infrastructure.csproj index 09397338..794aae79 100644 --- a/projects/Infrastructure/Infrastructure.csproj +++ b/projects/Infrastructure/Infrastructure.csproj @@ -20,7 +20,7 @@ - + @@ -28,16 +28,16 @@ - - - + + + - - + + diff --git a/projects/IoTDameon/IoTDameon.csproj b/projects/IoTDameon/IoTDameon.csproj index 0a68820a..b7dec01a 100644 --- a/projects/IoTDameon/IoTDameon.csproj +++ b/projects/IoTDameon/IoTDameon.csproj @@ -7,7 +7,7 @@ - + diff --git a/projects/Platform/Controllers/HomeController.cs b/projects/Platform/Controllers/HomeController.cs index 71a26deb..166e5f63 100644 --- a/projects/Platform/Controllers/HomeController.cs +++ b/projects/Platform/Controllers/HomeController.cs @@ -27,6 +27,7 @@ namespace Platform.Controllers this._statisticRepo = statisticRepo; } + [Authorize] public IActionResult Index() { return View(); diff --git a/projects/Platform/Platform.csproj b/projects/Platform/Platform.csproj index 422bc82f..599cd448 100644 --- a/projects/Platform/Platform.csproj +++ b/projects/Platform/Platform.csproj @@ -7,14 +7,14 @@ 1.1.1.1 - + - + - + diff --git a/projects/Platform/Program.cs b/projects/Platform/Program.cs index 32c36f4e..cd3d5307 100644 --- a/projects/Platform/Program.cs +++ b/projects/Platform/Program.cs @@ -25,7 +25,7 @@ namespace Platform .ReadFrom.Configuration(config, ConfigurationAssemblySource.AlwaysScanDllFiles) .WriteTo.Console(); - logConfig = config.GetSection("AppSetting").GetValue("Log", "File") == "File" + logConfig = config.GetSection("AppSettings").GetValue("Log", "File") == "File" ? logConfig.WriteTo.File("logs/log.txt", rollOnFileSizeLimit: true, fileSizeLimitBytes: 100 * 1024 * 1024, rollingInterval: RollingInterval.Infinite) : logConfig.WriteTo.SQLite(Path.Combine(Directory.GetCurrentDirectory(), "log.db")); diff --git a/projects/Platform/Startup.cs b/projects/Platform/Startup.cs index 1cc80b75..e0ccf7ff 100644 --- a/projects/Platform/Startup.cs +++ b/projects/Platform/Startup.cs @@ -35,6 +35,9 @@ namespace Platform { services.AddMiniProfiler(o => { o.RouteBasePath = "/profiler";// /profiler/results-index /profiler/results + o.ResultsAuthorize = o => { + return Configuration.GetAppSetting("Profiler", false) == true; + }; }).AddEntityFramework(); services.AddTransient(); services.AddTransient(); diff --git a/projects/Platform/appsettings.Development.json b/projects/Platform/appsettings.Development.json index 7d6a931f..883da92a 100644 --- a/projects/Platform/appsettings.Development.json +++ b/projects/Platform/appsettings.Development.json @@ -7,7 +7,9 @@ } }, "AppSettings": { - "Database": "SQLite" + "Database": "SQLite", + "JobDatabase": "SQLite", + "Profiler": true }, "ReverseProxy": { "Routes": [ diff --git a/projects/Platform/appsettings.json b/projects/Platform/appsettings.json index 4ff2d9ce..a947d8a8 100644 --- a/projects/Platform/appsettings.json +++ b/projects/Platform/appsettings.json @@ -18,6 +18,7 @@ "Log": "SQLite", "FileServer": "MinIO", "Cache": "Redis", + "Profiler": false, "sms": "url=https://api.netease.im/sms/sendcode.action;key=54ebdf1f4364ddd8ff6f82f88d630a76;secret=c49d42b67798@" }, "ConnectionStrings": {