//第四步 工作消息通知 //https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=ACCESS_TOKEN //参数 agent_id 应用agentId ,userid_list 第三步 originator_userid errcode=0 审批通过 public WorkMsgReturn DoPostPerson(string token, ProcessDetail _processDetail) { Text _text = new Text() { content = string.Empty }; List <Form_component_values> _lsComp = _processDetail.process_instance.form_component_values; List <LsRowValue> rowValues = new List <LsRowValue>(); foreach (var item in _lsComp) { if (item.name.Contains("物品明细")) { rowValues = JsonHelper.FromJson <List <LsRowValue> >(item.value); foreach (var itemRowDetial in rowValues) { foreach (var itemDetail in itemRowDetial.rowValue) { if (itemDetail.label == "物品名称") { _text.content += "商品名称:\t" + itemDetail.value + "\r\n" + "取货码:" + string.Format("{0:ssffff}", DateTime.Now) + "\r\n"; } } } } } _text.content = "申请时间:" + _processDetail.process_instance.create_time.ToString() + "\r\n" + _text.content; SenPersonMsg _sdMsg = new SenPersonMsg(); Msg _msg = new Msg() { msgtype = "text", text = _text }; _sdMsg.agent_id = "250353028"; _sdMsg.userid_list = _processDetail.process_instance.originator_userid; _sdMsg.msg = _msg; string strMsgJson = JsonHelper.ToJson <SenPersonMsg>(_sdMsg); this.strUrl = "https://oapi.dingtalk.com/topapi/message/corpconversation/asyncsend_v2?access_token=" + token; this.strJson = HttpMethod.PostUrl(this.strUrl, strMsgJson); WorkMsgReturn _workMsgReturn = JsonHelper.FromJson <WorkMsgReturn>(this.strJson); return(_workMsgReturn); }
static void Main(string[] args) { DDAPI _dDAPI = new DDAPI(); string strToken = _dDAPI.GetAcessTocken(); ProcessInstance _processInstance = _dDAPI.GetProsListId(strToken); foreach (var item in _processInstance.result.list) { ProcessDetail _processDetail = _dDAPI.GetProsDetial(strToken, item); WorkMsgReturn _workMsgReturn = _dDAPI.DoPostPerson(strToken, _processDetail); // 检查数据是否真实发送 WorkSendOk _workSendOk = _dDAPI.GetWorkSendOk(strToken, _workMsgReturn.task_id); } //ProcessDetail _processDetail = _dDAPI.GetProsDetial(strToken, _processInstance.result.list[0]); //WorkMsgReturn _workMsgReturn = _dDAPI.DoPostPerson(strToken, _processDetail); Console.WriteLine("执行成功"); Console.ReadLine(); }