Flowgear Nodes are the building blocks of an integration. The Flowgear Nodes Test Harness makes it easy for developers to build and debug Nodes.

If you need help along the way, use the Feedback/Support link in the Console to get in touch!


Screencasts

Part 1: Creating a Node and Live-Debugging it

Part 2: Creating Samples & Publishing Nodes

You will need

  • Visual Studio 2015 (Run as Administrator)
  • Install a DropPoint on your development machine (requires Flowgear DropPoint v4.3 or later)

Creating a Project

  1. Create a Class Library project in Visual Studio targeting .NET Framework 4.5.1. This will be the assembly that contains your Node (or Nodes).
  2. Create a second Console Application project in the same solution, it also needs to target .NET Framework 4.5.1.
  3. Reference the Class library project in your Console Application project
  4. 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 command install-package Flowgear.Sdk
  5. In your Console Application project, add a nuget reference to Flowgear.Nodes.TestHarness using the command install-package Flowgear.Nodes.TestHarness
  6. 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).
  7. Add a 16x16 PNG to the Class Library, this will be the icon used to represent your Node. Set the Build Action to Embedded Resource
  8. Create the structure of your Node using the template shown below
  9. In your Console Application, add the harness loader code shown below
  10. Set the Console Application to be the Startup Project for the Solution and launch the project
  11. 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.
  12. Tap the DropPoint that is running on the development machine
  13. 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
  14. Run the Workflow to invoke the Node.
  15. You can also create and test Connections (if your Node defines a Connection) by tapping the Connection property and clicking the + button

Creating Samples

  1. Create an XML file that confirms to the Node Sample Schema.
  2. 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 the ValueFile attribute.
  3. 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.
  4. Run your Node via the Test Harness, add it to a Workflow as described above and then click Settings (cog icon) and Choose Samples on the Node.
  5. All samples will be immediately syntactically validated.

Publishing Your Node

  1. In the Console, click Nodes and then click the + icon to upload a Node.
  2. 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).
  3. 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.
  4. Once a Node has been uploaded, you can access it from the Nodes screen where you will see and Owned label next to it. Click the Node for more information and to upload Samples and save Node Configurations.
  5. 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, click Submit.
  6. To change Node Configuration, modify the content of the Configuration textbox and click Save Configuration.

Harness Loader Code

Place this code in the Main entry point in your Console Application project.


            string path = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
 
            var samplePath = Path.Combine(path, "..\\..\\samples");
 
            var configPath = Path.Combine(path, "..\\..\\configuration.xml");
 
            Flowgear.Nodes.TestHarness.NodesTestHarness.AttachNode(
                typeof(DemoNode.DemoNode), // provides the Type for the Node being debugged
                File.ReadAllText( configPath), // provides user-defined config data that the Node can use. This data is never shown to end-users
                samplePath); // provides the path to sample files
 
            Console.ReadKey();

An Example Node Class

This example shows a complete Node structure including all supported attributes.


using flowgear.Sdk;
using System.Collections.Generic;
 
namespace DemoNode
{
    // Connections are defined in their own class
    public class Connection
    {
        // Connection properties must also be decorated with the Property attribute
        [Property(ExtendedType.None)]
        public string Username { get; set; }
 
        // Hide sensitive information by marking a property as a Password
        [Property(ExtendedType.Password)]
        public string Password { get; set; }
 
    }
 
    // Enums are presented as Dropdowns in the UI
    public enum Actions
    {
        ThisAction,
        ThatAction
    }
 
    // The Node property is what defines a Node. Your class should be public
    // as should any Properties and Methods that Flowgear will need to interact with
    [Node("DemoNode", "Demo Node", NodeType.Connector, "icon.png", RunFrom.Anywhere)]
    public class DemoNode
    {
        // Properties on the Node should have a FlowDirection and optionally an extended type
        // All properties MUST have getters and setters
        [Property(FlowDirection.Input, ExtendedType.ConnectionProfile)]
        public Connection Connection { get; set; }
 
        /// <summary>
        /// Use a triple slash comment on your properties to document them. This comment
        /// will be surfaced in the Design Canvas
        /// </summary>
        [Property(FlowDirection.Input)]
        public Actions Action { get; set; }
 
        // You can specify a default value for a Property with the DefaultValue attribute
        [DefaultValue("<thexml />")]
        [Property(FlowDirection.Input, ExtendedType.Xml)]
        public string InputXml { get; set; }
 
        [Property(FlowDirection.Output, ExtendedType.Xml)]
        public string OutputXml { get; set; }
 
        // You can opt in to supporting custom properties with the CustomProperties attribute
        [CustomProperties(true,true)]
        public Dictionary<string, object> Properties { get; set; }
 
        // You can opt into receiving configuration data with the Configuration attribute
        [Configuration]
        public Dictionary<string, object> Configuration { get; set; }
 
        // You must have a public method marked with the Invoke attribute. This is where your Node will do its processing
        [Invoke]
        // If you want to add multiple execution outputs, you can define them with the InvokeResult attribue
        [InvokeResult("Iterating", true, false)]
        [InvokeResult("Finished", true, false)]
 
        public InvokeResult Invoke()
        {
            // In the Invoke method, you can read all of your properties and configuration
            // You should return an InvokeResult (with no params) or an InvokeResult with the 
            // name of the label you want to fire
 
            // It's important to note that the a single instance of a Node on a Workflow is 
            // instanced once for the lifetime of the Workflow. This means that if your workflow
            // calls the Node multiple times (eg. downstream from a trigger or a looped Node like
            // Splitter or Loop, your Node Invoke method will be called multiple times
 
            // Don't catch exceptions - letting them bubble out to the consumer
            // enables Flowgear to present them to the user.
            // Flowgear will also record all inner exceptions internally for you
            return new InvokeResult("Finished");
 
        }
 
        // You can opt into supporting Connection testing with the Test Attribute. If the test
        // is successful, simply return. If a problem occurs, throw an exception
        [Test]
        public void Test()
        {
 
        }
 
        // You can opt into receiving exit requests with the ShouldExit notification. If your
        // Node is a trigger or may run for a long time and has the ability to execute gracefully
        // you can monitor the value of ShouldExit from within your Invoke method.
        [ShouldExit]
        public bool ShouldExit { get; set; }
 
        // If your Node needs to do cleanup like freeing objects or closing off sessions, implement it here
        [Terminate]
        public void Terminate()
        {
        }
    }
}
© 2010 - 2016 Flowgear