0

如何在 ExternalAction 的代码效果中创建接触器,我有这个代码

 [ExternalAction(typeof(Service), "SendEmail")]

我想在成功评估时发送电子邮件但没有在 SendEmail 中编写发送代码,我想使用调用接口发送它,像这样

    private readonly IEmailService email;
    public Service(IEmailService emailService)
    {
        email = emailService;
    }
 [Action("Send Email", "Send Email to Someone")]
    public void SendEmail(Rule Rule, [Parameter(ValueInputType.User, Description = "Output message", DataSourceName = "UserList")] int userId)
    {
      email.sene(userId);
    }
4

1 回答 1

0

您正在尝试使用实例操作方法。为了让引擎能够调用这样的方法,它需要实例化您的类型。您的 Service 类没有空(无参数/默认)构造函数。显然,引擎在评估时不会有您的 EmailService 实例。因此,它不能调用您的实例方法。将默认构造函数添加到您的 Service 类并找到另一种方法将 EmailService 传递给 Service 类,或者使用带有值类型参数的静态方法。

于 2021-02-08T13:16:37.233 回答