27 lines
714 B
C#
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));
|
|
}
|
|
}
|
|
}
|