Custom Routes

In some cases you would want to write a custom route to do some specific manipulation with message data that might be easier that processing through Crossfire.

These are extensions to Crossfire and is written typically using C# code, and building a separate DLL.

First you can create a project with Visual Studio, and make sure you are at least using .NET 4.0 for the project.

Then you'll need to reference the Sandfield.Messaging.dll  file (which you will be required to request access to when navigating to this link), and any other files that you might need to use in the project. Remember to copy all of these and this new DLL to the Custom Route folder in the Engine folder. You will not be required to move the Sandfield.Messaging.dll into the Custom Route folder unless there are conflicts with the one currently in the Engine folder.

In the project create a public class and implement the IRouteMessage interface from Sandfield.Messaging. Below is an example of the code.

namespace Sandfield.MFT.EDI.Routes {     public class MyCustomRoute : IRouteMessage     {         public bool CustomMatch(Message message)         {              return true;         }          public bool CustomRoute(DeliveryTypeDetail FromDeliveryTypeDetail, Message message)         {              return true;         }     } } 

There are two methods that it will implement CustomMatch and CustomerRoute.

Custom Match

With this method you can determine if the message should be routed, by processing the message. If a custom match is used on a route the matched on the UI are all ignored.

A custom match should return true if it matched what you need. If it does not then return false to ensure that it does not route the message.

public bool CustomMatch(Messaging.Message message) {

        return true; } 

Custom Route 

With this method you can process the message and have any data returned for routing.

public bool CustomRoute(Messaging.DeliveryTypeDetail FromDeliveryTypeDetail, Messaging.Message message) {         //Create a new List of attachments to be sent back         List<Message.Attachment> attachments = new List<Message.Attachment>();          //Iterate through each attachment from the source message         for (int i = 0; i < message.Attachments.Length; i++)          {                 string fileContents = Encoding.UTF8.GetString(message.Attachments[i].Data);                 //Here you can do the work for each attachment from the source message         }         //Here you add attachments that you want to send back.          //You can send back an attachment for each of the original ones, or combine the result into one final attachment         Message.Attachment returnAttachment = new Message.Attachment(string.Format("OrderFile{0}", fileCounter + 1), Encoding.UTF8.GetBytes(sb.ToString()));         attachments.Add(returnAttachment);          //Set the original message attachments to the new attachments         message.Attachments = attachments.ToArray();         return true; } 

Configuration

To configure the transport, use the settings on the TransportRoute object.

Set the Custom assembly field to the full path where the DLL is located, typically in the Crossfire Engine folder.

Set the Custom class to the fully qualified name IE Sandfield.MFT.EDI.Routes.MyCustomRoute 

You will also have to select the Custom match and/or Custom route check-boxes, depending on what you have implemented