hoover1980

C# in Dell Boomi? Yes

Discussion created by hoover1980 on Sep 6, 2017
Latest reply on May 24, 2018 by carl.evans603058

I'm working for about six weeks with Dell Boomi and coming from years of BizTalk, C#  and .Net development  is not without a pain. One of the things is not be able to use Visual Studio to build  and debug custom scripts. And if  you are like me and you just can't let go of Visual Studio and C# or any other .Net language, it is a struggle.
Don't get me wrong Java and Groovy are very capable languages and has some nice IDE's, but sometimes I just want my Visual Studio fix.

 

So I began to google a lot (Just like any developer these days) and found a way to use C++ in Dell Boomi. See this link for more info:https://app-community.boomi.com/community/knowledge-center/blog/2017/01/19/how-to-call-dll-functions-from-a-boomi-process-using-jna. My C++ knowledge is very basic, but is uses some trickery to make methods available for external use. Just follow the guidelines in the blog mentioned  above to set up a local Dell Boomi Atom to be able to use C++. If that bit works, you are almost able to use C#.

 

The main problem is that there is no standard way to make .Net methods available for external use by the JNA framework. But on NuGet there is a package that allows you to achieve this critical part very easily. This package is called UnmanagedExports. See this link for more info: https://www.nuget.org/packages/UnmanagedExports/

Now we have the tools we can begin to create a simple C# project. We will create a class library with some simple methods.

 

Now we have the tools we can begin to create a simple C# project. We will create a class library with some simple methods.

  1. Start up Visual Studio. In my case it is Visual Studio 2017 Pro. Others should work.
  2. Go to File - New - Project and create a new Class Library Project named Customer.
  3. Rename the class1.cs file to Customers.cs
  4. In the NuGet Package Magement Console, execute the following command: Install-Package UnmanagedExports -Version 1.2.7.
  5. The next part is to set the project to either x86 or x64 build. This is a crucial part to be able to make your methods external. Right click on the project in the Solution Explorer and click properties. Go to the Build tab and set Platfom target from Any CPU to x86.

    I haven't tried x64 because I have a x86 atom, but it should work in x64 mode.

    Close the properties screen.

  6.  Open the Customers.cs file.

     Replace the content with the following code and close the file.  (Customers Source is available as attachment)

     

  1. Build the project by right clicking on the project and click build.
  2. Go to the solution bin / debug folder in the explorer and you should find a Customers.dll.
  3. Copy this file to the Local Atom installation \userlib\script directory.
  4. Restart the local atom. Use either Boomi Atom Management or your local Task manager.
  5.  Create a new process in Dell Boomi and add a Data Process shape. Add a process Step of type Custom Scripting and edit the script. Add the following code.

     

    import com.sun.jna.win32.StdCallLibrary;

    import com.sun.jna.Native;

    import com.boomi.execution.ExecutionUtil;

     

    def logger = ExecutionUtil.getBaseLogger();

     

    interface ICustomers extends StdCallLibrary {

     

    void StartUp();

    void AddCustomer(int value);

    int GetCustomerByID(int id);

     

    }

      

    def ICustomers customers = (ICustomers) Native.loadLibrary("Customers", ICustomers.class);

     

    customers.StartUp();

    customers.AddCustomer(20);

    logger.info(customers.GetCustomerByID(1).toString());

    logger.info(customers.GetCustomerByID(2).toString());

    logger.info(customers.GetCustomerByID(20).toString());

  6. Press ok to close the Edit Data Process Script screen. It should look like this.
  7. Press ok to close the Data Process Shape screen. Your process should look like this.


    Don't forget to connect the arrows   .

  8. Save the process and test it with your local atom. If everything is done correctly, the process should end successfully.
  9. Go to Process - view log.
  10. In the log you should see some entries of the Custom script.

Evidence of our accomplishment . But there are some issues with it. For some reason it does not let me to use a constructor, so I've created a StartUp method to initialize the list to avoid the use of a constructor. More importantly is that the methods you want to expose MUST be STATIC. Also be sure that the namespace of you C# class you want to expose has the same name as the projectname. I ran into issues when I used other namespaces .

 

So here you have it. C# running from Dell Boomi. It's fairly simple to implement and to be able to use C# .Net and things like LINQ is very nice. 

Attachments

Outcomes