Table of Contents

Class JobConfiguratorExtensions

Namespace
Quartz.Jobs
Assembly
Quartz.Jobs.dll

Configures a job from Quartz.Jobs with named options rather than with its job data keys.

public static class JobConfiguratorExtensions
Inheritance
JobConfiguratorExtensions
Inherited Members

Remarks

Each of these writes the same JobDataMap entries the job has always read, so the stored job is identical to one configured key by key and reads back the same on any version. What changes is the writing: the key cannot be misspelled, the value cannot be of the wrong type, and a setting the job supports cannot go missing from the documentation — the options type lists them.

They are generic in the configurator so that the call keeps its receiver's type: a JobBuilder<TJob> chain still ends in Build(), and the IJobConfigurator<TJob> handed to AddJob still chains its own members.

Methods

UsingDirectoryScanOptions<TConfigurator>(TConfigurator, DirectoryScanOptions)

Configures a DirectoryScanJob with the directories to scan, the pattern to match, whether to recurse, and how long a file must have settled.

public static TConfigurator UsingDirectoryScanOptions<TConfigurator>(this TConfigurator configurator, DirectoryScanOptions options) where TConfigurator : class, IJobConfigurator<DirectoryScanJob>

Parameters

configurator TConfigurator
options DirectoryScanOptions

Returns

TConfigurator

Type Parameters

TConfigurator

Examples

IJobDetail job = JobBuilder.Create<DirectoryScanJob>()
    .WithIdentity("inboxScan")
    .UsingDirectoryScanOptions(new DirectoryScanOptions
    {
        Directories = ["/var/spool/inbox"],
        SearchPattern = "*.csv",
        IncludeSubDirectories = true,
        ScanListenerName = nameof(InboxListener),
    })
    .Build();

UsingFileScanOptions<TConfigurator>(TConfigurator, FileScanOptions)

Configures a FileScanJob with the file to watch, the listener to tell, and how long the file must have settled.

public static TConfigurator UsingFileScanOptions<TConfigurator>(this TConfigurator configurator, FileScanOptions options) where TConfigurator : class, IJobConfigurator<FileScanJob>

Parameters

configurator TConfigurator
options FileScanOptions

Returns

TConfigurator

Type Parameters

TConfigurator

UsingNativeJobOptions<TConfigurator>(TConfigurator, NativeJobOptions)

Configures a NativeJob with the command to run and how to run it.

public static TConfigurator UsingNativeJobOptions<TConfigurator>(this TConfigurator configurator, NativeJobOptions options) where TConfigurator : class, IJobConfigurator<NativeJob>

Parameters

configurator TConfigurator
options NativeJobOptions

Returns

TConfigurator

Type Parameters

TConfigurator

Examples

IJobDetail job = JobBuilder.Create<NativeJob>()
    .WithIdentity("nightlyReport")
    .UsingNativeJobOptions(new NativeJobOptions
    {
        Command = "report.exe",
        Parameters = "--nightly",
        ConsumeStreams = true,
    })
    .Build();

UsingSendMailOptions<TConfigurator>(TConfigurator, SendMailOptions)

Configures a SendMailJob with the message to send and the server to send it through.

public static TConfigurator UsingSendMailOptions<TConfigurator>(this TConfigurator configurator, SendMailOptions options) where TConfigurator : class, IJobConfigurator<SendMailJob>

Parameters

configurator TConfigurator
options SendMailOptions

Returns

TConfigurator

Type Parameters

TConfigurator

Remarks

SendMailOptions has no credentials on purpose; register an ICredentialsByHost with the container instead of putting a password in job data.