SuperDesign/Source/开发辅助工具/Manager/APIManager.cs
zilinsoft a0cbe0a68f ### 2024-12-20 星期五更新
------
#### SuperDesign    V3.0.2412.2003
- *.[新增]新增支持更新日志发布时自动调用起TortoiseGit。
- *.[新增]版本列表新增支持设置正式版本。
- *.[改进]自定义对话框针对单选函数返回值,则使用if而不是switch语句。
- *.[改进]点击发布日志按钮弹出确认框,避免误点击。
- *.[改进]更新版本列表的更新时间支持昨天、今天的简短显示。
2024-12-20 15:55:33 +08:00

148 lines
5.0 KiB
C#

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)
{
string log_text = "### " + DateTime.Now.ToString("yyyy-MM-dd dddd") + "更新";
log_text += "\r\n------";
for (int i = 0; i < jarr.Count; i++)
{
var item = jarr[i];
log_text += "\r\n#### " + item.GetJsonValue("ProjectName", "") + " 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];
if (log_item.StartsWith("- *."))
{
log_text += "\r\n" + log_item;
}
else if (log_item.StartsWith("*."))
{
log_text += "\r\n- " + log_item;
}
else
{
log_text += "\r\n- *." + log_item;
}
}
}
return log_text;
}
public static string GetHtmlLogText(JArray jarr, DateTime dt)
{
string log_text = "";
for (int i = 0; i < jarr.Count; i++)
{
var item = jarr[i];
if(log_text.Length!=0)
{
log_text += "\r\n";
}
var ProjectName = item.GetJsonValue("ProjectChsName", "");
if(ProjectName.Length==0)
{
ProjectName = item.GetJsonValue("ProjectName", "");
}
log_text += "<h4>" + System.Web.HttpUtility.HtmlEncode(ProjectName) + "</h4>";
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];
if (log_item.StartsWith("- *."))
{
log_text += "\r\n<p>" +System.Web.HttpUtility.HtmlEncode(log_item.Substring(2))+"</p>";
}
else
{
log_text += "\r\n<p>" + System.Web.HttpUtility.HtmlEncode(log_item) + "</p>";
}
}
}
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 "";
}
/// <summary>
/// 获取参数翻译名称
/// </summary>
/// <param name="ParamName"></param>
/// <returns></returns>
public static string GetParamTitle(string ParamName)
{
var title = "";
switch (ParamName.ToLower())
{
case "starttime":
title = "开始时间";
break;
case "endtime":
title = "结束时间";
break;
case "page":
title = "页码";
break;
case "pagesize":
title = "每页数量";
break;
case "title":
title = "标题";
break;
case "name":
title = "名称";
break;
case "id":
title = "id编号";
break;
case "modelid":
title = "资源类型";
break;
case "packagename":
case "pkgname":
title = "包名";
break;
case "filename":
title = "文件名";
break;
case "url":
title = "网址";
break;
case "username":
title = "用户名";
break;
case "realname":
title = "真实姓名";
break;
case "cooperid":
title = "合作包id";
break;
}
return title;
}
}
}