Files
jinko.yikatong/Src/Dlhis.ScheduledTask/Common/Services/Implements/HangfireService.cs

27 lines
714 B
C#

using Dlhis.ScheduledTask.Common.Dto;
using Hangfire;
using Kurisu.AspNetCore.Utils;
namespace Dlhis.ScheduledTask.Common.Services.Implements;
public class HangfireService : IHangfireService
{
private readonly RedisCache _redisCache;
public HangfireService(RedisCache redisCache)
{
_redisCache = redisCache;
}
public async Task CreateSapPersonSyncBackgroundJobAsync(SapPersonNoRequest request)
{
var jobKey = $"hangfire:background:{request.Code}";
using var handler = await _redisCache.LockAsync(jobKey);
if (handler.Acquired)
{
BackgroundJob.Enqueue<IGainfoUpdateService>(x => x.TodoByCodeAsync(request.Code));
}
}
}