DNN Version: 9.0.1
Issue / Request
We are trying to run a task at a specific time every day (for example 5:00AM). The scheduler and the task run fine, but we are having an issue with the next runtime of the task.
It looks like the DNN process sets the next run time to start at the end time of the present task:
For example, if I have a job set to run every 24 hours, and if the task starts at 5AM and ends at 5:10AM, then the DNN process sets the next run time to start at 5:10AM the following day.
How can we make sure the job runs at 5:00 AM every day?
Use the following code in order to standardize the start times for subsequent tasks:
public override void DoWork()
//notification that the event is progressing
ScheduleHistoryItem taskToSynchronize= CBO.FillCollection<ScheduleHistoryItem>(DotNetNuke.Data.DataProvider.Instance().ExecuteReader("Synchronizetask", "Purge Log Buffer")).FirstOrDefault();
taskToSynchronize.NextStart = DateTime.Today.AddDays(5);
ScheduleHistoryItem.Succeeded = true; //REQUIRED
Stored Procedure should look like this:
SET ANSI_NULLS ON
SET QUOTED_IDENTIFIER ON
CREATE PROCEDURE SynchronizeTask
SELECT TOP 1 * FROM ScheduleHistory
WHERE ScheduleID = (SELECT TOP 1 ScheduleID FROM Schedule WHERE FriendlyName = @TaskName)
ORDER BY StartDate DESC