Skip to end of metadata
Go to start of metadata

You are viewing an old version of this content. View the current version.

Compare with Current View Version History

« Previous Version 9 Next »

The Custom Code device allows you to use C# or Visual Basic code to write your own device within the constraints of Connexion. This is useful if, for example, you need more flexible transform options than those offered in the standard HL7 Transform device.

It is also possible to write your own device using C# or Visual Basic. This is different than using the Custom Code device. If any of the following conditions apply to your organization, you may want to write your own device. If you do decide to write a device, it is recommended that you first use the Custom Code device to create the required logic, and then move that logic to your own device.

Add a Custom Code device in the same way you would add any other device. Stop the channel, open it for editing, and choose Custom Code Device from the drop-down.

<screen shot>

Using the Custom Code window

If you select the Custom Code device in the channel, you can launch the Custom Code window.

<screen shot>

This window contains several components:

  • Code Editor: Use this window to write the custom code for the device (in either C# or Visual Basic)
  • Auto-run: Use this option to turn the auto-run feature on or off. When Auto-run is on, your code is run after every successful compile and the Input Message (as shown in the Input Message pane), will be transformed. If your ProcessMessage method contains long-running or expensive operations, you will most likely want this feature turned off.

When the auto-run feature is off, a new Run button is displayed. If your code is error-free, click this button to apply your code to the current Input Message.

  • Code language: toggle between C# and Visual Basic.

When you change the code language, any code you have written is replaced with boilerplate code. For that reason, it is important to choose your code language before starting.

  • Run Stop Method: runs the Stop() method.
  • References: maintains a list of references used by the device (see Using References below).
  • Service References:  maintains a list of web and service references (see Using Web and Service References below).
  • Resources: maintains a list of embedded resource files (see Using Resources below).
  • Code: maintains a list of code files (see Using code files below).
  • Transform status: displays the compile status and method calls (Start, Stop, ProcessMessage).
  • Input Message: If there are messages in the upstream Queue, you can view the messages in this pane by selecting one. Use the forward/back arrows to browse through the messages in the queue. You can also paste a message into this pane. This message is used as the source message for your transform.
  • Output Message: displays the resulting message after the transform is executed, and highlights any differences.
  • Debug Output Pane: displays the results of any Logger method calls (for example, Logger.DebugFormat(...)).
  • Compile Errors: displays any errors generated by the compiler.

Using Custom Code methods

The Custom Code device boiler-plate code provides the required CustomDevice class. It also provides three, empty, overridden methods:

  • Start: Called once when this device is started by the containing channel (channel started).
  • Stop: Called once when this device is stopped by the containing channel (channel stopped).
  • ProcessMessage: Called for every message received by this device. Your message logic should in this method.

Using References

The Custom Code Device allows the addition of local custom assemblies and .NET-framework assemblies. To add an assembly to your project, right click the References item and select Add Reference... A references window is opened showing a list of all assemblies registered in the GAC. You can either select a GAC-installed assembly from the list, or click the Browse button to point to a specific assembly file.

<screen shot>

The window contains the following:

  • Filter: Filter the GAC assemblies list.
  • Include: Check the checkbox beside the assembly you would like to include. Multiple assemblies can be selected before clicking OK.
  • Assembly Name: The GAC assembly name.
  • Version: The assembly version.

You may have multiple framework assembly versions listed. Be sure to choose the version that targets the .NET 4.5.1 framework.

  • Path: The path of the assembly file.
  • Browse: Click to open a specific assembly file.

It is your responsibility to include all dependent assemblies for each assembly you reference. Often the error "Metadata file 'ActiproSoftware.BarCode.Wpf351.dll' could not be found" indicates a missing required assembly. ® To remove a reference, right-click it in the list and select Remove Reference.

Using Web and Service References

You can also use references to a remote service (usually a SOAP service) in your Custom Code device. Right click the Service Reference item and select Add Service Reference. The Add Service Reference window will be displayed.

<screen shot>


  • No labels