Building Nodes with the Flowgear SDK
Flowgear Nodes are the building blocks of an integration. The Flowgear Nodes Test Harness makes it easy for developers to build and debug Nodes.
You will need
- Visual Studio 2015/2017/2019 (Run as Administrator)
- Install a DropPoint on your development machine (requires Flowgear DropPoint v4.3 or later)
Creating a Project
- Create a Class Library project in Visual Studio targeting .NET Framework 4.6.1. or later. This will be the assembly that contains your Node (or Nodes).
- Create a second Console Application project in the same solution, it also needs to target .NET Framework 4.6.1.
- Reference the Class library project in your Console Application project
- In your Class Library project, add a nuget reference to
Flowgear.Sdk
. To do this, locate the Package Manager Console in Visual Studio and enter the commandinstall-package Flowgear.Sdk
- In your Console Application project, add a nuget reference to
Flowgear.Nodes.TestHarness
using the commandinstall-package Flowgear.Nodes.TestHarness
- Sign both projects. (You do not need to use your production certificate. Signing the projects up-front ensures that they can only reference signed assemblies).
- Add a 16x16 PNG to the Class Library, this will be the icon used to represent your Node. Set the
Build Action
toEmbedded Resource
- Create the structure of your Node using the template shown below
- In your Console Application, add the harness loader code shown below
- Set the Console Application to be the Startup Project for the Solution and launch the project
- In the Flowgear Console, open or add a Workflow. Click the + button on the Design Canvas to add an object and tap
Debug a Node
. - Tap the DropPoint that is running on the development machine
- Flowgear will add the Node to the Design Canvas. If you make changes to the Node (eg. add properties, implement optional methods, etc), you can update the Node UI by tapping Node settings (cog button) and choosing
Upgrade Node
- Run the Workflow to invoke the Node.
- You can also create and test Connections (if your Node defines a Connection) by tapping the Connection property and clicking the + button
Harness Loader Code
Place the Harness reference code in the Main method of your C# Console Application project.
Example Node Class
Place the Custom Node reference code in its own class in a C# Console Application
See the Node code sample or see the complete sample Node
Creating Static Samples
Static samples are pre-generated and can be selected without a Connection on the Node.
- Create an XML file that confirms to the Node Sample Schema.
- When providing values for the Properties on the Node, you can either provide a text value in the
Value
attribute or if the value is a document or large string, point to a file in a sub-folder with a relative path by using theValueFile
attribute. - For XML properties, you can also optionally supply a schema file by providing a value for the
SchemaFile
attribute. If you don't provide a schema for an XML property, Flowgear will infer a schema for you. - Run your Node via the Test Harness, add it to a Workflow as described above and then click
Settings
(cog icon) andChoose Samples
on the Node. - All samples will be immediately syntactically validated.
Creating Dynamic Samples
Dynamic samples cause the ListSamples
method to be invoked in the Node thereby allowing samples to be generated that are specific to the endpoint instance defined in the Connection. For details of how to implement this, refer to the ListSamples
method in the Node code sample.
Implementing support for OAuth2
Flowgear Nodes allow you to implement support for OAuth2 directly. Refer to the Interact
and refreshToken
methods in the Node code sample methods for further details.
Publishing Your Node
- In the Console, click Nodes and then click the
+
icon to upload a Node. - Select the Account you would like to publish the Node from and then point to a Zip archive of the binaries for the Node (typically, the contents of the bin\Release folder should be zipped).
- Tick the
Make this Node Public checkbox
if you would like the Node to be reviewed and published to all users on approval. If this is left unchecked, the Node will only be available for your use. - Once a Node has been uploaded, you can access it from the Nodes Pane where you will see an
Owned
label against the Node. Click the Node for more information and to upload Samples and save Node Configurations - To upload samples, create a Zip archive of the contents of your samples folder including any referenced files. Click
Upload Samples
and point to the archive. Once it's uploaded, clickSubmit
- To change Node Configuration, modify the content of the
Configuration
textbox and clickSave Configuration
.
Troubleshooting
Unable to connect to Test Harness
Ensure that you have selected the correct DropPoint and that your Visual Studio project is running on the same machine as the DropPoint. It may also be necessary to run Visual Studio as Administrator (if you don't do this, it may not be able to establish a connection to the DropPoint service).
Request for the permission of type ... failed
Nodes are not permitted to perform certain actions within the Flowgear Cloud environment. Set the appropriate RunFrom value in the Node attribute on your class. All permissions except RunFrom.DropPointUnrestrictedOnly will apply sandbox permissions similar to those of our Cloud environment so that you are able to identify any potential security issues during debugging.
To identify the source of this exception in your Node, check the Common Language Runtime Exceptions checkbox under the Exceptions pane in Visual Studio. In your own code, ensure you are not attempting to access resources such as the File System, Registry, Environment variables and are not calling functions in the System.Reflection namespace.
If the permission exception is triggered by a third party library that you are referencing, review the source code of the library. If the source code is not available, use ILDASM, ILSpy or .NET Reflector to review the source code.
If it is not possible to avoid violating the permission requirement, you can still publish your Node but it will only execute when routed through a DropPoint.