SuperDesign/Source/开发辅助工具/Manager/APIManager.cs
zilinsoft 5a5faaf5dc ## 📅2025-07-16 星期三更新
### RySmartEditor    V1.0.2507.1601
- *.[新增]新增文件内容索引搜索。
- *.[新增]新增打开文件自动定位到指定行的功能。
### SuperDesign    V3.0.2507.1601
#### 网页抓取工具
- *.[修复]修复历史记录无法记录的BUG。
#### 编码解码
- *.[新增]新增svg图片代码转Geometry代码的功能。
#### 项目功能->项目管理
- *.[新增]互斥运行标准改为以毕方文件夹为准,而不是以项目文件为准。
- *.[新增]支持同个毕方项目可以不用重启来快捷切换不同子项目。
- *.[新增]支持发布时和打包时自动编译功能。
- *.[修复]修复项目输出路径为相对路径时,更新引用dll可能不成功的BUG。
2025-07-16 09:08:09 +08:00

197 lines
7.4 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
{
/// <summary>
/// 获取毕方标准项目根路径
/// </summary>
/// <returns></returns>
public static string GetBFFolderPath(string _ProjectPath)
{
var _path = _ProjectPath;
while (true)
{
_path = System.IO.Path.GetDirectoryName(_path.TrimEnd('\\')).TrimEnd('\\');
if (System.IO.File.Exists(_path + "\\查看项目.ryp"))
{
return _path;
}
else
{
if (_path.Length < 4) { break; }
}
}
return "";
}
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 += "<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.IndexOfEx("[开发]") >= 0) { continue; }
if (log_item.IndexOfEx("#### ")== 0) {
log_text += "\r\n<h4>" + System.Web.HttpUtility.HtmlEncode(log_item.Substring(5)) + "</h4>";
continue;
}
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;
}
}
}