📜 ⬆️ ⬇️

Only without hands! Robots that do not repeat user actions

This review article describes how to use RPA for business processes that include tasks that ordinary people do not know how to do, do not want, or it takes them a lot of time and requires special knowledge, such as working with FTP, databases or API.

Inclusion in the process of such actions brings its creation to the traditional programming and "scripts", with all the advantages and disadvantages of this approach.

Using the API, even in traditional tasks for robotization, can significantly increase the speed of their execution, increase reliability and sustainability, but at the same time removes us from the realization of the dream that business users themselves create and maintain their processes, clearly returning their development and support development teams.
')
When you can, and when you need to add to the process of action at a lower level, I will try to tell in this article. The first, the introductory part, contains general considerations, and the second - specific examples. Examples are given for the platform with which I am well acquainted (UiPath), so for those who prefer other tastes and colors of robots, please do not be offended in advance.



Pro and Contra robotization low


Why such robots are useful



Why are such robots harmful



When it is necessary and when it is not necessary to use programming in robots


Summarize the above as follows:

Programming is worth using if



Programming should not be used if





With what and how does it make sense to work through code?


Then I tried to give a few examples of working with the code, which, one way or another, I had to actually use when creating robots, which means they have a place in life. Naturally, the list is not exhaustive, but I hope it is illustrative.
The examples are all tested on the latest release versions of actions at the time of this writing.

Microsoft Office


It is not strange, one of the first candidates for work through the API is Microsoft Office. Yes, UiPath has excellent built-in functionality for working with Excel (even two types, one with files directly, the second through the application). There are opportunities to work with Word (package UiPath.Word.Activities , put through the package manager). But, for example, there are no standard actions to work with PowerPoint, but there is also Outlook or even Visio with Project, which are still quite actively used in large companies. With Office, you can quite successfully make the robot through the user interface, but in some cases it is not very convenient, since not all UI elements can be accessed directly and you have to play scales on the keyboard. For example, the action Type Into with the text k [tab] k [f10] JCDD (for the English version of Office) will open the chart data from a PowerPoint slide for editing in Excel. Such combinations work well, but they look like magic more than IDDKQD.
ProTip: You can expand the list of available selectors using Microsoft UI Automation (UIA) instead of Microsoft Active Accessibility (MSAA) , which is selected by default. Switch to it with the F4 button in the UI Explorer and see if there is a difference.
To work with office files, you can use third-party libraries, such as Xceed DocX or Spire libraries, such as Spire.Presentation . When working with third-party libraries, pay attention to the license, it may not always be suitable for your company (for example, iTextSharp for PDF is distributed free of charge on AGPL , and PDFSharp - on MIT ). This method is very convenient, since it can be used even if no Microsoft Office is installed on the machine, which means that it is great for Unattended robots running on virtual machines.

For complex work with office software comes to the aid Microsoft.Office.Interop . It allows us to perform actions within applications, manipulate data, etc. The features of working with Office.Interop can devote more than one article, the thing is ancient and fragile, but it is suitable for our purposes. In order for Interop to work, you need to add the appropriate assemblies to Imports.

Let me give you a couple of examples of what can be done using Office Interop:

Outlook


Outlook functionality is much broader than just working with mail, it’s a personal information manager, there’s a calendar, a notebook, and an address book, in general, a complete set. If with e-mail everything is usually possible to solve by direct access to the server, if it represents the IMAP / POP3 interfaces, then the rest of the information is much easier to get from Outlook itself. For this Interop fits perfectly.

Getting a list of calendar events
 Dim oApp As New Microsoft.Office.Interop.Outlook.Application Dim mapiNamespace As Microsoft.Office.Interop.Outlook.NameSpace Dim calendarFolder As Microsoft.Office.Interop.Outlook.MAPIFolder Dim calendarItems As Microsoft.Office.Interop.Outlook.Items mapiNamespace = oApp.GetNamespace("MAPI") calendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar) calendarItems = calendarFolder.Items calendarItems.IncludeRecurrences = True 


Powerpoint


With PowerPoint, you can not only create beautiful presentations, but also use it to process documents, such as commercial proposals or regular project reports. To do this, PowerPoint needs to show data from other sources, and, of course, the robot does an excellent job with this task. Most of the time when creating PowerPoint slides, it takes time to decorate them beautifully, so this can be done in advance, and substitute real data by copying template slides and replacing texts with them.
Microsoft.Office.Interop.Powerpoint and all other Interop assemblies can be found in the nuget.org repository.
Duplicate slide
Because Presentation is in System.Activities, and Application is in other Interop, you have to write the names of the classes completely. fileName and slideToCopy are arguments, string and number, respectively.

 Dim app As New Microsoft.Office.Interop.PowerPoint.Application Dim pres As Microsoft.Office.Interop.PowerPoint.Presentation Dim newSlide As Microsoft.Office.Interop.PowerPoint.Slide pres = app.Presentations.Open(fileName) newSlide = pres.Slides(slideToCopy).Duplicate()(1) 


Then through the Shapes collection containing all the elements of the slide, you can quickly update the necessary information on a new page.

Work in Word


Although Word Activities Pack activities implement the basic features of Word, they do not cover all the functionality of the Xceed DocX library on which they are built. The most common case is working with tables, but there are many other cases.

There are enough different examples in the project repository to understand where this or a similar library will be useful.

Web API (REST, SOAP)


REST / JSON is now probably the keynote in order to integrate with systems representing the API.

REST, SOAP, and JSON support is provided through the Web Activities Pack .
C REST is simple enough, as it should be: HTTP Request -> Deserialize JSON and now we already have a JObject with which we can do everything we want. In order to transfer the data to the web service there is a convenient parameter editor.

But for SOAP, the built-in functional, unfortunately, is limited, not all types of web services are supported, not all requests are correctly processed. If the service does not work for you, you have to use one of the many wrappers for the HttpClient, for example, SimpleSOAPClient or write your own (a variant of working with SOAP from C # ).

UPDATE 04/03/19: In version 2019.4, the beta of which is already available for download, the component is updated, improved and redone. So you can expect to see normal SOAP support very soon.

Work with FTP


Everything is simple here in UiPath, there is a ready-made set of actions for FTP included in Community Activities , although it should be noted that, starting with version 18.2 of the FTP Activities Pack, it is deprecated . But all the functionality is there, even SFTP is supported (the set is based on SSH.NET ), although, unfortunately, work with the client key is not finished.

.

Database


UiPath works with databases through the .NET Data Provider. For MS SQL and MS Access, everything is simple, for the rest, you need to configure ODBC, and if it is not already there, install the driver. Keep in mind that since, at the moment, the platform is 32-bit, then we need the driver to download the corresponding one and the ODBC data source should be started the same.

Below is an example for working with MySQL.

We configure connection to MySQL
Test MySQL remote database settings (driver from here ):

and connect to it from the action


Further work with a SQL-compatible database is fairly standard - we make queries, we get a DataTable.

SAP via BAPI


If your SAP gives you this opportunity, you can try to automate the integration with SAP through BAPI instead of working through the UI. As usual, the UiPath is ready for this.
A set of actions that includes the SAP Connection Setup Wizard. There is almost no programming here, but this is an example of the fact that the standard integration path is not the only possible one.

Finally


I hope that with the help of this article I was able to talk about those aspects of the use of robots, which are not so easy to learn at the Academy or at the Forum . I would be glad if someone could be interested in or help answer questions related to the development of robots.

Source: https://habr.com/ru/post/446092/


All Articles