Oiler Works
  • Home
    • My resume
    • Free premium
    • Privacy Policy
  • Portfolio
  • Blogs
    • Computing
    • Science & MBA
    • Gaveta de remédios
    • Canadá
    • Presentes

Robot process automation

25/4/2022

 
Robot process automation (RPA) using Microsoft Power Automate Desktop.
Picture
RPA1.mp4
File Size: 3260 kb
File Type: mp4
Download File

This robot uses the files names from a group of pdf files to fill in a search field to find a certain register on an intranet website.
The files are continuously been added by multiples scanner stations during the working hours.
The register is completed,  its respective file is uploaded, and the register is sent to the corresponding recipient,  depending on the data found.
Picture
RPA2.mp4
File Size: 5855 kb
File Type: mp4
Download File

This robot was used during an emergency where many registers were corrupted and lost. Starting from a list of numbers (about 2,500), the corresponding files were filtered from a huge backup (about 300,000). 
For each file, a register was searched on an intranet website, the file was uploaded to it, an other particular file was uploaded to every register, a form was filled in using numbers referring to that register, this form was digitally signed by two persons using theirs users and passwords, and the register was sent to the corresponding recipient.

/*
This is a javascript function used in the PAD 
to fill in and submit a login form.
I found it faster than using PAD tools.
I use a *atob* function to keep the user password
obfuscated in the PAD code. 
*/
function ExecuteScript() {
  document.querySelectorAll('input[Id="txtUsuario"]')[0].value="%SEIuser%";
  document.querySelectorAll('input[Id="pwdSenha"]')[0].value=atob("%SEIpw%");
  document.querySelectorAll('button[Id="sbmLogin"]')[0].click();
}

<# 
I found this powershell code faster
than PAD tools to filter a huge quantity of files (above 10,000)
#>
$a=[Datetime]::ParseExact('%agora%', 'yyyyMMdd HHmmss', $null);
Get-ChildItem -Path '%FolderSelected%' -Attributes !Directory -Recurse -Filter '*.pdf' | 
   Where-Object -FilterScript {
   ($_.LastWriteTime.ToUniversalTime() -le $a.ToUniversalTime()) -and 
   ($_.Directory -NotLike '*\Processados*') -and 
   ($_.Directory -NotLike '*\Incorretos*') -and 
   ($_.Directory -NotLike '*\_*') -and ($_.Name -NotLike '_*') }  |
   Sort-Object -Property CreationTime | 
   Select-Object -Property FullName -First %P['Limit']%

<#
I use an external binary (PDF Tools), automatically downloaded,
to get the number of pages in a PDF file 
#>

$CreationTime=(Get-Item("%file.FullName%")).CreationTime.ToString("yyyy-MM-dd HH:mm");
$FileOwner=((Get-ACL "%file.FullName%").Owner -replace '(.*\\)?(.+)','$2');

$pdftools='C:\Intel\pdftools.zip'
$pdfinfo='C:\Intel\pdfinfo.exe'
$file='%File.FullName%'
if (-not (Test-Path -Path $pdfinfo)) {
    if (-not (Test-Path -Path $pdftools)) {
    try {
        Invoke-WebRequest -Uri 'https://dl.xpdfreader.com/xpdf-tools-win-4.03.zip' -OutFile $pdftools
    }
    catch {
        echo "Não foi possível fazer o download da ferramenta de contagem de páginas. Abortando."
        pause
        exit
    }
    }
    Add-Type -AssemblyName System.IO.Compression.FileSystem
    $zip = [System.IO.Compression.ZipFile]::OpenRead($pdftools)
    $zip.Entries | 
      Where-Object { $_.Name -like "pdfinfo.exe" } |
        ForEach-Object { 
          $FileName = $_.Name
          [System.IO.Compression.ZipFileExtensions]::ExtractToFile($_, $pdfinfo, $true)
        }
    $zip.Dispose()
    try {Remove-Item $pdftools} catch{}
}

Write-Host -NoNewLine (C:\Intel\pdfinfo.exe "$file" | 
  Select-String -Pattern '(?<=Pages:\s*)\d+').Matches.Value


Comments are closed.

    Author

    About Me /\ Sur moi

    View Euler Alves's profile on LinkedIn
Powered by Create your own unique website with customizable templates.
  • Home
    • My resume
    • Free premium
    • Privacy Policy
  • Portfolio
  • Blogs
    • Computing
    • Science & MBA
    • Gaveta de remédios
    • Canadá
    • Presentes