Create the Custom Exception Handler AgileConnector

This topic gives an example of how to configure the runtime functionality for an example CustomExceptionHandler AgileConnector with the AgileConnector project template.

Good to Know

  • The AgileConnectorDaemon.cs file has different code for Event Listener Type and Polling Service Type of AgileConnector.
  • Signing an assembly for strong name is done when the AgileConnector project template generates code.
  • To download a sample AgileConnector for custom exception handling, refer to AgileConnector Sample for Custom Exception Handling.

How to Start

  1. Create a New AgileConnector Project in AgilePoint NX Developer.
  2. In the project folder Runtime, open the file AgileConnectorDaemon.cs.

Procedure

  1. In the AgileConnectorDaemon.cs file, replace the default class name MyAgileConnectorDaemon with CustomExceptionHandler.
    [IntegratedApplicationDescriptor(typeof(MyAgileConnectorDescriptor))]
    public class MyAgileConnectorDaemon : WFIntegratedApplication, IWFTrackingEventPublisher
  2. Replace this C# code in Publish method to handle the custom exceptions:
    public void Publish(IWFTrackingEvent evt)
    {
      try
      {
         IWFFaultingExceptionTrackingEvent fault = evt as IWFFaultingExceptionTrackingEvent;
         if (fault == null) return; // in case it is not IWFFaultingExceptionTrackingEvent
    
         DateTime dateOccured = fault.DateOccured;
         Exception e = fault.FaultingException;
    
         // release this object reference immediately when it is done.
         IWFProcessInstance pi = fault.ProcessInstance;
    
      }
      catch (Exception ex)
      {
         Logger.WriteLine("{0}: Error when processing event {1}. Error Message: {2}", 
                           base.AppName, evt.EventName, ex.Message);
      }
    }