Creating and deploying a custom Data Flow Item Class Library

This is the first post in a series focused on Data Flow development

Simply put, Class Libraries contains classes and methods that describe your business logic. Programs, such as Profitbase InVision, can execute class libraries after they have been compiled into assemblies (.dll) and linked to the program.

Development tools, such as Visual Studio, can be used to develop, compile and deploy class libraries as assemblies to Profitbase InVision, so that you can create and run your own business logic as part of your Solutions.

This post will walk you through the steps of creating your own class library, compile, deploy and link it to Profitbase InVision so it can be executed. We will write our code in C#, so you need at least basic knowledge of C# and the .NET library.

The Scenario

Our library will contain a function for writing a value to the database of a (fictitious external) system called InfoTraxx. In a later blog post, we’ll walk through executing this function from a Data Flow.

Install Visual Studio

The first thing you need to do, is install Visual Studio. If you do not have access to the pro versions of Visual Studio, you can use the free Visual Studio Community. It has all the features we require.

Creating a Class Library

  1. In Visual Studio, create a new Class Library project from File -> New -> Project (or press Ctrl + Shift + N)…
    Select Windows | Class Library. Lets call the project InfoTraxx.Databasevs_file_new_projnew_vs_proj_clslib
  2. Next, you’ll need to add a reference to Profitbase.AppFramework.Infinity.Core.dll. In the Solution Explorer, right-click References -> Add Reference, browse to the install folder of the InVision Worker Service and select the file.
    This assembly conains the core runtime types that enables your code to be discovered and executed by the Infinity Runtime.
  3. From the Solution Explorer, add a new Class and call it Messages. Add a ScriptClass attribute to the class.vs_add_class
  4. In the Messages class, add a public void method, AddMessage, which accepts a string. Add a ScriptMethod attribute to the method.

When you’re done, your Messages class should look like this

using Profitbase.AppFramework.Infinity.Runtime;
using System.Data.SqlClient;

namespace InfoTraxx.Database
    public class Messages
        public void AddMessage(string message)
            using (var sqlConnection = new SqlConnection("Data Source=mydbserver;Initial Catalog=InfoTraxxDB;Integrated Security=True"))
                using (var cmd = new SqlCommand("INSERT INTO Messages (Message) VALUES(@message)", sqlConnection))
                    cmd.Parameters.Add(new SqlParameter("@message", message));

Compile and Deploy

In order to make your functions discoverable to the Designer and executable by the Infinity Runtime (hosted by the InVision Worker Service process), you need to copy the assembly (.dll) to two folders and register them with the application.

Before you do anything, make sure you have at least Modify, Read and Write access to the designer website \bin folder and to the Worker Service install folder. (Right click the folder -> Properties ->Security -> Edit…)

  1. In the Solution Explorer, open the Project Properties.
    1. Go to Build Events
    2. Add the following Post-build event command line commands
      1. net stop <worker windows service name> (you get the service name by opening the properties window of the service)
      2. pushd “$(TargetDir)”
      3. xcopy InfoTraxx.Database.dll <path to worker service> /y
      4. xcopy InfoTraxx.Database.dll <path to designer website bin folder> /y
      5. popd
      6. net start <worker windows service name>
  2. Navigate to <designer website folder>\InVisionServices\Data and open DPDServiceConfig.Custom.xml for editing. (Make sure you have at least write and modify permissions).
  3. Add the following line to the ScriptAssemblyReferenceCatalog
    <ScriptAssemblyReferenceCatalogItem LibraryName=”InfoTraxx Database API” AssemblyFile=”InfoTraxx.Database.dll” Version=”1.0”/>

Copying the .dll to the Worker Service folder enables executing your code in Data Flows, because Data Flows are executed by the Worker Service.

Copying the .dll to Designer website and registering it enables you to use it as part of your Solution and configure the execution.

We’re done

Once you have everything set up, you can go ahead and build your project. If you have everything set up correctly, your code should be compiled into an assembly and copied to the two folders. Once that’s done, you can go to the Data Flow Item designer, add a reference to the assembly then create tasks using your classes and methods.

The next step

In our next post, we’ll create a Data Flow Item and use our InfoTraxx.Database class library to write a value to the database from a Data Flow.