diff --git a/Myshipping.Core/Job/LogJobWorker.cs b/Myshipping.Core/Job/LogJobWorker.cs index 5bfabaed..cc3b8e7a 100644 --- a/Myshipping.Core/Job/LogJobWorker.cs +++ b/Myshipping.Core/Job/LogJobWorker.cs @@ -13,6 +13,7 @@ using System.IO; using Furion.DynamicApiController; using Microsoft.AspNetCore.Mvc; using System.Threading.Tasks; +using Furion.Logging; namespace Myshipping.Core.Job; @@ -42,7 +43,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient } // 默认值 - var daysAgo = 15; + var daysAgo = 30; var sysCache = App.GetRequiredService(); @@ -53,10 +54,12 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient // 如果存在相关配置项 if (parameters != null && parameters.ContainsKey("daysAgo") && - string.IsNullOrEmpty(parameters["daysAgo"])) + !string.IsNullOrEmpty(parameters["daysAgo"])) daysAgo = int.Parse(parameters["daysAgo"]); } + Log.Information($"准备清理天{daysAgo}之前的日志LogEx"); + // 生成查询表达式 Expression> expression = ex => ex.ExceptionTime < DateTime.Now.AddDays(-daysAgo); @@ -69,7 +72,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient /// /// /// - [SpareTime("@midnight", "LogOpDeletionService", Description = "后台定期删除操作日志,配置项参数:{\"daysAgo\": 7},不填默认为7", + [SpareTime("@midnight", "LogOpDeletionService", Description = "后台定期删除操作日志,配置项参数:{\"daysAgo\": 30},不填默认为30", DoOnce = false, StartNow = true, ExecuteType = SpareTimeExecuteTypes.Serial)] public void DoDeleteLogOp(SpareTimer timer, long count) { @@ -80,7 +83,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient } // 默认值 - var daysAgo = 7; + var daysAgo = 30; var sysCache = App.GetRequiredService(); @@ -91,10 +94,12 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient // 如果存在相关配置项 if (parameters != null && parameters.ContainsKey("daysAgo") && - string.IsNullOrEmpty(parameters["daysAgo"])) + !string.IsNullOrEmpty(parameters["daysAgo"])) daysAgo = int.Parse(parameters["daysAgo"]); } + Log.Information($"准备清理天{daysAgo}之前的日志LogOp"); + // 生成查询表达式 Expression> expression = ex => ex.OpTime < DateTime.Now.AddDays(-daysAgo); @@ -107,7 +112,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient /// /// /// - [SpareTime("@midnight", "LogVisDeletionService", Description = "后台定期删除访问日志,配置项参数:{\"daysAgo\": 15},不填默认为15", + [SpareTime("@midnight", "LogVisDeletionService", Description = "后台定期删除访问日志,配置项参数:{\"daysAgo\": 30},不填默认为30", DoOnce = false, StartNow = true, ExecuteType = SpareTimeExecuteTypes.Serial)] public void DoDeleteLogVis(SpareTimer timer, long count) { @@ -118,7 +123,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient } // 默认值 - var daysAgo = 15; + var daysAgo = 30; var sysCache = App.GetRequiredService(); @@ -129,10 +134,12 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient // 如果存在相关配置项 if (parameters != null && parameters.ContainsKey("daysAgo") && - string.IsNullOrEmpty(parameters["daysAgo"])) + !string.IsNullOrEmpty(parameters["daysAgo"])) daysAgo = int.Parse(parameters["daysAgo"]); } + Log.Information($"准备清理天{daysAgo}之前的日志LogVis"); + // 生成查询表达式 Expression> expression = ex => ex.VisTime < DateTime.Now.AddDays(-daysAgo); @@ -204,7 +211,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient Scoped.Create((_, scope) => { var services = scope.ServiceProvider; - var logRep =App.GetService(services); + var logRep = App.GetService(services); var sysCache = services.GetRequiredService(); // 默认值 @@ -252,7 +259,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient { var services = scope.ServiceProvider; var logRep = App.GetService(services); - logRep.Deleteable(expression); + logRep.Deleteable(expression).ExecuteCommand(); }); } @@ -288,10 +295,11 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient { fi.Delete(true); } - else { + else + { TemporaryDirectories(it); } - + } } } diff --git a/Myshipping.Web.Entry/Properties/launchSettings.json b/Myshipping.Web.Entry/Properties/launchSettings.json index 73fa5ef9..0e72b226 100644 --- a/Myshipping.Web.Entry/Properties/launchSettings.json +++ b/Myshipping.Web.Entry/Properties/launchSettings.json @@ -13,7 +13,8 @@ "launchBrowser": true, "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" - } + }, + "nativeDebugging": true }, "Myshipping.Web.Entry": { "commandName": "Project", @@ -22,7 +23,8 @@ "ASPNETCORE_ENVIRONMENT": "Development" }, "applicationUrl": "http://localhost:5000", - "dotnetRunMessages": "true" + "dotnetRunMessages": "true", + "nativeDebugging": true } } } \ No newline at end of file