How to develop a Scheduler library for DotNetNuke
1. Create a Visual Basic Class Library project, in project Properties, go to Application tab, and specify the Assembly Name (e.g. NWDS.TestScheduler) (we'll need this later), leave Root Namespace blank.
2. Add the following references:
3. Delete all the default files from the project
4. Create "Components" folder
5. Go to any of your module folders in App_Code, and copy DataProvider, SqlDataProvider, and Controller classes -- paste those into the "Components" folder from Step 4. Modify methods as necessary. Do not catch any exceptions in your Controller class, let them bubble up to your Scheduler class, and log them there - this will make Debugging a lot easier.
6. Create your business object (if you need one)
7. Add Scheduler class, that inherits from
Public Class Scheduler
Public Sub New(ByVal objScheduleHistoryItem As DotNetNuke.Services.Scheduling.ScheduleHistoryItem)
Me.ScheduleHistoryItem = objScheduleHistoryItem
Public Sub New()
Public Overrides Sub DoWork()
Me.ScheduleHistoryItem.Succeeded = True
'do work here
If SUCCESS Then
Catch exc As Exception
Me.ScheduleHistoryItem.Succeeded = False
Me.ScheduleHistoryItem.AddLogNote("EXCEPTION: " + exc.ToString)
8. Build the project, and move .dll file to the /bin folder of your DotNetNuke install
9. Login as Host into your DNN, and go to Host > Schedule
10. In "Add Item to Schedule" form, the most important field is "Full Class Name and Assembly", if your scheduler doesn't run -- chances are you've made a mistake here.
Full Class Name -- name of your Scheduler class (including Namespace), in this example that would be NWDS.TestScheduler.Scheduler
Assembly -- name of the assembly from Step 1, in this example that would be NWDS.TestScheduler
Here's how your Full Class Name and Assembly field should look like:
The rest is easy, enable the schedule by checking the "YES" box, specify the frequency (Time Lapse) (I set this to 1 minute when I test), set "Retain Schedule History" to 10 (for debugging), and click UPDATE.
Check schedule history to see if your scheduler works -- if the history is empty, check Step 10 :)
Hope this helps.