In some situations there is the need to reuse functionality that is already implemented in .Net or Java in an OutSystems application. A common situation is the need to use an advanced data structure (like a HashTable, Stack, Queue, Cirular Array, StringBuilder, Graph, Tree, XML Document, Etc.) or even a business spefic object that is already available in the .Net or Java frameworks or in a custom library (an external existing .dll or .jar library).
The goal of this HOWTO is to explain how a specific data structure already available in .Net can be used in an OutSystems application. The HOWTO will be based on a specific example in .Net (the Queue data structure), but the exact same pricinciples can be used in the Java stack and any other data structure.
In the screenshot below you can get and high-level picture of how a Queue class that is availalble at the .Net (or Java) framework can be wrapped in an OutSystems extension and then used in your OutSystems Service Studio visual flows.
In this HOWTO our goal is to use the functionality provided by the Queue class available in the .Net Framwork in our OutSystems application to manage strings.
Click here to download the StringQueue.zip file that contains the StringQueue.xif extension that will be created throughout the HOWTO and the StringQueue_Sample.oml file that uses and tests the StringQueue extension.
The Queue class is availlable in the System.Collections namespace (see the Queue class documention here). We want to be able to use the following members of the Queue class:
From a high-level perspective, we will have to do the following:
In this section I will show you the step by step instructions to create the QueueString OutSystems extension that makes use of the System.Collections.Queue class. In the attached StringQueue.zip file you have the StringQueue_Sample.xif extension that will be created in this section.
To create an OutSytems extension, start by opening the OutSystems Integration Studio at Start > Programs > OutSystems > Integration Studio. Name your extension StringQueue.
The CreateQueue action that will instantiate a Queue object. The CreateQueue action returns the reference to the created Queue object with the OutSystems object data type.
To edit the source code implementation of the CreateQueue action, press the Edit Source Code button in Integration Studio - this will open Microsoft Visual Studio. By opening the StringQueue.cs file, you can see that Integration Studio automatically generates the signature of your integration actions.
The C# implementation of your CreateQueue is extremely simple. All you have to do is find the MssQueueAction that was generate for you and write the C# line that invokes the System.Collections.Queue class constructor and assigns the result to the ssQueue output variable.
For each of the Queue class member that you want to use, create a corresponding OutSystems action. Each of these actions will receive the Queue object as an input parameter and the remaining necessary parameters.
In order to be able to use the actions that you just created in the StringQueue extension, you only have to push the 1-click-publish button. This will automatically compile you extension source code and make it available for OutSystems applications to use it.
In your eSpace, press Add/Remove References import all the actions made available by the StringQueue extension.
Whenever you use the StringQueue object, you have to first invoke the CreateQueue action that creates the Queue object - the output of the action is a reference to the object.
Whenever you invoke one of the Queue behavior actions (Enqueue, Dequeue, etc.), use the reference returned by the CreateQueueaction.