UiPath Documentation
data-service
latest
false
  • 入门指南
    • 简介
    • Data Fabric / Data Service feature availability
    • 探索用户界面
    • 区域和实例
  • 许可
  • 设置和配置
  • 使用服务
  • 参考
  • 示例和教程
    • 在项目中使用实体
    • 在实体记录中上传文件字段
    • 在实体记录中下载文件字段
    • 使用批处理活动从 CSV 上传数据
  • 日志记录

Data Service 用户指南

上次更新日期 2026年5月7日

在项目中使用实体

By using entities created in Data Fabric / Data Service, you can manage and manipulate data aggregated in a single object, without having to work with it in a granular way. To do so you need Studio v2020.8 or later.

以下示例检索奥运会各个项目所获奖牌数前 10 名的国家/地区的相关数据,以及它们获得的奖牌。

Entities in Data Fabric / Data Service

Following the steps detailed on the Creating an entity page, we created an entity for storing information about participating nations, the opening and closing dates, and the medals they won.

“奥运会”实体具有以下字段:“名称”、“国家/地区”、“开幕日期”和“闭幕日期”。“奖牌”实体具有以下字段:“国家/地区”、“金牌”、“银牌”、“铜牌”以及奖牌总数。这两个实体通过“关系”标签相互关联。

文档图像

在 Studio 中导入的实体

在 Studio 的工作流中导入实体。

以下工作流将抓取有关某届奥运会的信息,将数据映射到参数,并将其传递到主工作流。

文档图像

为此,我们为要收集的每种信息类型定义了一个参数,从而生成了五个导入的参数。

文档图像

通过使用实体,我们只需导入并使用两个参数即可收集数据。

备注:

Entities must be initialized using the new operator, read from Data Fabric / Data Service or passed through an input argument in a workflow before usage, otherwise assigning or reading their values can cause errors.

文档图像

收集的数据映射到两个参数(inOlympics YearoutOlympics)、其各自的属性和实体中定义的字段。通过使用实体,我们通过将数据正确映射到其各自的实体字段,减少了传递信息所需的参数个数。

创建数据记录

Once the data was collected, you can use the Create Entity Record activity to add the information to Data Fabric / Data Service.

In this example, we used the imported arguments to pass the collected information to Data Fabric / Data Service. The Input and Output records are the values of variables of type Olympics used for passing along the data.

文档图像

After running the project, the following record was created in Data Fabric / Data Service:

文档图像

创建包含结构化数据的记录

Records structured in a data table can be passed along to Data Fabric / Data Service using the For Each Row activity. In this example, we're invoking a workflow that collects structured data on the number of medals won by each country and passes these records along to Data Fabric / Data Service.

文档图像

After running the workflow, the following data is stored in Data Fabric / Data Service:

文档图像

通过在“奥运会”实体和“奖牌”实体之间设置关系,两者中的数据记录都可以在另一个实体中使用。例如,“奖牌”实体中的“奥运会”字段的值与相关实体中的值相同。

The Query Entity Records activity can be used to pull up a list of records from Data Fabric / Data Service. In the following example, we use the activity to query data records from the Olympics entity, allow the user to choose an Olympics edition, and from the Medals entity write the number of medals that each participating country won.

文档图像

在查询“奥运会”表格时,我们在查询生成器中使用了 Name != NULL 条件。这将遍历“名称”列中的所有记录,并在 listOlympics 变量中输出这些记录,以在“输入对话框”活动中使用。

为了将记录列表显示为选项,我们在“输入对话框” 活动中使用了以下 Lambda 表达式listOlympics.Select(Function (o as Olympics) o.Name).ToArray 。或者,也可以使用“遍历循环”活动。

系统会将所选内容映射到 selectedOlympics 变量,并在另一个“查询实体记录”活动中使用所选内容来遍历在特定一届奥运会上所获奖牌的列表。此条件是通过在查询生成器中使用 equals 选项设置的。

文档图像

可对选定实体和相关的实体记录执行查询。

分页

Data Fabric / Data Service can potentially store a large number of records. To query only a certain number of records, use the Pagination properties from the Query Entities Records activity. The Top property supports a maximum number of 1,000, this means that 1,000 records can be queried at a time.

本示例先查询前五个记录,然后再查询接下来的五个记录,直到抓取列表中的最后一个记录为止。

文档图像

为此,我们为 skip Int64 变量分配了初始值 0,然后在每个循环后将其值递增,直到抓取最后一个记录为止。

文档图像

抓取前五枚奖牌后,使用“遍历循环”活动将参与国家/地区及其所获奖牌数写入到记事本文件。

更新实体架构

The following scenario explains the steps for updating an entity schema in Data Fabric / Data Service and then syncing the data with Studio.

In Data Fabric / Data Service, go to the Medals entity, select Create New Field, and add a new column HostCountry of type Yes/No. Select Save.

文档图像

In Studio, select on Manage Entities, and then the Refresh button. A change was detected for the Medals entity, as illustrated in the Changes column. Select Save and the entity is updated in Studio.

文档图像

查询和更新记录

The Update Entity Record activity can be used for updating records from your workflow directly into Data Fabric / Data Service.

在本示例中,我们将从“奖牌”实体查询某些记录,并使用上述活动自动更新这些记录。

在“奖牌”实体中,每届奥运会的主办国家名称旁边标有星号。例如,对于 2012 奥运会,主办国家在“奥运会”列中记录为“英国 (GBR)*”。

文档图像

使用“查询实体记录”活动,我们遍历所有包含星号 (*) 的记录,在 listMedals 变量中抓取记录,使用“遍历循环”活动遍历循环每个项目,并在“主办国家”列中在主办特定一届奥运会的国家旁边分配“True”值。

The Update Entity Record activity can be used in numerous other scenarios for passing along data and updating records in Data Fabric / Data Service.

此页面有帮助吗?

连接

需要帮助? 支持

想要了解详细内容? UiPath Academy

有问题? UiPath 论坛

保持更新