November Happy Hour will be moved to Thursday December 5th.

Class ScheduledPlugInAttribute

A plugin to have a scheduled job with a simple user interface in admin mode

Inheritance
System.Object
System.Attribute
ScheduledPlugInAttribute
Implements
System.Runtime.InteropServices._Attribute
Inherited Members
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo)
System.Attribute.GetCustomAttributes(System.Reflection.MemberInfo, System.Boolean)
System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type)
System.Attribute.IsDefined(System.Reflection.MemberInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.MemberInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.ParameterInfo, System.Boolean)
System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type)
System.Attribute.IsDefined(System.Reflection.ParameterInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.ParameterInfo, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.Module)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.IsDefined(System.Reflection.Module, System.Type)
System.Attribute.IsDefined(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.Module, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, System.Boolean)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly)
System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Boolean)
System.Attribute.IsDefined(System.Reflection.Assembly, System.Type)
System.Attribute.IsDefined(System.Reflection.Assembly, System.Type, System.Boolean)
System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type)
System.Attribute.GetCustomAttribute(System.Reflection.Assembly, System.Type, System.Boolean)
System.Attribute.Equals(System.Object)
System.Attribute.GetHashCode()
System.Attribute.IsDefaultAttribute()
System.Attribute.System.Runtime.InteropServices._Attribute.GetTypeInfoCount(System.UInt32)
System.Attribute.System.Runtime.InteropServices._Attribute.GetTypeInfo(System.UInt32, System.UInt32, System.IntPtr)
System.Attribute.System.Runtime.InteropServices._Attribute.GetIDsOfNames(System.Guid, System.IntPtr, System.UInt32, System.UInt32, System.IntPtr)
System.Attribute.System.Runtime.InteropServices._Attribute.Invoke(System.UInt32, System.Guid, System.UInt32, System.Int16, System.IntPtr, System.IntPtr, System.IntPtr, System.IntPtr)
System.Attribute.TypeId
System.Object.ToString()
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.PlugIn
Assembly: EPiServer.dll
Version: 11.20.7
Syntax
[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

GUID

Gets or sets the unique id for the corresponding ScheduledJob.

Declaration
public string GUID { get; set; }
Property Value
Type Description
System.String

The unique id of the ScheduledJob. Default value is null.

Remarks

Use GetGUID() to check if a value has been assigned.

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.

Restartable

Indicates if the Job is restartable. A restartable job restarts immediately if the job is aborted or not running.

Declaration
public bool Restartable { get; set; }
Property Value
Type Description
System.Boolean
Remarks

When an application controlled or uncontrolled getting server shutdown then jobs can be marked as aborted. When the application restarts, the jobs that are marked as restartable will be executed immediately if the LastExecutionAttempt has not exceeded the MaximumExecutionAttempts. Bacause a restartable job could started many times then it is important the job has capability to handle restart attempts.

Methods

AsyncStart()

Initialization method called by the plug-in system.

Declaration
[Obsolete("Scanning of scheduled jobs are done during an initialization module")]
public static Task AsyncStart()
Returns
Type Description
System.Threading.Tasks.Task

GetGUID()

Returns the nullable Guid for the corresponding property GUID.

Declaration
public Guid? GetGUID()
Returns
Type Description
System.Nullable<System.Guid>
Remarks

If the usage of the attribute has not set the GUID property this will not have any value.

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
System.Attribute.Match(System.Object)

Start()

Initialization method called by the plug-in system.

Declaration
[Obsolete("Scanning of scheduled jobs are done during an initialization module")]
public static void Start()

Implements

System.Runtime.InteropServices._Attribute

Extension Methods