|
Navigation: IM Sequencer > Custom plugin development > Custom trigger plugin |
![]() ![]()
|
This section describes how you need to develop a "trigger plugin"
To create a trigger plugin you will need to reference the file Traxion.IM.Scheduler.dll and implement the following interface:Traxion.IM.Scheduler.Plugins.ICustomTriggerPlugin. This interface has one method that needs to be implemented.
| • | (Method) ShouldTrigger (DateTime) - This method is called when the triggers need to evaluate if it needs to trigger, if the triggers need to trigger is need to return "True" else "False" |
Below is an example trigger implementation:
using System;
using Traxion.IM.Library.Data;
using Traxion.IM.Library.Logging;
using Traxion.IM.Scheduler.Plugins;
namespace Traxion.CustomTriggers
{
[CustomPluginClassAttribute(Name = "Example", Description = "Example trigger implementation")]
public class TriggerExample : ICustomTriggerPlugin
{
// Create a logger for use in this class
private static readonly ApplicationLog log = ApplicationLogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
[NonSerialized]
SqlServerConnection connection = new SqlServerConnection();
public bool ShouldTrigger(DateTime now)
{
log.Trace("Start shouldtrigger");
bool shouldTrigger = true;
//Check if it is not a sunday or saturday
if (now.DayOfWeek == DayOfWeek.Sunday||
now.DayOfWeek == DayOfWeek.Saturday)
{
shouldTrigger = false;
}
log.Trace("Finished shouldtrigger return '{0}", shouldTrigger);
return shouldTrigger;
}
[CustomPluginAttribute(Secure = false, Name = "Example setting", Required = true, Description = "Example Setting", DefaultValue = "localhost")]
public string Example { get; set; }
[CustomPluginStateDataAttribute]
public String LastWaterMark { get; set; }
}
}
As you can see this triggers has a reference to the logging implementation and uses a "SQLServerConnection" these variables should be set to "[NonSerialized]" because they cannot be and do not need to serialize. If not decorated with this attribute the saving and loading for this custom trigger will fail.
The should trigger method in the above example will always trigger, only not on saturdays and sundays.
Page url: http://www.traxionsolutions.com/imsequencer/help/index.html?customtriggerdevelopment.htm