Here below the code of the DLL i will use, just two classes:
- Log Helper: write something in the event viewer (could be useful for bug hunting)
- Program: the typical entry point for every .NET console application
using System; using System.Diagnostics; namespace BP.ExternalDll.Example { public class LogHelper { private readonly string _log; private readonly string _source; public LogHelper(string source, string log) { _source = source; _log = log; } public void LogWarning(string message) { try { CreateEventSource(); EventLog.WriteEntry(_source, message, EventLogEntryType.Warning); } catch (Exception) { // ignored // If you're here, it means you cannot write on event registry } } private void CreateEventSource() { if (!EventLog.SourceExists(_source)) { EventLog.CreateEventSource(_source, _log); } } } }Program.cs
namespace BP.ExternalDll.Example { public class Program { public static void Log() { string currentDirectory = System.Environment.CurrentDirectory; LogHelper _helper = new LogHelper("BP.ExternalDll.Example", "Test library"); _helper.LogWarning(currentDirectory); } static void Main(string[] args) { Log(); } } }So, compile everything and place your brand new DLL in this folder: C:\Program Files\Blue Prism Limited\Blue Prism Automate .
Don't try to put the file in other folders in your PC or organize the BP folder with subfolders: it will not work and don't argue with me that BP offers this functionality, IT DOESN'T WORK.
I said: IT DOESN'T WORK |
In the code block you just have to write:
Program.Log()and you will start to find some new rows in your event viewer. It's clear that this is just a little example, you can complicate the things as you wish.
My advice is to create always a BusinessDelegate class that holds all the methods you want to expose and create a single VBO action for every method in the BP, this will enhance testability and maintenance. That's all folks!
How custom classes can be passed to other stages in Blueprism?
ReplyDeleteHi Anil, this is a good point.
DeleteI think you need to hide the class complexity and create a stateless helper to manipulate your classes.
BP should not be aware of classes.
Best regards