- 关于如何在C#中编写Custom Acitivity,虽然在这里Creating a Custom Activity 有非常详尽的描述,但自己再将作成过程记录一次的话,印象更深。
- UiPath Studioで使用するカスタムアクティビティの作成方法
1. 使用的工具
2. 在C#中编写dll
- 创建dll用的工程:

- 添加依赖关系:

- 追加对应代码:
注意添加了新的using:using System.Activities;和using System.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Activities;
using System.ComponentModel;
namespace ClassMathCustomActivity
{
public class SimpleFormula : CodeActivity
{
[Category("Input")]
[RequiredArgument]
public InArgument<double> FirstNumber { get; set; }
[Category("Input")]
public InArgument<double> SecondNumber { get; set; }
[Category("Output")]
public OutArgument<double> ResultNumber { get; set; }
protected override void Execute(CodeActivityContext context)
{
var firstNumber = FirstNumber.Get(context);
var secondNumber = SecondNumber.Get(context);
var result = System.Math.Pow(firstNumber + secondNumber, 2);
ResultNumber.Set(context, result);
}
}
}
- 编译成dll文件:

可以在对应目录中找到dll文件。
3. 创建NuGet Package
- 启动NuGet Package Explorer,创建新的包

- 将dll添加到Nuget Package中:

- 最后
File -> Save as...,既可以保存为nupkg文件了。
4. 在UiPath中使用该Activity

5. 使用Activity Creator
使用 Activity Creator能更快的创建自定义Activity。 参考使用方法:DEMO: Build custom activities in minutes with the UiPath Activity Creator
- 在Visual Studio 2019中安装:
注意:在2019之前的版本中不能使用。

- 安装完毕后,启动Visual Studio,创建一个Uipath Activity Project:

- 创建一个Project后,通过Extension的UiPath可以追加Activities:

- 创建Activity完毕后,publish:

- 导入后,在UiPath中结果如下:

这个Extension做得很强大,更多功能等着去挖掘!