DNN Forums

Ask questions about your website to get help learning DNN and help resolve issues.

Update Scheduler

 2 Replies
 2 Subscribed to this topic
 12 Subscribed to this forum
Sort:
Author
Messages
New Around Here
Posts: 1
New Around Here

    Hi,
    I'm automatically updateing a SchedulerHistory item after a custom scheduler has been issued.
    I want to do this to set the next start time based on when the scheduler was created.
    As it is by default, if I manually run the scheduler it just adds the frequency.
    So for example, if I have it scheduled to run at 4AM every day but then I manually run it at 8:30AM the next start time will be 8:30AM the next day and not 4AM.
    So what I'm doing is to calculate the next start time based on the ScheduleStartDate.
    This all works perfectly and I can update the SchedulerHistory item with the following code.

    schHistInfo.NextStart = startDate
    SchedulingController.UpdateScheduleHistory(schHistInfo)
    SchedulingController.ReloadSchedule() ' Not sure what this does?

    I can see that my custom calculated [ScheduleHistory].[NextStart] has been updated in the database.
    However, the issue is that it is not reflected under Settings - Scheduler.
    Even if I do a Settings - Server - Clear Cache it is not updated in the Scheduler.
    I also tried DotNetNuke.Common.Utilities.DataCache.ClearPortalCache(portalID, False) but to no vail.
    The only way I can get Scheduler to reflect my newly set NextStart is to cycle the application pool, which of course isn't an option.

    So does anyone have any ideas how to get an updated NextStart issued through the API to get reflected in the scheduler?

    Cheers
    Mikael

    Veteran Member
    Posts: 545
    Veteran Member
      how are you updating the value?
      you should perform this using DNN API, not directly in the database.
      Senior Member
      Posts: 1393
      Senior Member
        Posted By mikaelldnn on 10 Dec 2020 09:35 AM


        This all works perfectly and I can update the SchedulerHistory item with the following code.

        schHistInfo.NextStart = startDate
        SchedulingController.UpdateScheduleHistory(schHistInfo)
        SchedulingController.ReloadSchedule() ' Not sure what this does?

        @Sebastian:  It looks like he is indeed using the API and not a direct database call already.

        @Mikael:  I think this mostly looks correct, but if you're using DNN 9.2+ it should be altered a bit.  

        First, create an instance of the schedule item from the API, then update just the properties you need.  Finally, call the method below.  

        SchedulingProvider.Instance().UpdateScheduleWithoutExecution(updatedItem);

        These Forums are dedicated to the discussion of DNN Platform.

        For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

        1. If you have (suspected) security issues, please DO NOT post them in the forums but instead follow the official DNN security policy
        2. No Advertising. This includes the promotion of commercial and non-commercial products or services which are not directly related to DNN.
        3. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
        4. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
        5. No Flaming or Trolling.
        6. No Profanity, Racism, or Prejudice.
        7. Site Moderators have the final word on approving / removing a thread or post or comment.
        8. English language posting only, please.

        Would you like to help us?

        Awesome! Simply post in the forums using the link below and we'll get you started.

        Get Involved