fix 删除日志try
This commit is contained in:
@@ -7,13 +7,17 @@ namespace Dlhis.ScheduledTask.CommonJobs;
|
|||||||
public class DelApiLogTaskJob
|
public class DelApiLogTaskJob
|
||||||
{
|
{
|
||||||
private readonly IDbContext _dbContext;
|
private readonly IDbContext _dbContext;
|
||||||
|
private readonly Logger<DelApiLogTaskJob> _logger;
|
||||||
|
|
||||||
public DelApiLogTaskJob(IDbContext dbContext)
|
public DelApiLogTaskJob(IDbContext dbContext, Logger<DelApiLogTaskJob> logger)
|
||||||
{
|
{
|
||||||
_dbContext = dbContext;
|
_dbContext = dbContext;
|
||||||
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task RunAsync()
|
public async Task RunAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
DateTime now = DateTime.Now;
|
DateTime now = DateTime.Now;
|
||||||
DateTime todayStart = now.Date;
|
DateTime todayStart = now.Date;
|
||||||
@@ -27,6 +31,12 @@ namespace Dlhis.ScheduledTask.CommonJobs;
|
|||||||
|
|
||||||
await _dbContext.ChangeDb("log").DeleteReallyAsync(logs);
|
await _dbContext.ChangeDb("log").DeleteReallyAsync(logs);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.LogError(ex, "删除日志异常:{message}", ex.Message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user