【二开分享】——插件实现发送消息
金蝶云社区-云小爱
云小爱
3人赞赏了该文章 1.2万次浏览 未经作者许可,禁止转载编辑于2014年07月09日 09:28:39

示例代码:
private Message SendMessage(Context ctx, string formId, string billId, string title, string content, DateTime now, long receiverId)

{
string messageId = SequentialGuid.NewGuid().ToString();
Message msg = new DynamicObject(Message.MessageDynamicObjectType);
msg.MessageId = messageId;
msg.Title = title;
msg.Content = content;
msg.CreateTime = now;
msg.SenderId = ctx.UserId;
msg.ObjectTypeId = formId;
msg.KeyValue = billId;
msg.ReceiverId = receiverId;

IDbDriver driver = new OLEDbDriver(ctx);
var dataManager = Orm.DataManagerUtils.GetDataManager(Message.MessageDynamicObjectType, driver);
dataManager.Save(msg.DataEntity);

return msg;
}

说明:
1.发消息就是往T_WF_MESSAGESEND表中写数据,对应模型FormId是WF_MessageSendBill
2.强类型实体Message(引用Kingdee.Bos.Core.Dll组件,引用Kingdee.BOS.Core.Msg命名空间);IDbDriver接口,引用Kingdee.BOS.OrmEngine.Dll组件,引用Kingdee.BOS.Orm.Drivers命名空间