跳转至

消息通知接口

功能描述

Notifier 类是通知管理核心类,负责处理各类通知消息(如应用通知、短信、邮件、第三方平台通知等)的发送、缓存与队列调度。以下文档聚焦其核心的 SendNotify 方法,明确方法功能、参数、使用约束及内部处理逻辑。

接口列表

Send 方法

功能描述

将用户消息(UserMessage)通过 H3.Notification.UserMessageType 通知方式转化为对应的消息类型(短信、邮件、钉钉通知等)发送。

接口定义

public void Send(UserMessage[] messages);

参数说明

参数名称 是否必填 类型 描述
messages H3.Notification.UserMessage[] 待发送的用户消息数组,支持多种消息类型(如短信、邮件、钉钉通知等),数组为空或长度为 0 时会直接返回,不执行后续逻辑。

返回值

无。

示例

List <H3.Notification.UserMessage> _messageList=new List<H3.Notification.UserMessage>();
string title = "欢迎词";//标题
string welcomeWords = "hello,氚云!\n很荣幸加入你";//发送内容
string send =   H3.Organization.User.SystemUserId;//发起人
string receiverid =   this.Request.UserContext.UserId;//接收人
H3.Notification.UserMessage   _message = new  H3.Notification.UserMessage(
    H3.Notification.UserMessageType.DingTalkPlainText,   
    send, receiverid, 
    "", 
    title, 
    welcomeWords, 
    "");
_messageList.Add(_message);
if(_messageList.Count > 0)
{
    this.Request.Engine.Notifier.Send(_messageList.ToArray());//执行发送
}

Notify 方法

功能描述

接收通用通知对象(Notification),将其转换为对应平台(钉钉、企微、飞书)的消息并发送。

接口定义

public void Notify(Notification notification);

参数说明

参数名称 是否必填 类型 描述
notification H3.Notification.Notification 通用通知对象,需包含通知标题、内容、接收者、关联应用/表单信息等,为 null 时会直接返回。

返回值

无。

示例

H3.Notification.InstanceFinishedNotification finishedNotification = new H3.Notification.InstanceFinishedNotification(
                        this.Request.UserContext.UserId,
                        this.Request.UserContext.UserId,
                        "流程结束通知测试",
                        "流程结束通知测试摘要",
                        "D0001837dc8288927204832ba440f7cf0542687",
                        "2ea0b9cc-55d8-4b9d-983a-503f787bac94",
                        "4b165903-8e11-4d68-993f-993d6d7391a6",
                        true);
  this.Engine.Notifier.Notify(finishedNotification);