Roboter
2023.4
False
Bannerhintergrundbild
Roboter-Benutzerhandbuch
Letzte Aktualisierung 3. Apr. 2024

SDK-Spezifikationen

Methoden und Eigenschaften

Sie können die folgenden Methoden und Eigenschaften in Ihre benutzerdefinierte Anwendung oder Webseite aufnehmen.

Init

Die init-Methode ist optional. Sie gibt die IRobotSDK-Instanz zurück, mit der Sie sie als Variable für die spätere Verwendung speichern können.
const robot = UiPathRobot.init();const robot = UiPathRobot.init();

Einstellungen

Mit der Eigenschaft settings vom Typ Einstellungen können Sie die Standardportnummer und das Abfrageintervall in Millisekunden ändern oder das Senden von Telemetriedaten deaktivieren.
const robot = UiPathRobot.init();
robot.settings.portNumber = 1234;
robot.settings.pollTimeInterval = 1000;
robot.settings.disableTelemetry = true;const robot = UiPathRobot.init();
robot.settings.portNumber = 1234;
robot.settings.pollTimeInterval = 1000;
robot.settings.disableTelemetry = true;

Auf

Die Methode on wird verwendet, um Ereignishandler an das SDK anzufügen.
Die verfügbaren SDK-Ereignisse sind consent-prompt und missing-components .

fehlende-Komponenten

Das Ereignis missing-components wird ausgelöst, wenn der Robot JS-Dienst nicht ausgeführt wird. In diesem Fall zeigt das SDK einen Fehler an, der mit einem benutzerdefinierten Handler überschrieben werden kann.
const robot = UiPathRobot.init();
robot.on('missing-components', () => console.log('Missing Components'));const robot = UiPathRobot.init();
robot.on('missing-components', () => console.log('Missing Components'));

Prozesse erhalten (Get Processes)

Die getProcesses -Methode ruft die Liste der verfügbaren Prozesse ab. Gibt eine Zusage an ein Array von RobotProcess- Objekten zurück. Wenn der Roboter mit dem Orchestrator verbunden ist, ruft er die Prozesse aus der Umgebung und dem Ordner ab, zu dem der Roboter gehört. Andernfalls werden lokale Prozesse abgerufen.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
for(let i=0; i<processes.length; i++){
    console.log(processes[i].name + " (" + processes[i].description + ") - Id=" + processes[i].id);
}const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
for(let i=0; i<processes.length; i++){
    console.log(processes[i].name + " (" + processes[i].description + ") - Id=" + processes[i].id);
}

Schema für Eingabeargumente abrufen

Mit der Eigenschaft „inputArgumentsSchema“ eines installierten Prozesses können Sie die Eingabeargumente eines Prozesses abrufen. Bevor Sie die Eigenschaft inputArgumentsSchema verwenden, müssen Sie zuerst den Prozess installieren.
Die Methode installProcess installiert einen Prozess und gibt eine Zusage an ein Objekt vom Typ InstallProcessResult zurück, das einen Array von InputArgumentSchema-Objekten enthält.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const installedProcess = await robot.installProcess(processes[0].id);
for(let i=0; i<installedProcess.inputArgumentsSchema.length; i++){
    console.log("Argument " + i + ":");
    console.log("  name: " + installedProcess.inputArgumentsSchema[i].name)
    console.log("  type: " + installedProcess.inputArgumentsSchema[i].type)
    console.log("  isRequired: " + installedProcess.inputArgumentsSchema[i].isRequired)
    console.log("  hasDefault: " + installedProcess.inputArgumentsSchema[i].hasDefault)
}const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const installedProcess = await robot.installProcess(processes[0].id);
for(let i=0; i<installedProcess.inputArgumentsSchema.length; i++){
    console.log("Argument " + i + ":");
    console.log("  name: " + installedProcess.inputArgumentsSchema[i].name)
    console.log("  type: " + installedProcess.inputArgumentsSchema[i].type)
    console.log("  isRequired: " + installedProcess.inputArgumentsSchema[i].isRequired)
    console.log("  hasDefault: " + installedProcess.inputArgumentsSchema[i].hasDefault)
}
Hinweis: In TypeScript kann die Methode install eines RobotProcess-Objekts verwendet werden, um einen Prozess zu installieren.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const installedProcess = await myProcess.install();const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const installedProcess = await myProcess.install();

