public DingTalkResModel ConvertMD(HWCodeHookModel model, DingTalkConfig config) { var result = new DingTalkResModel(); result.msgtype = "markdown"; var md = new DingTalkResMarkdown(); md.title = $"{model.repository.name}源代码提交"; var mdSb = new StringBuilder(); foreach (var commit in model.commits) { mdSb.AppendLine($"# {commit.message}{Environment.NewLine}"); mdSb.AppendLine($"> [{commit.author.name} {commit.timestamp.AddHours(8)}](https://devcloud.huaweicloud.com/codehub/project/{config.Project}/codehub/{model.project_id}/{commit.id}/commitdetail){Environment.NewLine}"); //if (commit.added != null && commit.added.Length > 0) //{ // mdSb.AppendLine($"> Added{Environment.NewLine}"); // foreach (var item in commit.added) // { // mdSb.AppendLine($"- [{item}](https://devcloud.huaweicloud.com/codehub/project/{config.Project}/codehub/{model.project_id}/file?ref={model.project.default_branch}&path={Uri.EscapeDataString(item)})"); // } // mdSb.AppendLine($"{Environment.NewLine}"); //} //if (commit.modified != null && commit.modified.Length > 0) //{ // mdSb.AppendLine($"> Modified{Environment.NewLine}"); // foreach (var item in commit.modified) // { // mdSb.AppendLine($"- [{item}](https://devcloud.huaweicloud.com/codehub/project/{config.Project}/codehub/{model.project_id}/file?ref={model.project.default_branch}&path={Uri.EscapeDataString(item)})"); // } // mdSb.AppendLine($"{Environment.NewLine}"); //} //if (commit.removed != null && commit.removed.Length > 0) //{ // mdSb.AppendLine($"> Removed{Environment.NewLine}"); // foreach (var item in commit.removed) // { // mdSb.AppendLine($"- [{item}](https://devcloud.huaweicloud.com/codehub/project/{config.Project}/codehub/{model.project_id}/file?ref={model.project.default_branch}&path={Uri.EscapeDataString(item)})"); // } // mdSb.AppendLine($"{Environment.NewLine}"); //} } mdSb.AppendLine($"> *Repository [{model.repository.name}](https://devcloud.huaweicloud.com/codehub/project/{config.Project}/codehub/{model.project_id}/home)*{Environment.NewLine}"); mdSb.AppendLine($"> *Project [{model.project.name}](https://devcloud.huaweicloud.com/scrum/{config.Project}/home)*{Environment.NewLine}"); md.text = mdSb.ToString(); result.markdown = md; return(result); }
public DingTalkResModel ConvertMD(GitHubPushModel model) { var result = new DingTalkResModel(); result.msgtype = "markdown"; var md = new DingTalkResMarkdown(); md.title = $"{model.repository.name}源代码提交"; var mdSb = new StringBuilder(); foreach (var commit in model.commits) { mdSb.AppendLine($"# {commit.message}{Environment.NewLine}"); mdSb.AppendLine($"> [{commit.author.name} {commit.timestamp}]({commit.url}){Environment.NewLine}"); } mdSb.AppendLine($"> *Repository [{model.repository.name}]({model.repository.url})*{Environment.NewLine}"); mdSb.AppendLine($"> *Organization [{model.organization.login}](https://github.com/{model.organization.login})*{Environment.NewLine}"); md.text = mdSb.ToString(); result.markdown = md; return(result); }