Class ScheduledJobRepository
Get, list, save and delete scheduled jobs
Inheritance
Inherited Members
Namespace: EPiServer.DataAbstraction
Assembly: EPiServer.dll
Version: 8.11.0Syntax
[ServiceConfiguration]
public class ScheduledJobRepository
Remarks
The best way to create a custom scheduled job is to use the ScheduledPlugInAttribute as it will automatically generate a settings page in admin mode.
All dates exposed by ScheduledJob are in local time, but they will be saved to the database as UTC dates.
Examples
Example that demonstrates listing all available jobs.
Constructors
ScheduledJobRepository()
Declaration
public ScheduledJobRepository()
Methods
Delete(Guid)
Deletes a job by id
Declaration
public virtual void Delete(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id |
Get(Guid)
Get a job by id
Declaration
public virtual ScheduledJob Get(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | The id of the job |
Returns
Type | Description |
---|---|
ScheduledJob | The job, or null if not found |
Get(String, String, String)
Get a job by method, type name and assembly
Declaration
public virtual ScheduledJob Get(string method, string typeName, string assemblyName)
Parameters
Type | Name | Description |
---|---|---|
System.String | method | The method to call. |
System.String | typeName | Name of the class where method lives. |
System.String | assemblyName | Name of the assembly where the class is defined. |
Returns
Type | Description |
---|---|
ScheduledJob | A ScheduledJob instance if a matching job is found, otherwise null. |
GetNextScheduledJob()
Get the next job up for execution
Declaration
public virtual ScheduledJob GetNextScheduledJob()
Returns
Type | Description |
---|---|
ScheduledJob | A ScheduledJob instance if there is a waiting job, otherwise null. |
List()
Retrieves a list of all available jobs
Declaration
public virtual IEnumerable<ScheduledJob> List()
Returns
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<ScheduledJob> |
LoadLog(Guid)
Loads log information for the ScheduledJob.
Declaration
public virtual DataTable LoadLog(Guid id)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id |
Returns
Type | Description |
---|---|
System.Data.DataTable | A System.Data.DataTable containing log data where each row represents a log event. |
MarkForExecution(Guid, DateTime, TimeSpan)
Marks a job for execution
Declaration
public virtual bool MarkForExecution(Guid id, DateTime validateUtcDate, TimeSpan pingTime)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | The identity |
System.DateTime | validateUtcDate | The expected execution time that should be validated |
System.TimeSpan | pingTime | The expected ping time |
Returns
Type | Description |
---|---|
System.Boolean | True if the job was successfully marked for execution |
ReportExecutedJob(Guid, Boolean, String)
Report a job as executed
Declaration
public virtual void ReportExecutedJob(Guid id, bool success, string message)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | Job id |
System.Boolean | success | If the job executed successfully |
System.String | message | Message |
Save(ScheduledJob)
Saves job information or creates a new job
Declaration
public virtual void Save(ScheduledJob job)
Parameters
Type | Name | Description |
---|---|---|
ScheduledJob | job |
UpdateCurrentStatusMessage(Guid, String)
Update current status message
Declaration
public virtual void UpdateCurrentStatusMessage(Guid id, string message)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | The job id |
System.String | message | Status message |
UpdateRunningState(Guid, Boolean)
Update running state
Declaration
public virtual void UpdateRunningState(Guid id, bool isRunning)
Parameters
Type | Name | Description |
---|---|---|
System.Guid | id | Job id |
System.Boolean | isRunning | If job is running or not |
Events
ScheduledJobDeleted
Declaration
public static event EventHandler<EventArgs> ScheduledJobDeleted
Event Type
Type | Description |
---|---|
System.EventHandler<System.EventArgs> |
ScheduledJobSaved
Declaration
public static event EventHandler<EventArgs> ScheduledJobSaved
Event Type
Type | Description |
---|---|
System.EventHandler<System.EventArgs> |