I'm trying to migrate an existing ABP project backed by Quartz.NET to Hangfire.
I have a recurring job and I need to get the scheduled fire time inside the job. Note that I do not need the real execution time, but rather the expected one. Let’s suppose that I have a recurring job scheduled for every Monday at 10:00 am; When the job runs I need to obtain a DateTime indicating the current Monday at 10 am.
Am I missing some PerformContext or JobData property?
public class TestJob : BackgroundJob<PerformContext>, ITransientDependency
{
private readonly IRepository<User, long> _usersRepository;
public TestJob(IRepository<User, long> usersRepository)
{
_usersRepository = usersRepository;
}
public override void Execute(PerformContext context)
{
var jobData = context.Connection.GetJobData(context.BackgroundJob.Id);
// How to get planned execution time for this job run?
}
}
If my recurring job was scheduled to run every hour and my server is down for 5 hours, I would need indeed to run all 5 missing runs, and for each of them I would expect to reference the right planned date time. Do you have any suggestions on how to accomplish this?
The same information can be found in Quartz under the IJobExecutionContext.ScheduledFireTimeUtc