public MessageCorpconversationAsyncsendV2Response SendAsynMsg(OpenAuth.Repository.Domain.Message message) { try { Message.Request.MessageCorpconversationAsyncsendV2Request req = new Message.Request.MessageCorpconversationAsyncsendV2Request(); req.AgentId = Ext.ToLong(DDHelper.GetAgentId()); req.ToAllUser = false; req.UseridList = message.RecieveUsers; var msg = new Message.Request.MessageCorpconversationAsyncsendV2Request.MsgDomain(); msg.text = new Message.Request.MessageCorpconversationAsyncsendV2Request.TextDomain(); msg.text.content = message.MsgContent; msg.msgtype = "text"; req.Msg = msg; string Url = string.Format("https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token={0}", DDHelper.GetToken()); string response = Infrastructure.Web.WebHelper.HttpWebRequestJson(Url, req.GetParametersToJosn()); MessageCorpconversationAsyncsendV2Response res = response.ToObject <MessageCorpconversationAsyncsendV2Response>(); if (res.Errcode == 0) { messageApp.UpdateToRecevice(new string[] { message.Id }); } else { messageApp.UpdateToReceviceErrMsg(message.Id, res.Errmsg); } return(res); } catch (Exception ex) { return(null); } }
public MessageCorpconversationSendResponse SendMsg(OpenAuth.Repository.Domain.Message message) { try { Message.Request.MessageCorpconversationSendRequest req = new Message.Request.MessageCorpconversationSendRequest(); req.AgentId = Ext.ToLong(DDHelper.GetAgentId()); req.ToUser = message.RecieveUsers.Replace(",", "|"); req.MessageType = ((Message.Request.MessageCorpconversationSendRequest.MessageTypeDomain)(message.MsgType)).ToString(); req.textMessage = new Message.Request.MessageCorpconversationSendRequest.TextDomain { content = message.MsgContent }; string Url = string.Format("https://oapi.dingtalk.com/message/send?access_token={0}", DDHelper.GetToken()); string response = Infrastructure.Web.WebHelper.HttpWebRequestJson(Url, req.GetParametersToJosn()); MessageCorpconversationSendResponse res = response.ToObject <MessageCorpconversationSendResponse>(); if (res.Errcode == 0) { messageApp.UpdateToRecevice(new string[] { message.Id }); } else { messageApp.UpdateToReceviceErrMsg(message.Id, res.Errmsg); } return(res); } catch (Exception ex) { return(null); } }