You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you have Sitecron Jobs that use the "ExecuteExactlyAtDateTime", and that DateTimeUtc is set in the past, these jobs will trigger immediatelly whenever "InitializeScheduler" is executed, e.g. after application startup but also after every item.save of a Sitecron Job.
Possible scenarios:
when you have multiple sitecron jobs defined which you programmatically set the "ExecuteExactlyAtDateTime" (I want several jobs to run x minutes/hours/days after a certain event)
Item Package install (or TDS/Unicorn project) has a set of predefined Sitecron Jobs with "ExecuteExactlyAtDateTime" set in the past.
Every time you save a Sitecron Job, the scheduler reinitializes and all jobs with "ExecuteExactlyAtDateTime" in the past are triggered.
Imho ScheduleHelper.cs ln121 : the job should only be scheduled if the startDateTime is in the future:
`var startDateField = (DateField)i.Fields[SitecronConstants.FieldNames.ExecuteExactlyAtDateTime];
if (startDateField != null)
{
Log.Info(string.Format("Sitecron - Job Loaded - {0} using ExecuteExactlyAtDateTime: {1}", i.Name, i[SitecronConstants.FieldNames.ExecuteExactlyAtDateTime]), this);
DateTimeOffset startDateTime = new DateTimeOffset(startDateField.DateTime.ToUniversalTime());
if (startDateTime > DateTimeOffset.UtcNow)
{
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity(i.ID.ToString())
.StartAt(startDateTime)
.ForJob(jobDetail)
.Build();
scheduler.ScheduleJob(jobDetail, trigger);
}else{
Log.Info(string.Format("Sitecron - Job Not Loaded - ExecuteExactlyAtDateTime in the past: {0} ExecuteExactlyAtDateTime: {1} Cron Expression: {2}", i.Name, i[SitecronConstants.FieldNames.ExecuteExactlyAtDateTime], i[SitecronConstants.FieldNames.CronExpression]), this);
}
}`
The text was updated successfully, but these errors were encountered:
If you have Sitecron Jobs that use the "ExecuteExactlyAtDateTime", and that DateTimeUtc is set in the past, these jobs will trigger immediatelly whenever "InitializeScheduler" is executed, e.g. after application startup but also after every item.save of a Sitecron Job.
Possible scenarios:
Every time you save a Sitecron Job, the scheduler reinitializes and all jobs with "ExecuteExactlyAtDateTime" in the past are triggered.
Imho ScheduleHelper.cs ln121 : the job should only be scheduled if the startDateTime is in the future:
`var startDateField = (DateField)i.Fields[SitecronConstants.FieldNames.ExecuteExactlyAtDateTime];
if (startDateField != null)
{
Log.Info(string.Format("Sitecron - Job Loaded - {0} using ExecuteExactlyAtDateTime: {1}", i.Name, i[SitecronConstants.FieldNames.ExecuteExactlyAtDateTime]), this);
DateTimeOffset startDateTime = new DateTimeOffset(startDateField.DateTime.ToUniversalTime());
if (startDateTime > DateTimeOffset.UtcNow)
{
ITrigger trigger = TriggerBuilder.Create()
.WithIdentity(i.ID.ToString())
.StartAt(startDateTime)
.ForJob(jobDetail)
.Build();
scheduler.ScheduleJob(jobDetail, trigger);
}else{
Log.Info(string.Format("Sitecron - Job Not Loaded - ExecuteExactlyAtDateTime in the past: {0} ExecuteExactlyAtDateTime: {1} Cron Expression: {2}", i.Name, i[SitecronConstants.FieldNames.ExecuteExactlyAtDateTime], i[SitecronConstants.FieldNames.CronExpression]), this);
}
}`
The text was updated successfully, but these errors were encountered: