another technical blog...technically

Friday, April 14, 2017

A Blue Prism project with custom DLLs

Lately i worked a lot on Blue Prism, which is a RPA software which helps you deal with process automation.
One of the most interesting things about Blue Prism, is that you can use a lot of custom code in order to power up your solution.
For example i designed one of the solution our customers appreciated a lot simply mixing up some old school programming with brand new Blue Prism knowledge.

Let me show you context and architecture before dealing with tips and tricks.
Basically, we need to get some data from the legacy mainframe systems of the customer and we use BluePrism to deal with that using some scripting techniques.
Those data will be used to produce some documents that will be produced starting from some templates which contain some logic.
For example, in the document templates, we have some placeholder like

{FOREACH:PEOPLE}
- Name is {NAME} and surname is {SURNAME}
{/FOREACH:PEOPLE}

that will be translated in
Name is Luke and surname is Skywalker
Name is Anakin and surname is Skywalker
Name is Leila and surname is Organa

where PEOPLE is a Blue Prism collection, or other placeholders that enable a paragraph to be shown or not in some particular circumstances.
This kind of work is done using OpenXML together with Blue Prism using a basic three-tier architecture, if you're curious about, please have a look at this image below.
Why a three tier? Because we share the business logic layer between the application and the robot.
Like you can see in the image, we have an application which deals with a custom DB and is capable of getting data from Blue Prism elaboration in order to create a attended process.

What seems to be not so funny is the fact that BP 5.0.23 is that, even if you reference some DLL (and the code seems to compile) when you run the process, Blue Prism will not work correctly, so you'll need to put all the DLLs into the Blue Prism automate folder, this means you also have to put in that folder also the .config file which contains connection strings or other stuff. This package will be deployed to every robot that will work the process, or maybe could be a the robot itself to download needed DLLs using a configuration process.

What about data transfer between Blue Prism and C#/VB.Net code?
You always have to think about BP Data structure, so, if you have to read a object collection, you have to translate it into a DataTable, in order to read it from Blue Prism, so here's a bit of code to accomplish the task

