Estoy empezando ahora¶
Si estás empezando ahora con BotCity o quieres tener una idea general de cómo se pueden reportar los elementos procesados en el código del proceso, simplemente sigue la guía a continuación:
Utilizando el SDK de Orquestador para reportar datos¶
Puedes reportar fácilmente la información sobre los elementos que han sido procesados utilizando el SDK de Orquestador en el código de tu automatización.
Instalación del SDK¶
Si aún no tienes la dependencia instalada, simplemente sigue estas instrucciones:
Importante
Además de instalarlo, recuerda incluir la dependencia en el archivo requirements.txt del robot.
<repositories>
    <repository>
        <id>nexus-botcity-public</id>
        <url>https://devtools.botcity.dev:8081/repository/botcity-public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
<dependencies>
    <!-- Your other dependencies -->
    <dependency>
        <groupId>dev.botcity</groupId>
        <artifactId>maestro-sdk</artifactId>
        <version>2.2.0</version>
    </dependency>
</dependencies>
Importando el SDK¶
Después de la instalación, simplemente importa la dependencia e instancia el Maestro SDK:
# Importing the Maestro SDK dependency
from botcity.maestro import *
# Disabling errors if there is no connection with the Orquestador
BotMaestroSDK.RAISE_NOT_CONNECTED = False
# Instantiating the Maestro SDK
maestro = BotMaestroSDK.from_sys_args()
# Getting the details of the current task being executed
execution = maestro.get_execution()
// Import for integration with BotCity Maestro SDK
using Dev.BotCity;
using Dev.BotCity.MaestroSdk.Model.Execution;
// Instantiating the Maestro SDK
BotMaestroSDK maestro = BotMaestroSDK.FromSysArgs();
// Fetching the details of the current task being executed
Execution execution = await maestro.GetExecutionAsync(maestro.GetTaskId());
Reportando los datos del proceso¶
Al final de la ejecución, es posible reportar en la finalización de la tarea la información sobre los elementos que han sido procesados.
Código completo¶
from botcity.core import DesktopBot
from botcity.maestro import *
# Disabling errors if there is no connection with the Orquestador
BotMaestroSDK.RAISE_NOT_CONNECTED = False
def main():
    maestro = BotMaestroSDK.from_sys_args()
    execution = maestro.get_execution()
    # Implementing here the logic to process the items
    bot = DesktopBot()
    # The items can be any entity related to your automation process
    items = []
    processed_items = 0
    failed_items = 0
    # You can use the logic that is necessary to consume, process, and count the items
    for item in items:
        try:
            # Process the item...
            # Counting as an item processed successfully
            processed_items+=1
        except Exception:
            # Counting as an item processed with failure
            failed_items+=1
    # At the end, simply report the data of the processed items when finishing the task
    maestro.finish_task(
        task_id=execution.task_id,
        status=AutomationTaskFinishStatus.SUCCESS,
        message="Task Finished OK.",
        total_items=len(items), # Total number of items processed
        processed_items=processed_items, # Number of items processed successfully
        failed_items=failed_items # Number of items processed with failure
    )
def not_found(label):
    print(f"Element not found: {label}")
if __name__ == '__main__':
    main()
import java.util.List;
import java.util.ArrayList;
import dev.botcity.framework.bot.DesktopBot;
import dev.botcity.maestro_sdk.BotExecutor;
import dev.botcity.maestro_sdk.BotMaestroSDK;
import dev.botcity.maestro_sdk.model.AutomationTask.FinishStatus;
import dev.botcity.maestro_sdk.runner.BotExecution;
import dev.botcity.maestro_sdk.runner.RunnableAgent;
public class FirstBot extends DesktopBot implements RunnableAgent
{
    public FirstBot() {
        try {
            setResourceClassLoader(this.getClass().getClassLoader());
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    @Override
    public void action(BotExecution botExecution) {
        try {
            BotMaestroSDK maestro = new BotMaestroSDK();
            maestro.login(botExecution);
            // The items can be any entity related to your automation process
            List<Object> items = new ArrayList<Object>();
            int processedItems = 0;
            int failedItems = 0;
            // You can use the logic that is necessary to consume, process, and count the items
            for(Object item : items){
                try{
                    // Process the item...
                    // Counting as an item processed successfully
                    processedItems+=1;
                }
                catch(Exception e){
                    // Counting as an item processed with failure
                    failedItems+=1;
                }
            }
            // At the end, simply report the data of the processed items when finishing the task
            maestro.finishTask(
                botExecution.getTaskId(),
                "Task Finished OK.",
                FinishStatus.SUCCESS,
                items.size(), // Total number of items processed
                processedItems, // Number of items processed successfully
                failedItems // Number of items processed with failure
            );
        } catch(Exception e) {
            e.printStackTrace();
        }
    }
    private void notFound(String label) {
        System.out.println("Element not found: "+label);
    }
    public static void main(String[] args) {
        BotExecutor.run(new FirstBot(), args);
    }
}
using Dev.BotCity.MaestroSdk.Model.AutomationTask;
using Dev.BotCity.MaestroSdk.Model.Execution;
using System;
using System.Threading.Tasks;
namespace FirstBot
{
    class Program
    {
        static async Task Main(string[] args)
        {
            BotMaestroSDK maestro = BotMaestroSDK.FromSysArgs();
            Execution execution = await maestro.GetExecutionAsync(maestro.GetTaskId());
            Console.WriteLine("Task ID is: " + execution.TaskId);
            Console.WriteLine("Task Parameters are: " + string.Join(", ", execution.Parameters));
            // The items can be any entity related to your automation process
            string[] items;
            int processedItems = 0;
            int failedItems = 0;
            // You can use the logic that is necessary to consume, process, and count the items
            foreach (string item in items) 
            {
                try {
                    // Process the item...
                    // Counting as an item processed successfully
                    processedItems+=1;
                } catch (Exception ex) {
                    // Counting as an item processed with failure
                    failedItems+=1;
                }
            }
            // At the end, simply report the data of the processed items when finishing the task
            await maestro.FinishTaskAsync(
                execution.TaskId,
                FinishStatusEnum.SUCCESS,
                "Task Finished OK.",
                items.Length, // Total number of items processed
                processedItems, // Number of items processed successfully
                failedItems // Number of items processed with failure
            );
        }
    }
}
Consejo
No es obligatorio utilizar una estructura de código específica en tu proceso de automatización.
Tienes total libertad para definir la lógica que se utilizará y también la forma en que se contabilizarán los elementos.
Al final, simplemente reporta estos datos utilizando el método finish_task del Maestro SDK.