Job starten (Start Job)

Die Methode startJob empfängt eine bereits erstellte Job und startet diese. Sie gibt eine Zusage an ein Objekt vom Typ JobResult zurück, das die Ausgabeargumente enthält.
Die Methode createJob erstellt einen Roboterauftrag mit der Prozess-ID. Kann optional die Auftragseingabeargumente empfangen. Sie gibt ein Auftragsobjekt zurück.
Hinweis: Ab v2022.10 wird die Prozessliste parallel zur Prozessausführung aktualisiert, davor wurde die Prozessliste aktualisiert, bevor der Prozess gestartet wurde. Das bedeutet, dass beim Ausführen eines Prozesses, für den ein Update verfügbar ist, der Auftrag möglicherweise mit der älteren Version des Prozesses ausgeführt wird.
robot = UiPathRobot.init();
processes = await robot.getProcesses();
const calculatorProcess = processes.find(p => p.name.includes('Calculator'));
const arguments = {
    "input1" : 23,
    "input2" : 42,
    "operation" : "add"
};
const job = robot.createJob(calculatorProcess.id, arguments);
const result = await robot.startJob(job);
console.log(result.Sum);robot = UiPathRobot.init();
processes = await robot.getProcesses();
const calculatorProcess = processes.find(p => p.name.includes('Calculator'));
const arguments = {
    "input1" : 23,
    "input2" : 42,
    "operation" : "add"
};
const job = robot.createJob(calculatorProcess.id, arguments);
const result = await robot.startJob(job);
console.log(result.Sum);
Hinweis: In TypeScript kann ein Auftrag mithilfe des Auftragsklassenkonstruktors erstellt werden.
robot = UiPathRobot.init();
processes = await robot.getProcesses();
const calculatorProcess = processes.find(p => p.name.includes('Calculator'));
const arguments = {
    "input1" : 23,
    "input2" : 42,
    "operation" : "add"
};
const job = new Job(calculatorProcess.id, arguments);
const result = await robot.startJob(job);
console.log(result.Sum);robot = UiPathRobot.init();
processes = await robot.getProcesses();
const calculatorProcess = processes.find(p => p.name.includes('Calculator'));
const arguments = {
    "input1" : 23,
    "input2" : 42,
    "operation" : "add"
};
const job = new Job(calculatorProcess.id, arguments);
const result = await robot.startJob(job);
console.log(result.Sum);

Auftrag auf

Die Methode on des Job -Objekts wird verwendet, um Ereignishandler an den Auftrag anzufügen. Die verfügbaren Ereignisse sind status und workflow-event .

Status

Das Ereignis status wird während der Auftragsausführung jedes Mal ausgelöst, wenn sich der Status des Auftrags geändert hat.

Dieses Ereignis wird auch jedes Mal ausgelöst, wenn die Aktivität ReportStatus ausgeführt wird.

const robot = UiPathRobot.init();
const job = robot.createJob('processId');
job.on('status', robotStatus => console.log(robotStatus));
await robot.startJob(job);const robot = UiPathRobot.init();
const job = robot.createJob('processId');
job.on('status', robotStatus => console.log(robotStatus));
await robot.startJob(job);

Workflow-Ereignis

Das Ereignis workflow-event wird während der Auftragsausführung jedes Mal ausgelöst, wenn eine Aktivität ausgeführt wird, die ein Workflowereignis sendet. Es ist die Unterstützung für die Implementierung von Teilergebnissen mithilfe der Aktivität Send Interim Results . Der Event Handler hat ein Argument vom Typ WorkflowEventData.
const robot = UiPathRobot.init();
const job = robot.createJob('processId');
job.on('workflow-event', e => console.log(e.name));
await robot.startJob(job);const robot = UiPathRobot.init();
const job = robot.createJob('processId');
job.on('workflow-event', e => console.log(e.name));
await robot.startJob(job);

Prozess starten (Start Process)

Die Methode start des Objekts RobotProcess wird verwendet, um einen Prozess zu starten, indem ihm Eingabeargumente übergeben werden, falls verfügbar.

Es gibt ein Objekt vom Typ JobPromise zurück.

const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const arguments = {
    "a" : 41,
    "b" " 27
};
const result = await myProcess.start(arguments);const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const arguments = {
    "a" : 41,
    "b" " 27
};
const result = await myProcess.start(arguments);

