feat 数据敏感分配角色可见,切换基地,定时任务lock
This commit is contained in:
@@ -23,27 +23,21 @@ public abstract class BaseJob : IJob
|
||||
{
|
||||
using (var scope = _serviceProvider.CreateScope())
|
||||
{
|
||||
Logger = scope.ServiceProvider.GetService<ILogger<BaseJob>>();
|
||||
|
||||
var recurringJob = this.GetType().GetCustomAttribute<RecurringJobAttribute>()!;
|
||||
var key = recurringJob.UniqueJobKey;
|
||||
var name = recurringJob!.Name;
|
||||
|
||||
var redisCache = scope.ServiceProvider.GetService<RedisCache>();
|
||||
await using var handler = await redisCache.LockAsync($"scheduled:{key}");
|
||||
|
||||
var name = recurringJob.Name;
|
||||
|
||||
Logger = scope.ServiceProvider.GetService<ILogger<BaseJob>>();
|
||||
DbContext = scope.ServiceProvider.GetService<IDbContext>();
|
||||
DbContext.Client.QueryFilter.ClearAndBackup<ITenantId>();
|
||||
var sqlSugarOptionsService = scope.ServiceProvider.GetService<ISqlSugarOptionsService>();
|
||||
sqlSugarOptionsService.IgnoreTenant = true;
|
||||
|
||||
try
|
||||
{
|
||||
var redisCache = scope.ServiceProvider.GetService<RedisCache>();
|
||||
await using var handler = await redisCache.LockAsync($"Scheduled:{key}");
|
||||
if (handler.Acquired)
|
||||
{
|
||||
Logger.LogInformation("[{name}]开始执行...", name);
|
||||
|
||||
await RunAsync(scope.ServiceProvider);
|
||||
Logger.LogDebug("[{name}]开始执行...", name);
|
||||
await DbContext.IgnoreAsync<ITenantId>(async () => { await RunAsync(scope.ServiceProvider); });
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -53,8 +47,6 @@ public abstract class BaseJob : IJob
|
||||
finally
|
||||
{
|
||||
Logger.LogDebug("[{name}]执行结束...", name);
|
||||
DbContext.Client.QueryFilter.Restore();
|
||||
sqlSugarOptionsService.IgnoreTenant = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user