robot
2020.10
false
- 发行说明
- 入门指南
- UiPath Assistant
- 安装和升级
- 机器人类型
- 机器人组件
- 许可
- 将机器人连接到 Orchestrator
- 流程与活动
- 日志记录
- Robot JavaScript SDK
- 特定场景
- 故障排除
重要 :
请注意此内容已使用机器翻译进行了部分本地化。
新发布内容的本地化可能需要 1-2 周的时间才能完成。
不在支持范围内
机器人用户指南
上次更新日期 2024年7月1日
SDK 规范
您的自定义应用程序或网页中可以包含以下方法和属性:
Get Process
方法会检索并显示可用流程列表。如果机器人已连接到 Orchestrator,它将从机器人所属的环境和文件夹中检索流程。如果未连接到 Orchestrator,则显示本地流程。
const robot = UiPathRobot.init();
robot.getProcesses()
.then(result => {
for(let i=0; i<result.length;i++){
console.log(result[i].name);
}
}, err => {
console.log(err);
});
const robot = UiPathRobot.init();
robot.getProcesses()
.then(result => {
for(let i=0; i<result.length;i++){
console.log(result[i].name);
}
}, err => {
console.log(err);
});
Start Job
方法通过其 ID 和输入参数(如有)启动流程。
let arguments = {
"input1" : 23,
"input2" " 42,
"operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(process => {
let calculatorProcess = processes.find(p => p.name.includes('Calculator'));
let job = new job(calculatorProcess.id, arguments);
robot.startJob(job).then(result => {
console.log(result.Sum);
}, err => {
console.log(err);
})
}, err => {
console.log(err);
});
let arguments = {
"input1" : 23,
"input2" " 42,
"operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(process => {
let calculatorProcess = processes.find(p => p.name.includes('Calculator'));
let job = new job(calculatorProcess.id, arguments);
robot.startJob(job).then(result => {
console.log(result.Sum);
}, err => {
console.log(err);
})
}, err => {
console.log(err);
});
On
方法适用于在 SDK 上附加事件处理程序。UiPath JavaScript SDK 随附内置的同意覆盖,每次您的自定义应用程序或网页需要连接到机器人时都会显示。您可以使用自定义处理程序覆盖此同意覆盖。
const robot = UiPathRobot.init();
robot.on('consent-prompt', (consentCode) => {console.log(consentCode)});
robot.on('mising-components', () => {console.log('Missing Components')});
const robot = UiPathRobot.init();
robot.on('consent-prompt', (consentCode) => {console.log(consentCode)});
robot.on('mising-components', () => {console.log('Missing Components')});
Process Start
方法适用于通过传递输入参数(如果可用)来启动流程。
let arguments = {
"input1" : 23,
"input2" " 42,
"operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(process => {
let process = processes.find(p => p.name.includes('Calculator'));
process.start(arguments).then(result => {
console.log(result.Sum);
}, err => {
console.log(err);
})
}, err => {
console.log(err);
});
let arguments = {
"input1" : 23,
"input2" " 42,
"operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(process => {
let process = processes.find(p => p.name.includes('Calculator'));
process.start(arguments).then(result => {
console.log(result.Sum);
}, err => {
console.log(err);
})
}, err => {
console.log(err);
});
Process Start On Status
方法适用于通过传递回调处理程序来启动流程并附加状态回调。
let arguments = {
"input1" : 23,
"input2" " 42,
"operation" : "add"
};
let globalHandler = (status) => {console.log(status)};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(processes => {
let statusHandler = (status) => {console.log('Calculator Process Status -' + status)};
let process = processes.find(p => p.name.includes('Calculator'));
process.start(arguments)
.onStatus(globalHandler)
.onStatus(statusHandler)
.then(result => {
console.log(result.Sum);
}, err => {
console.log(err);
})
}, err => {
console.log(err);
});
let arguments = {
"input1" : 23,
"input2" " 42,
"operation" : "add"
};
let globalHandler = (status) => {console.log(status)};
const robot = UiPathRobot.init();
robot.getProcesses()
.then(processes => {
let statusHandler = (status) => {console.log('Calculator Process Status -' + status)};
let process = processes.find(p => p.name.includes('Calculator'));
process.start(arguments)
.onStatus(globalHandler)
.onStatus(statusHandler)
.then(result => {
console.log(result.Sum);
}, err => {
console.log(err);
})
}, err => {
console.log(err);
});
Stop Process
方法用于停止正在执行或正在运行的机器人流程。返回一个 promise,该 promise 在成功取消正在运行的机器人流程时得到解决。
try {
const robot = UiPathRobot.init();
const robotProcessId = 'MyRunningRobot';
const processes = await robot.getProcesses();
const myProcess = processes.find(function(process){return process.name.includes(robotProcessId)});
await robot.stopProcess(myProcess);
console.log(robotProcessId +' cancelled successfully');
} catch (e) {
console.log(robotProcessId +' cancellation failed -'+ e);
}
try {
const robot = UiPathRobot.init();
const robotProcessId = 'MyRunningRobot';
const processes = await robot.getProcesses();
const myProcess = processes.find(function(process){return process.name.includes(robotProcessId)});
await robot.stopProcess(myProcess);
console.log(robotProcessId +' cancelled successfully');
} catch (e) {
console.log(robotProcessId +' cancellation failed -'+ e);
}
Job On
方法适用于附加事件处理程序,以检索正在进行的流程所处的状态。
let arguments = {
"input1" : 23,
"input2" " 42,
"operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses().then(processes => {
let calculatorProcess = processes.find(p => p.name.includes('Calculator'));
let job =new job(calculatorProcess.id, arguments);
job.on('status', (robotStatus) => {console.log(robotStatus)});
robot.startJob(job).then(result => {
console.log(result.Sum);
}, err => {
console.log(err);
})
}, err => {
console.log(err);
});
let arguments = {
"input1" : 23,
"input2" " 42,
"operation" : "add"
};
const robot = UiPathRobot.init();
robot.getProcesses().then(processes => {
let calculatorProcess = processes.find(p => p.name.includes('Calculator'));
let job =new job(calculatorProcess.id, arguments);
job.on('status', (robotStatus) => {console.log(robotStatus)});
robot.startJob(job).then(result => {
console.log(result.Sum);
}, err => {
console.log(err);
})
}, err => {
console.log(err);
});
Settings
方法允许您编辑默认端口号和轮询间隔时间(以毫秒为单位)。
const robot = UiPathRobot.init();
robot.settings.portNumber = 1234;
robot.settings.pollTimeInterval = 1000
const robot = UiPathRobot.init();
robot.settings.portNumber = 1234;
robot.settings.pollTimeInterval = 1000
class Settings {
portNumber: number;
pollTimeInterval: number;
}
class Settings {
portNumber: number;
pollTimeInterval: number;
}
class RobotProcess {
id: string;
name: string;
constructor(id: string, name: string);
start: (inArguments?: any) => JobPromise;
}
class RobotProcess {
id: string;
name: string;
constructor(id: string, name: string);
start: (inArguments?: any) => JobPromise;
}
interface IRobotSDK {
settings: Settings;
getProcesses(): Promise<Array<RobotProcess>>;
init(): IRobotSDK;
on(eventName: string, callback: (argument?: any) => void): void;
startJob(job: Job): Promise<JobResult>;
}
interface IRobotSDK {
settings: Settings;
getProcesses(): Promise<Array<RobotProcess>>;
init(): IRobotSDK;
on(eventName: string, callback: (argument?: any) => void): void;
startJob(job: Job): Promise<JobResult>;
}
/**
* Job result model containing all output arguments from the process.
* Empty if there are no out arguments.
*/
class JobResult {
[Key: string]: any;
}
/**
* Job result model containing all output arguments from the process.
* Empty if there are no out arguments.
*/
class JobResult {
[Key: string]: any;
}
class Job {
processId: string;
argument?: any;
jobId: string;
constructor(processId: string, argument?: any);
on(eventName: string, eventHanlder: (argument?: any) => void): void;
}
class Job {
processId: string;
argument?: any;
jobId: string;
constructor(processId: string, argument?: any);
on(eventName: string, eventHanlder: (argument?: any) => void): void;
}