38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
|
|
using Company.Domain.ContarctingPartyAgg;
|
|
using Company.Domain.InstitutionContractAgg;
|
|
using Hangfire;
|
|
|
|
namespace BackgroundInstitutionContract.Task.Jobs;
|
|
|
|
public class JobSchedulerRegistrator
|
|
{
|
|
private readonly IBackgroundJobClient _backgroundJobClient;
|
|
private readonly SmsReminder _smsReminder;
|
|
private readonly IInstitutionContractRepository _institutionContractRepository;
|
|
private static DateTime? _lastRunDebtReminder;
|
|
|
|
|
|
public JobSchedulerRegistrator(SmsReminder smsReminder, IBackgroundJobClient backgroundJobClient, IInstitutionContractRepository institutionContractRepository)
|
|
{
|
|
_smsReminder = smsReminder;
|
|
_backgroundJobClient = backgroundJobClient;
|
|
_institutionContractRepository = institutionContractRepository;
|
|
}
|
|
|
|
public void Register()
|
|
{
|
|
|
|
|
|
RecurringJob.AddOrUpdate(
|
|
"InstitutionContract.ReminderDebtSMS",
|
|
() => _institutionContractRepository.SendReminderSmsForBackgroundTask(),
|
|
"*/1 * * * *" // هر 1 دقیقه یکبار چک کن
|
|
);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} |