.NET Core Web API Solution Using UiPath (RPA) - Part One

Thebjective of this article series is to create .NET Core Web API solution using UiPath Studio, a RPA tool. At the end of this series will have ready to use .NET Core Web API solution including data & service layer. Main objective of this particular article is to create data layer and service layer for our API solution.

Once you have completed requirement gathering and you are ready this database structure. Just crate excel file for this database structure (PFA attached excel). If we go with our traditional approach then, using this excel file developer will start creating entity and then it’s services and so on.
 
In large project it will take time for developer to write all code for this, but we can do all this stuff using UiPath Sequence in few minutes only. We will read this excel file and using provided data, will create different Entity classes (.cs file) i.e. final output of this step will be two C# libraries in our solution.
 
So now guys you will be having some questions like
 

What is RPA?

 
RPA stands for Robotic Process Automation. Using RPA technology we can automate business processes. We can configure software as a robot to capture transactions, managing and scrapping data, triggering some responses based on different triggers (see article) and interacting with other application (desktop/web/app from citrix env) systems. Basically it allows us to automate some task which is getting performed by human across application and systems.
 
Benefits
  • Speed up the process
  • Increase throughput
  • Less human error
  • Cost-saving

What is UiPath Studio?

 
Software designed to automate business processes using RPA. In this tool we have number of activities to automate our process. It’s a desktop application currently fully supporting VB to create process (in near future tool will have full support to C# also). We can create process in sequence or in flowchart manner. 
 

What is Sequence?

 
Sequence is a one of the type of workflows from UiPath. It is executed as single block activity (because they do not use connectors) so suitable to linear processes, also easily go to one activity to another. They can be reused, as a standalone process or as part of a flowchart.
 
How to create C# library using UiPath? Answer is using Recording feature.
 
Recording
 
It’s a great feature of UiPath, it saves lot of time. It helps us to record whatever actions we perform on a window. These recorded actions can be modified so we can use it in other processes also. While recording all elements are highlighted so you can easily select your required element.
 
 
There are 5 types of recording, whatever type you select some actions are not recordable like,
  • Keyboard shortcuts
  • Modifier Keys
  • Right Click
  • Mouse hover
There are dedicated activities to add above actions our sequence.
 
We will be using Desktop recording for our process, because is suitable for all kind of desktop application and its multiple actions, as it generates partial selectors for each activity. Mostly used when you have to record more than one action.
 
Create Process in UiPath, default main sequence will be created but add new sequence “Create VS Project”.
 
 
We will take project name and location as input also from user, so add “Input Dialog” in Main sequence like, 
 
 
Then add “Create VS Project” sequence in after above “input dialog” by simply dragging it from left side menu. It will be added using “Invoke” activity, this activity is used to integrate sequence inside another sequence. 
 
 
These are arguments we need to pass to “Create VS Project”. Argument direction can be In/Out, In, Out which are self-explainer.
 
 
Before starts recording, open Visual Studio 2019 then in “Create VS Project” use Open Application,
 
 
In properties assign "C:\Program Files\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe" to “FileName”.
 
But robot can’t intuitively identify GUI/object on screen so we have to trained them to recognize it. For this purpose we can use “selector” property. It is a XML as string used to identify element on screen.
 
For ex: In above activity we are trying to open VS 2019, we have provided the file path to open but how robot can confirm, opened app is correct one. SO for this we need to click on “Indicate window on screen” and click on startup page of VS. UiPath will generate below string in “selector” property
 
<wnd app='devenv.exe' cls='HwndWrapper*' title='Microsoft Visual Studio' />
 
 
Or you can put the string directly if you can figure it out by userself.
 
Or you can use UI Explorer from top menu to identify element.
 
 
Once desktop recoding selected, following window opens, 
 
 
Click on Record button to record multiple activities at once and press ESC to exit automatic recording. If you want to record each action separately then use options next to record button and while recording if you want to skip some steps then you can pause it for 3 sec using “F2” key.
 
To record any activity move the mouse over that element, it will be highlighted then click on it to select. Highlighted element will look like below image, 
 
 
After selecting below click activity will be added and you can check in property what values are selected.
 
 
Next select “Class library(.NET Core)” project in VS and click next button, then it will look like below in UiPath Studio,
 
 
<wnd app='devenv.exe' cls='HwndWrapper*' title='Microsoft Visual Studio' />
 
will beassign to “selector” property. After next steps it will be like, 
 
 
Project called “App.Domain” will be created after executing above recording activities.
 
As you know Visual Studio take a time to create project, so before executing next step it’s always a good I idea to put “Delay”. If you want to add 30 sec delay then pass value like: “00:00:30”. 
 
 
Now we need to create “App.Service” project (C# library) inside the same solution and it will serve as service layer for us. We will do it using same recording feature.
 
For that first we have to right click Solution,
 
 
As right click is can’t be recorded, we can select which mouse button click we want to emulate, after in properties
 
 
Then just record next actions, 
 
 
And then we can reuse sequence which we create previously while adding “App.Domain”, simply copy paste that sequence and instead of “App.Domain” put “App.Services”.
Or you can simply assign a shortcut key to New Project window (see in screen shot I have used “ctrl+num2” which can be assigned from Tools=>Options=>Keyboard)
If you use above shortcut then instead of above activity use,
 
 
After this step you can add “Delay”, if needed. Once executed two projects will be created under one solution like
 
 
In next step we will see how to add entities and services files to these libraries.
 

Summary

 
We learn what RPA is and how we can use it to automate some processes. To move forward to our goal we learn how to record our different action on desktop using recording feature in UiPath. We have created C# library for data and service layer.
 
A small step towards automation.