Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Custom Module with Scheduler - how?Custom Module with Scheduler - how?
Previous
 
Next
New Post
5/20/2007 8:57 AM
 

I've written a custom module (WAP) for 4.5.1 using the very helpful tutorial by adefwebserver: http://dotnetnuke.adefwebserver.com/DotNetNuke/tabid/195/Default.aspx

I now need to write a scheduler for this module and package it all together.

Are there any tutorials around for building and packaging a scheduler with a custom module? I've read the scheduler documentation but I'm not sure where I should build the class in my solution. Do I need to add the class to the Module solution, or add a new solution and build it separately?

Many thanks


Steve White
 
New Post
5/20/2007 3:07 PM
 

When I create scheduled tasks for a module I do it inside an independent class in the App_Code or Bin folder. Of course you need to include it in the module package.

 
New Post
5/21/2007 3:50 AM
 

Thanks for the reply. Do you have an idiot's guide on how to set the project up? I have VS2005 but am feeling a bit lost on how to even set up a project for a new scheduler within the dotnetnuke.sln.

Thanks agan.


Steve White
 
New Post
5/21/2007 8:11 AM
 

A scheduler class does not have to be in a separate assembly. It's fine to include it with your module. The easiest way to get going is to take the code of an existing scheduled item and modify it for your needs as I did below with the SearchEngineScheduler:

Namespace MyNamespace

    Public Class MyScheduler
        Inherits DotNetNuke.Services.Scheduling.SchedulerClient

        Public Sub New(ByVal objScheduleHistoryItem As DotNetNuke.Services.Scheduling.ScheduleHistoryItem)
            MyBase.new()
            Me.ScheduleHistoryItem = objScheduleHistoryItem
        End Sub

        Public Overrides Sub DoWork()
            Try
                ' Code to do something goes here

                ScheduleHistoryItem.Succeeded = True
                ScheduleHistoryItem.AddLogNote("Completed re-indexing content")
            Catch ex As Exception
                ScheduleHistoryItem.Succeeded = False
                ScheduleHistoryItem.AddLogNote("EXCEPTION: " & ex.Message)
                Errored(ex)
                LogException(ex)
            End Try
        End Sub

    End Class
End Namespace

Nik


Nik Kalyani
Co-founder
DotNetNuke Corporation
Blog | Twitter | FaceBook
 
New Post
5/21/2007 2:57 PM
 

Nik -

Much appreciated, thanks. I've set this up now in another class in my module:

Namespace TT.Modules.Emailer

    Public Class EmailerSchedule
        Inherits DotNetNuke.Services.Scheduling.SchedulerClient

        Public Sub New(ByVal objScheduleHistoryItem As DotNetNuke.Services.Scheduling.ScheduleHistoryItem)
            MyBase.new()
            Me.ScheduleHistoryItem = objScheduleHistoryItem
        End Sub

        Public Overrides Sub DoWork()
            Try
                ' Code to do something goes here
                SendEmail()
                Me.ScheduleHistoryItem.Succeeded = True
                Me.ScheduleHistoryItem.AddLogNote("Completed Emailer schedule")
            Catch ex As Exception
                Me.ScheduleHistoryItem.Succeeded = False
                Me.ScheduleHistoryItem.AddLogNote("EXCEPTION: " & ex.Message)
                Me.Errored(ex)
                LogException(ex)
            End Try
        End Sub

        Private Sub SendEmail()
            Me.Status = "Sending Email"
            ' do the job
            Me.Status = "Sent Email"
            Me.ScheduleHistoryItem.AddLogNote("Completed Emailer schedule")
            Me.ScheduleHistoryItem.Succeeded = True
        End Sub
    End Class

End Namespace

I added the Scheduler manually like this in Host > Schedule:

Full Class Name and Assembly: TT.Modules.Emailer.EmailerSchedule,TT.Modules.Emailer
Enabled: Yes
Time Elapsed: 2 Mins
Retry Frequency: 5 Mins
Retain Schedule History: All
Run on Event: None
Catch Up Enabled: Yes
Object Dependencies:
Run on Servers:

I edited web.config and set the schedule debug="true" as per the scheduler docs. This then added some stuff to events:

EVENT ADDED TO PROCESS GROUP 0: TT.Modules.Emailer.EmailerSchedule,TT.Modules.Emailer
SCHEDULE ID: 10
Server Name: MyBox

But, there is no schedule history. Where does Me.ScheduleHistoryItem.AddLogNote() write to?

I think this is very close now because it looks like I added it correctly, just nothing being logged.

Thanks again


Steve White
 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Custom Module with Scheduler - how?Custom Module with Scheduler - how?


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

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

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. 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.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out