using Newtonsoft.Json.Linq; using ryCommon; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; using 开发辅助工具; namespace SuperDesign.Manager { public class APIManager { public static string GetMdLogText(JArray jarr, DateTime dt,bool UseEmoji=false) { string log_text = "## :date:" + DateTime.Now.ToString("yyyy-MM-dd dddd") + "更新"; for (int i = 0; i < jarr.Count; i++) { var item = jarr[i]; log_text += "\r\n\r\n### " + item.GetJsonValue("ProjectName", "").Trim() + " V" + item.GetJsonValue("VerStr", ""); var logs = item.GetJsonValue("LogText", "").Replace("\r", "\n").Replace("\n\n", "\n").Split('\n'); for (int m = 0; m < logs.Length; m++) { if (logs[m].Length == 0) { continue; } var log_item = logs[m].Replace("[开发]",""); if (log_item.StartsWith("*.")) { log_item = "- " + log_item; } else if (log_item.StartsWith("[")) { log_item = "- *." + log_item; } if (UseEmoji) { var is_kf = log_item.IndexOfEx("[开发]") > 0; var type_item = log_item.GetStr("- *.[", "]"); if (type_item == "修复") { log_item = log_item.Replace("*.[" + type_item + "]", ":lady_beetle:"+(is_kf? ":secret:" : "")+"[" + type_item + "]"); } else if (type_item == "改进") { log_item = log_item.Replace("*.[" + type_item + "]", ":100:"+(is_kf? ":secret:" : "")+"[" + type_item + "]"); } else if (type_item == "新增") { log_item = log_item.Replace("*.[" + type_item + "]", ":cactus:"+(is_kf? ":secret:" : "")+"[" + type_item + "]"); } else if (type_item == "删除") { log_item = log_item.Replace("*.[" + type_item + "]", ":x:"+(is_kf? ":secret:" : "")+"[" + type_item + "]"); } } log_text += "\r\n" + log_item.Trim(); } } return log_text; } public static string GetHtmlLogText(string bf_folder, JArray jarr, DateTime dt) { ryCommon.Ini ini = new Ini(bf_folder + "\\查看项目.ryp"); string log_text = ""; for (int i = 0; i < jarr.Count; i++) { var item = jarr[i]; var eng_name= item.GetJsonValue("ProjectName", ""); if(ini.ReadIni("NoVerHtml", eng_name,0)==1) { continue; } if (log_text.Length != 0) { log_text += "\r\n"; } var ProjectName = item.GetJsonValue("ProjectChsName", ""); if(ProjectName.Length==0) { ProjectName = eng_name; } log_text += "
" +System.Web.HttpUtility.HtmlEncode(log_item.Substring(2))+"
"; } else { log_text += "\r\n" + System.Web.HttpUtility.HtmlEncode(log_item) + "
"; } } } return log_text; } public static string GetTortoiseGitProcPath() { DriveInfo[] driveInfo = DriveInfo.GetDrives(); for (int i = 0; i < driveInfo.Length; i++) { var path = driveInfo[i].Name + "Program Files\\TortoiseGit\\bin\\TortoiseGitProc.exe"; if (System.IO.File.Exists(path)) { return path; } } return ""; } ///