2024-10-12 22:25:33 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
using Serein.Library;
|
2024-10-12 22:25:33 +08:00
|
|
|
|
using Serein.Library.Api;
|
2024-10-20 21:59:42 +08:00
|
|
|
|
using Serein.Library.Utils;
|
2024-10-20 12:10:57 +08:00
|
|
|
|
using Serein.NodeFlow.Env;
|
2024-10-13 19:36:45 +08:00
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
|
using System.Reflection;
|
2024-10-20 21:59:42 +08:00
|
|
|
|
using static System.Net.Mime.MediaTypeNames;
|
2024-10-12 22:25:33 +08:00
|
|
|
|
|
|
|
|
|
|
namespace Serein.FlowStartTool
|
|
|
|
|
|
{
|
|
|
|
|
|
public class Program
|
|
|
|
|
|
{
|
2024-12-12 20:47:10 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 运行环境
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private static readonly FlowEnv flowEnv = new FlowEnv();
|
2024-10-12 22:25:33 +08:00
|
|
|
|
public static void Main(string[] args)
|
|
|
|
|
|
{
|
2024-12-12 20:47:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 获取文件路径
|
2024-10-28 10:25:57 +08:00
|
|
|
|
#if debug
|
2024-10-27 00:54:10 +08:00
|
|
|
|
args = [@"F:\临时\project\linux\project.dnf"];
|
|
|
|
|
|
#endif
|
2024-10-13 19:36:45 +08:00
|
|
|
|
Console.WriteLine("Hello :) ");
|
|
|
|
|
|
Console.WriteLine($"args : {string.Join(" , ", args)}");
|
2024-12-12 20:47:10 +08:00
|
|
|
|
|
2024-10-13 19:36:45 +08:00
|
|
|
|
string filePath;
|
|
|
|
|
|
string fileDataPath;
|
|
|
|
|
|
SereinProjectData? flowProjectData;
|
2024-12-12 20:47:10 +08:00
|
|
|
|
string? assembly = Assembly.GetExecutingAssembly()?.Location;
|
|
|
|
|
|
string exeAssemblyDictPath = Path.GetDirectoryName(assembly)!;
|
2024-10-13 19:36:45 +08:00
|
|
|
|
|
2024-12-12 20:47:10 +08:00
|
|
|
|
if (args.Length == 1)
|
2024-10-13 19:36:45 +08:00
|
|
|
|
{
|
|
|
|
|
|
filePath = args[0];
|
|
|
|
|
|
fileDataPath = Path.GetDirectoryName(filePath) ?? "";
|
|
|
|
|
|
}
|
|
|
|
|
|
else if (args.Length == 0)
|
|
|
|
|
|
{
|
2024-10-20 21:59:42 +08:00
|
|
|
|
Console.WriteLine("loading project file data...");
|
2024-10-13 19:36:45 +08:00
|
|
|
|
filePath = Process.GetCurrentProcess().ProcessName + ".dnf";
|
2024-12-12 20:47:10 +08:00
|
|
|
|
|
2024-10-13 19:36:45 +08:00
|
|
|
|
fileDataPath = exeAssemblyDictPath;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
2024-10-12 22:25:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
2024-10-13 19:36:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Console.WriteLine($"Current Name : {filePath}");
|
|
|
|
|
|
Console.WriteLine($"Dict Path : {fileDataPath}");
|
2024-12-12 20:47:10 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 读取项目文件内容
|
2024-10-13 19:36:45 +08:00
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
string content = File.ReadAllText(filePath); // 读取整个文件内容
|
|
|
|
|
|
flowProjectData = JsonConvert.DeserializeObject<SereinProjectData>(content);
|
|
|
|
|
|
if (flowProjectData is null || string.IsNullOrEmpty(fileDataPath))
|
2024-10-12 22:25:33 +08:00
|
|
|
|
{
|
2024-10-13 19:36:45 +08:00
|
|
|
|
throw new Exception("项目文件读取异常");
|
2024-10-12 22:25:33 +08:00
|
|
|
|
}
|
2024-10-13 19:36:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Console.WriteLine($"读取文件时发生错误:{ex.Message}");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
2024-12-12 20:47:10 +08:00
|
|
|
|
#endregion
|
2024-10-13 19:36:45 +08:00
|
|
|
|
|
2024-12-12 20:47:10 +08:00
|
|
|
|
#region 加载项目
|
|
|
|
|
|
_ = Task.Run(async () => await flowEnv.StartFlow(flowProjectData, fileDataPath));
|
|
|
|
|
|
while (flowEnv.IsRuning)
|
2024-10-13 19:36:45 +08:00
|
|
|
|
{
|
2024-10-27 00:54:10 +08:00
|
|
|
|
Console.ReadKey();
|
2024-12-12 20:47:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
2024-10-12 22:25:33 +08:00
|
|
|
|
|
2024-12-12 20:47:10 +08:00
|
|
|
|
}
|
2024-10-12 22:25:33 +08:00
|
|
|
|
|
2024-10-20 21:59:42 +08:00
|
|
|
|
|
2024-10-13 19:36:45 +08:00
|
|
|
|
|
2024-12-12 20:47:10 +08:00
|
|
|
|
|
2024-10-12 22:25:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|