wet 1 year ago
commit 7825720d9d

@ -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<ISysCacheService>();
@ -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<Func<SysLogEx, bool>> expression = ex => ex.ExceptionTime < DateTime.Now.AddDays(-daysAgo);
@ -69,7 +72,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient
/// </summary>
/// <param name="timer"></param>
/// <param name="count"></param>
[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<ISysCacheService>();
@ -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<Func<SysLogOp, bool>> expression = ex => ex.OpTime < DateTime.Now.AddDays(-daysAgo);
@ -107,7 +112,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient
/// </summary>
/// <param name="timer"></param>
/// <param name="count"></param>
[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<ISysCacheService>();
@ -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<Func<SysLogVis, bool>> 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<ISqlSugarClient>(services);
var logRep = App.GetService<ISqlSugarClient>(services);
var sysCache = services.GetRequiredService<ISysCacheService>();
// 默认值
@ -252,7 +259,7 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient
{
var services = scope.ServiceProvider;
var logRep = App.GetService<ISqlSugarClient>(services);
logRep.Deleteable<T>(expression);
logRep.Deleteable<T>(expression).ExecuteCommand();
});
}
@ -288,10 +295,11 @@ public class LogJobWorker : ISpareTimeWorker, IDynamicApiController, ITransient
{
fi.Delete(true);
}
else {
else
{
TemporaryDirectories(it);
}
}
}
}

@ -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
}
}
}
Loading…
Cancel
Save