Rock Jobs - SparkDevNetwork/Rock GitHub Wiki

Rock is using the open source Quartz.NET job scheduling system for handling longer running, recurring tasks (Job). Although Quartz is complex and feature rich, you only need to know a few things to create a Job for Rock.

NOTE: For shorter running, simple tasks, you can use Transactions.

Writing a Rock Job

To create a custom Rock Job you only need to extend the IJob interface and implement the Execute() method. You can also use [BlockProperty] to hold administrator configured settings/values for your job.

using Quartz;

[BlockProperty( 0, "My Property", "MyProperty", "General",
    "This would be the description of this property.", false, "100", "Rock", "Rock.Field.Types.Integer" )]

public class MyCustomJob : IJob
{
    public virtual void Execute( IJobExecutionContext context )
    {
        // get the stored configuration property
        JobDataMap dataMap = context.JobDetail.JobDataMap;
        int someNumber = Int32.Parse( dataMap.GetString( "MyProperty" ) );

        // TODO: your code that does something interesting
    }
}