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 4 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 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

 

 

 

  • No labels