public IActionResult CodePushed([FromBody] CodePushed data)
        {
            var commit = data.Resource.Commits.First();

            //var repository = data.Resource.Repository;
            if (commit == null)
            {
                return(BadRequest());
            }
            var text = $"### 代码推送\n\n" + $"##### {data.DetailedMessage.Markdown}";

            var sendMsg = new MarkdownMsg
            {
                Markdown = new Markdown
                {
                    Title = "代码推送",
                    Text  = text
                },
                At = new At
                {
                    IsAtAll = false
                }
            };

            return(Json(DingServices.SendMsgAsync(buildNoticeUrl, sendMsg).Result));
        }
        public IActionResult WorkUpdated([FromBody] WorkUpdated data)
        {
            var work        = data.Resource.Fields;
            var workContent = data.Resource.Revision?.Fields.SystemDescription;

            if (workContent == null)
            {
                workContent = "无";
            }
            else if (workContent.Length > 100)
            {
                workContent = workContent.Substring(0, 100);
            }
            if (work == null)
            {
                return(BadRequest());
            }
            var text = $"### 任务更新 @**{data.Resource.Revision?.Fields.SystemAssignedTo ?? ""}**\n\n{data.DetailedMessage.Markdown}\n\n";

            text += $"任务内容:{workContent}";
            var sendMsg = new MarkdownMsg
            {
                Markdown = new Markdown
                {
                    Title = "任务更新",
                    Text  = text
                },
                At = new At
                {
                    IsAtAll = false
                }
            };

            return(Json(DingServices.SendMsgAsync(workNoticeUrl, sendMsg).Result));
        }
        public IActionResult BuildCompleted([FromBody] BuildCompleted data)
        {
            var resource = data.Resource;
            // 用时
            TimeSpan timeSpends = resource.FinishTime - resource.StartTime;
            // 发起人
            var requestMan = resource.RequestedBy.DisplayName;

            if (requestMan.Equals("Microsoft.TeamFoundation.System"))
            {
                requestMan = "自动构建";
            }

            if (resource == null)
            {
                return(BadRequest());
            }
            var text = $"### {resource.Definition.Name} 构建 {resource.Result}\n" +
                       $"#### {data.DetailedMessage.Markdown}\n\n" +
                       $"用时:{timeSpends.TotalSeconds}秒\n\n" +
                       $"请求方:{requestMan}\n\n";
            var sendMsg = new MarkdownMsg
            {
                Markdown = new Markdown
                {
                    Title = $"构建{resource.Result}",
                    Text  = text
                },
                At = new At
                {
                    IsAtAll = false
                }
            };

            //return Json(sendMsg);
            return(Json(DingServices.SendMsgAsync(buildNoticeUrl, sendMsg).Result));
        }