fix tenantId null 问题

This commit is contained in:
2024-03-08 17:07:07 +08:00
parent 23cc2588a3
commit 96ed9e04ef
2 changed files with 10 additions and 2 deletions

View File

@@ -10,17 +10,20 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Job
{
private readonly IDbContext _dbContext;
private readonly ILogger<CreateSyncServerDateTimeJob> _logger;
private readonly ISqlSugarOptionsService _sqlSugarOptionsService;
public CreateSyncServerDateTimeJob(IDbContext dbContext, ILogger<CreateSyncServerDateTimeJob> logger)
public CreateSyncServerDateTimeJob(IDbContext dbContext, ILogger<CreateSyncServerDateTimeJob> logger, ISqlSugarOptionsService sqlSugarOptionsService)
{
_dbContext = dbContext;
_logger = logger;
_sqlSugarOptionsService = sqlSugarOptionsService;
}
public async Task RunAsync()
{
_dbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
_sqlSugarOptionsService.IgnoreTenant = true;
try
{
var deviceUniqueNos = await _dbContext.Queryable<DeviceTaskEntity>()
@@ -60,6 +63,7 @@ namespace Dlhis.ScheduledTask.TaskAssignment.Job
}
finally
{
_sqlSugarOptionsService.IgnoreTenant = false;
_dbContext.Client.QueryFilter.Restore();
}
}