Navigation:  IM Sequencer > Custom plugin development >

Custom trigger plugin

Previous pageReturn to chapter overviewNext page

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 System.ComponentModel;

using Traxion.IM.Library.Data;

using Traxion.IM.Library.Logging;

using Traxion.IM.Library.UIControls;

using Traxion.IM.Scheduler.Plugins.Rules;

 

namespace Traxion.IM.Scheduler.Plugins.Custom

{

[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);

 

  public TriggerExample()

  {

    Example = "localhost";

    ShouldTest = true;

  }

 

  [NonSerialized]

  SqlServerConnection connection = new SqlServerConnection();

 

  public bool ShouldTrigger(DateTime now)

  {

    log.Trace("Start shouldtrigger");

 

    //Check if it is not a sunday or saturday

    bool shouldTrigger = !(now.DayOfWeek == DayOfWeek.Sunday || now.DayOfWeek == DayOfWeek.Saturday);

 

    log.TraceFormat("Finished shouldtrigger return '{0}", shouldTrigger);

    return shouldTrigger;

  }

 

  [Browsable(false)]

  public string DoNotDisplayMe { get; set; }

 

  [Category("General"), DisplayName("Example setting"), Description("This is the example description"), DefaultValue("localhost")]

  [RequiredRule]

  public string Example { get; set; }

 

  [Category("General"), DisplayName("Should test"), Description("Set to 'Yes' to start the test"), DefaultValue(true)]

  [TypeConverter(typeof(YesNoConverter))]

  public bool ShouldTest { get; set; }

 

  [CustomPluginStateDataAttribute]

  [Browsable(false)]

  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 decorated with"[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.

 

Below you can see the interface IM Sequencer generates for this plugin based on the attributes defined above each property

 
 

 


Page url: http://www.traxionsolutions.com/imsequencer/help/index.html?customtriggerdevelopment.htm