Class ScheduledPlugInAttribute
A plugin to have a scheduled job with a simple user interface in admin mode
Implements
Inherited Members
Namespace: EPiServer.PlugIn
Assembly: EPiServer.dll
Version: 9.12.2Syntax
[AttributeUsage(AttributeTargets.Class)]
public class ScheduledPlugInAttribute : PlugInAttribute, _Attribute
Remarks
The class must implement a public static method with name "Execute", it will be called on the interval specified in administration mode. An optional return value can be specified for a descriptive text.
Important! If you change the class or namespace name the old scheduled job will still be active but without a settings page, you should manually delete this job from the database in table tblScheduledItem.
The property HelpFile can be set to link to a custom help page for the job.
Examples
A simple example of a scheduled class, the return type could be void if you don't want to
return a descriptive message. Throwing a exception will in this case show up as "FAILED" on the
history tab i admin mode.
[ScheduledPlugIn(DisplayName = "My job", Description = "This job is just a sample")]
public class MyJob
{
public static string Execute()
{
if (DateTime.Now.DayOfWeek == DayOfWeek.Sunday)
throw new Exception("I'm out of office");
else
return "I was here";
}
}
Constructors
ScheduledPlugInAttribute()
Declaration
public ScheduledPlugInAttribute()
Properties
HelpFile
The help page to display for job
Declaration
public string HelpFile { get; set; }
Property Value
Type | Description |
---|---|
System.String |
InitialTime
Gets or sets the initial time. The format should be parsable to an TimeSpan and will be added to System.DateTime.Today
Declaration
public string InitialTime { get; set; }
Property Value
Type | Description |
---|---|
System.String | The initial time. |
Remarks
It is only the time part that is used in combination with IntervalType and IntervalLength.
This setting will only be used the first time the scheduled job is initialized.
IntervalLength
Gets or sets the length of the interval. Used in combination with IntervalType and InitialTime to set default value.
Declaration
public int IntervalLength { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 | The length of the interval. |
Remarks
This setting will only be used the first time the scheduled job is initialized.
IntervalType
Gets or sets the type of the interval. Used in combination with IntervalLength and InitialTime to set default value.
Declaration
public ScheduledIntervalType IntervalType { get; set; }
Property Value
Type | Description |
---|---|
ScheduledIntervalType | The type of the interval. |
Remarks
This setting will only be used the first time the scheduled job is initialized.
Methods
AsyncStart()
Initialization method called by the plug-in system.
Declaration
public static Task AsyncStart()
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task |
Match(Object)
Matches the specified attribute against this attribute type.
Declaration
public override bool Match(object o)
Parameters
Type | Name | Description |
---|---|---|
System.Object | o | The object to match. |
Returns
Type | Description |
---|---|
System.Boolean | True if the object matches this attribute instance. |
Overrides
Start()
Initialization method called by the plug-in system.
Declaration
public static void Start()