31 comments:

  1. Hi,
    I have a problem using iTextSharp DLL with BluePrism. Even if I reference the DLL and code is compiled I still got error when I run process. Any advices? Thanks

    ReplyDelete
    Replies
    1. Hi Marcin, do you have more details about the error? Maybe we can try to work this out together

      Delete
    2. Hi Valerio, I got it running already. The thing was that I needed to copy iTextSharp.dll directly to Blue Prism Automate folder. When I was referencing it to my C:/ drive - blue prism just didn't see it.
      Maybe some bug. Thank you for response thou! Best Regards!

      Delete
    3. Hi Marcin, absolutely true, maybe i have to write it better in the blog post, i think lots of people are facing the same problem.

      Even if it seems you can reference DLL from everywere, the sad truth is that it seems that the only way is to put DLL in the BP root folder.

      The same if you want to create a DLL which use a DB, you have to put also the config file there.
      I think the maim problem here is that if you want to update DLL you have to plan it with a windows task or something else.

      Delete
    4. Hi Valerio,

      I have not found any code in this Blog to convert the Collection to Data Table. I am working on C# code to read data from collection to Data table and loop through it to read each column data into array.

      Delete
    5. Hi, the reason is that a BP Collection is a DataTable :) No conversion needed

      Delete
  2. But how can i call the dll from blueprism?

    ReplyDelete
  3. You just have to reference DLLs and use a code block with the correct namespace ;)

    ReplyDelete
  4. so it is like a wrapper in VBA in a codeblock in the code area?

    ReplyDelete
    Replies
    1. so i am not shure how or where to reference the dll im blue prism

      Delete
    2. Yea, basically when i have to build a very complex operation, i create a DLL via Visual Studio that deals with other DLLs.
      I expose just a business delegate with no-logic methods and wrap just the business method calls into che code block.

      Delete
    3. Hi Valerio, your blog is helpful regarding the dlls, thank you. I have a problem with accessing my dll's. As you suggested , I added one of my straight forward Visual Studio project dlls in the Blue Prism Automate folder and it worked fine. But I have a complex solution where Visual Studio project dll(A) refers to other dll(B)(project or automation tool dlls), ideally I imagine if (A) is placed in the Blue Prism Automate folder , it should work, but it did not. I even placed my (B) in the Automate folder.
      Any help appreciated :-)
      Error:
      Internal : Could not execute code stage because exception thrown by code stage: Could not load file or assembly 'AutomatedQA.TestComplete.CSConnectedApp, Version=5.0.0.0, Culture=neutral, PublicKeyToken=483cb98dc5760d9e' or one of its dependencies. The system cannot find the file specified.

      Delete
    4. Hi deepu, it seems this is the most common question on this blog post. Are you sure you put every DLL in the Automate folder?
      Just to be sure, check in the debug or release folder, take all the DLLs and copy all of them in the Automate folder.
      After that, you got to close and re-open BP.
      Let me know what happens

      Delete
    5. Hi Valerio, thanks for your suggestions, it worked. been trying to reply with the output but got delayed.
      Recently we had tried a similar exercise of executing tests within BP on a Virtual machine and have been facing similar kind of issues.
      So, I not only copied all the dlls but all the .cs files and the reference dlls to the BP Automate folder and it worked as expected.

      Delete
    6. Hi deepu, i'm very happy it worked but also not sure this is the right thing, it's not a good thing to copy also *.cs files.
      ASAP i will publish a blog post to guides you through this.
      Thank you for your comment.

      Delete
  5. ok. can you provide an example maybe? the Blue Prism docs are not really complete regarding this part.

    ReplyDelete
    Replies
    1. Read this, there is all you need to know: https://drive.google.com/open?id=0ByO-3MlOhSzFOVdLWFlteHlHZjQ

      Delete
    2. Again? Stop spam please

      "Hello There, This is one awesome blog. Much thanks again. Fantastic. I hope you can help, we have had a few instances where we have had iexplore program open in the background and the v worked is unable to close or access it therefore it is affecting our automation as it cannot open a new instance with it seeing one already open. Our IT team seems to think it must be being open by a user with higher access rights than the v worker but this is not the case as no one accesses the machine. How Iexplorer can implement? Has anyone had this happen to them? Thank you, Jannu, da Jennifa."

      Delete
  6. Hi,
    I have a problem of assembly not loaded when I'm trying to use custom dll. But it's works with any built-in dll's
    But this not problem with the dll.
    I have to make sure, is that any standards I have to follow to build a dll in order to use in blueprism.

    ReplyDelete
    Replies
    1. Hi Rajesh, thx for your comment.
      It depends from the error, could you please paste the error message?

      Delete
  7. Hi Valerio,

    Thank you for this tutorial, very insightful. In my case, have my 3rd party DLLs in the BP root folder and they are correctly referenced from my code stage. It runs successfully if the BP resource PC is started by BP IDE. However, when I start resource PC from CMD, same process terminates with a code stage compile error. Please assist

    ReplyDelete
    Replies
    1. Hi Victor, could you please provide me more details? Feel free to contact me via skype, I'm stucked at home with a broken shoulder :-) With a screen sharing session we will be faster

      Delete
    2. Hi Valerio,

      Sorry about that, I hope you get well soon. Kindly share your Skype ID.

      Delete
    3. You cam find me easily on Skype searching by name and surname :)

      Delete
  8. Hi, I am looking for a solution. I want to automatically select Protection information (Public/restricted/confidential) on MS word or excel or Outlook.
    My company is using Azure Protection Information to classify documents and email. I am looking for some solution so that BP will automatically select doc as confidential either while Creating new document or while Closing it.
    Please help, Quite Urgent.
    Thanks.

    ReplyDelete
  9. Hi Valerio, i am trying a zip a file using code stage. i have imported the .dll libraries with full path. But, i am getting compilation errors(;EXPECTED, invalid expression term ',') when i run the following code.

    ZipFile.CreateFromDirectory(Source Path,Destination Path);

    could help me in solving this

    ReplyDelete
    Replies
    1. Are you sure you're dealing with C# in your VBO?

      Delete
  10. If I do that in Dev environment... How can the doll be copied to Automate folder in PROD environment. Because, I don't have access to every VDI to paste the dll manually to Automate folder in all VDIs

    ReplyDelete
    Replies
    1. Hi I solved this building a script that, at every login, get DLLs with an admin account and then start BluePrism Resource PCs. Otherwise you can use reflection

      Delete
  11. Hi Valerio, I am in a little trouble while writing a code for outlook. I need to read emails present in sub-folder of a sub-folder which I am able to achieve through recursion in Visual Studio but in Blue Prism Code I am unable to write a function. I get"Type or namespace definition, or end-of-file expected" error. could you please help me with it?

    ReplyDelete
  12. Hi Ankita, you have to change the code a little bit in order to make it work in code activity. Could you please post the code of the activity so i can see what is about?

    ReplyDelete

Because of a lot of SPAM about courses, I need to moderate all comments here.
I ensure you that I will answer whenever possible (if you are not a spammer).

Me, myself and I

My Photo
I'm just another IT guy sharing his knowledge with all of you out there.
Wanna know more?