public async Task <Object> SendVote(string Url, int Id) { try { using (DDContext context = new DDContext()) { Vote vote = context.Vote.Find(Id); string title = vote.Title; string ApplyMan = vote.ApplyMan; DingTalkManager dtManager = new DingTalkManager(); var AccessToken = await dtManager.GetAccessToken(); AccessTokenResponseModel accessTokenResponseModel = JsonConvert.DeserializeObject <AccessTokenResponseModel>(AccessToken); IDingTalkClient client = new DefaultDingTalkClient("https://eco.taobao.com/router/rest"); CorpMessageCorpconversationAsyncsendRequest req = new CorpMessageCorpconversationAsyncsendRequest(); req.Msgtype = "oa"; req.AgentId = long.Parse(DTConfig.AgentId); req.DeptIdList = "1"; req.ToAllUser = true; req.Msgcontent = "{\"message_url\": \"http://dingtalk.com\",\"head\": {\"bgcolor\": \"FFBBBBBB\",\"text\": \"投票通知\"},\"body\": {\"title\": \"正文标题\",\"form\": [],\"content\": \"11111111111\",\"author\": \"李四 \"}}"; CorpMessageCorpconversationAsyncsendResponse rsp = client.Execute(req, accessTokenResponseModel.access_token); Console.WriteLine(rsp.Body); } return(new ErrorModel() { errorCode = 0, errorMessage = "成功" }); } catch (Exception ex) { return(new ErrorModel() { errorCode = 1, errorMessage = ex.Message }); } }
public async Task <string> AccessToken() { var result = await dtManager.GetAccessToken(); return(result); }