- 发行说明
- 入门指南
- 设置和配置
- 自动化项目
- 依赖项
- 工作流类型
- 文件比较
- 自动化最佳实践
- 源代码控件集成
- 调试
- 诊断工具
- 工作流分析器
- 变量
- 参数
- 导入的命名空间
- 控制流程
- 对象存储库
- 日志记录
- ScaleCoordinates 迁移工具
- ScreenScrapeJavaSupport 工具
- StudioPro
- 扩展程序
- 故障排除
长时间运行的工作流是主项目,可在无人值守的环境中支持服务编排、人工干预和长时间运行的事务。
当某些流程在继续执行活动的下一步骤前需要人工输入来处理异常、审批或验证时,则需要人工干预。在这种情况下,系统将会暂停执行流程,并释放机器人,直到人工任务完成。
工作流拆分
长时间运行的工作流包含 UiPath.Persistence.Activities,可以与调用流程和非用户交互活动结合,通过机器人任务编排人工任务。 它在会话 0 中运行,从而确保快速执行。 请注意,编排流程的调试是在用户会话中完成的。
长时间运行的工作流可能会编排:
- 后台流程可能包含执行 API 调用并在会话 0 中运行的活动。可以使用“调用流程”活动调用它们。
- 用户界面:通过“从 Orchestrator 开始作业”活动调用包含用户交互活动的流程,并在用户会话中运行。
- 人在回路:用户通过需要在 Orchestrator 中填写表单的任务进行交互。这意味着将“创建表单任务”活动与“等待表单任务然后继续”配对。
编排流程模板
In Studio, go to Home > Orchestration Process to open the template, which contains the default UiPath.Persistence.Activities and UiPath.System.Activities dependencies in a Flowchart workflow type.
The template's project.json file has the supportsPersistence: true parameter, indicating that process execution resumes upon task completion.
The requiresUserInteraction: false parameter indicates this workflow does not contain user interaction activities, similar to a Background Process.
不建议手动修改 project.json 文件中的参数。
A process may be turned into an Orchestration Process from the Project Settings window by setting the Supports Persistence toggle to Yes.
编排流程的代码片段
首先,您可以使用“代码片段”面板中提供的一系列工作流代码片段创建“编排流程”。
构建编排流程
请按照以下步骤将 UiPath.Persistence.Activities 包中的活动配对,并建立自己的编排流程:
-
使用“添加队列项目并获取引用”活动添加具有
in、in/out或out参数的队列项目,然后获取对应的队列项目对象。当队列项目被处理时,如果此活动与“等待队列项目并继续”活动配对ItemInformation,则属性中提供的参数会被分配回映射的工作流变量。 -
“等待队列项目并继续”活动应与“添加队列项目”和“获取引用”活动配对。 工作流进入暂停状态,在此活动处释放机器人,等待特定的队列项目完成,然后再进入流程中的下一步。
-
“开始作业并获取引用”活动通过提供
in、in/out或out类型的参数来调用另一个流程 执行后,如果此活动与“等待作业并继续”活动配对,则会将修改后的参数映射回工作流变量。 -
“等待作业并继续”活动应与“开始作业并获取引用”活动配对,方法是将
Job Object后者活动的给定输出作为输出。 这将暂时暂停当前流程,并等待引用作业完成,在引用作业将状态更新为“完成”后继续流程。 -
Use the Create Form Task activity to create a task with form-based visualization for human interactions within a workflow. These forms with the relevant workflow context are presented to users for decision-making and other scenarios.
请注意,您需要安装 UiPath.FormActivityLibrary 包才能使用此活动。
-
“等待表单任务并继续”活动应与“创建表单任务”配对,方法是将其作为输入提供,
Task Object以暂停工作流,直到最终用户完成此特定任务。 -
使用“延迟后继续”活动来暂停工作流的执行,并在指定的日期和时间继续执行。
-
在 Studio 中执行工作流。每当机器人执行长时间运行的活动时,Studio 都会进入只读状态,同时启用功能区中的“继续”选项。接着,完成底层任务、队列项目或作业,然后单击“继续”。
最佳实践
-
UiPath.Persistence.Activities包内长时间运行的活动(“等待并继续”活动)只能用在编排流程的入口点,即标记为Main.xaml的文件。 -
由一个编排流程构建的可重用组件只能在其他编排流程中引用。
-
A process attached to a queue processing should not be modeled into a long-running workflow. If it must be used, ensure to complete the queue item status using the Set Transaction Status activity before the first persistence point (any Wait and Resume activity).
备注:Starting with Orchestrator v2020.10.8, queue items that are part of persistence points can be processed within long-running workflows, so setting the queue item's transaction to a final status (Failed or Successful) is not mandatory anymore. Head over to the Release Notes for more details.
-
暂留点(等待和恢复活动)不能在“遍历循环”活动的主体内使用,因其在执行第一次迭代后会暂停工作流,这可能与您的预期行为不相符。
也可以尝试同时使用循环与暂留活动,例如“并行的遍历循环“活动。请注意,默认情况下,每项作业恢复触发器的最大数量限制为 1,000。
-
任何可用的机器人均可恢复长时间运行的工作流,只要该机器人与暂停作业(例如无人值守或非生产)的机器人处于相同环境且类型相同,因此必须还要在暂留点后提供执行所需的本地资源。
-
All variables used in the scope of a long-running activity must be serializable. Types of variables listed in this page are serializable: Text, True or False, Number, Array, Date and Time. Data Table and GenericValue variables.
-
作用域中使用的不包含长时间运行活动的变量不受序列化要求的约束,因为工作流不会在其作用域中暂停。 不可序列化的数据类型可以在同一工作流中的单独序列作用域中使用,也可以通过调用其他文件来使用,前提是这些文件位于等待和继续活动之间,例如等待作业然后继续、等待队列项目然后继续以及等待表单任务然后继续。
-
Please take into consideration that some properties of objects generated by long-running activities cannot be evaluated in the Locals panel.
-
对期望每项作业具有大量操作的工作流实施适当的批处理。请注意,每项作业每次可等待的默认作业量限制为 1,000 项操作(或其他作业触发器)。
备注:The Delay and Retry Scope activities are not supported and do not work properly when used in the Main workflow of an Orchestration Process. In such cases, they should be placed inside a No Persist Scope activity.