Status „Prozess ein“

Die Methode onStatus wird verwendet, um einen Ereignishandler an das Statusereignis des Auftrags anzufügen.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start().onStatus(status => console.log(status));const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start().onStatus(status => console.log(status));

Prozess bei Workflowereignis

Die Methode onWorkflowEvent wird verwendet, um einen Ereignishandler an das Ereignis „workflow-event“ des Auftrags anzufügen.
const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start().onWorkflowEvent(e => console.log(e.name));const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start().onWorkflowEvent(e => console.log(e.name));

Prozess anhalten (Stop Process)

Die Methode stopProcess wird verwendet, um einen ausgeführten Roboterprozess zu stoppen.

Es gibt eine Zusage zurück, die bei erfolgreichem Abbrechen des laufenden Roboterprozesses aufgelöst wird.

const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start();
await robot.stopProcess(myProcess);const robot = UiPathRobot.init();
const processes = await robot.getProcesses();
const myProcess = processes.find(p => p.name === "MyProcess");
const result = await myProcess.start();
await robot.stopProcess(myProcess);

Modelldefinitionen

IRobotSDK

interface IRobotSDK {
    settings: Settings;
    getProcesses(): Promise<Array<RobotProcess>>;
    init(): IRobotSDK;
    on(eventName: string, callback: (argument?: any) => void): void;
    startJob(job: Job): Promise<JobResult>;
    stopProcess(process: RobotProcess): Promise<void>;
    installProcess(processId: string): Promise<InstallProcessResult>;
}interface IRobotSDK {
    settings: Settings;
    getProcesses(): Promise<Array<RobotProcess>>;
    init(): IRobotSDK;
    on(eventName: string, callback: (argument?: any) => void): void;
    startJob(job: Job): Promise<JobResult>;
    stopProcess(process: RobotProcess): Promise<void>;
    installProcess(processId: string): Promise<InstallProcessResult>;
}

Einstellungen

class Settings {
    portNumber: number;
    pollTimeInterval: number;
    disableTelemetry: boolean;
}class Settings {
    portNumber: number;
    pollTimeInterval: number;
    disableTelemetry: boolean;
}

RobotProcess

class RobotProcess {
    id: string;
    name: string;
    description?: string;
    start: (inArguments?: any) => JobPromise;
    install: () => Promise<InstallProcessResult>;
}class RobotProcess {
    id: string;
    name: string;
    description?: string;
    start: (inArguments?: any) => JobPromise;
    install: () => Promise<InstallProcessResult>;
}

InstallProcessResult

class InstallProcessResult {
    inputArgumentsSchema: InputArgumentSchema[]
}class InstallProcessResult {
    inputArgumentsSchema: InputArgumentSchema[]
}

EingabeArgumentSchema

class InputArgumentSchema {
    name: string;
    type: string;
    isRequired: boolean;
    hasDefault: boolean;
}class InputArgumentSchema {
    name: string;
    type: string;
    isRequired: boolean;
    hasDefault: boolean;
}

Auftragsversprechen

class JobPromise {
    onStatus(eventHanlder: (argument?: any) => void): JobPromise;
    onWorkflowEvent(eventHanlder: (argument?: any) => void): JobPromise;
}class JobPromise {
    onStatus(eventHanlder: (argument?: any) => void): JobPromise;
    onWorkflowEvent(eventHanlder: (argument?: any) => void): JobPromise;
}

Auftrag

class Job {
    processId: string;
    argument?: any;
    jobId: string;
    on(eventName: string, eventHanlder: (argument?: any) => void): void;
}class Job {
    processId: string;
    argument?: any;
    jobId: string;
    on(eventName: string, eventHanlder: (argument?: any) => void): void;
}

JobResult

class JobResult {
    [Key: string]: any;
}class JobResult {
    [Key: string]: any;
}

WorkflowEventData

class WorkflowEventData {
    name: string;
    payload: string;
}class WorkflowEventData {
    name: string;
    payload: string;
}

War diese Seite hilfreich?

Hilfe erhalten
RPA lernen – Automatisierungskurse
UiPath Community-Forum
UiPath Logo weiß
Vertrauen und Sicherheit
© 2005-2024 UiPath. All rights reserved.