重新确认开发方向

This commit is contained in:
fengjiayi
2024-10-13 19:36:45 +08:00
parent b166de4aaa
commit f76f09da94
18 changed files with 358 additions and 211 deletions

View File

@@ -2,6 +2,8 @@
using Serein.Library.Api;
using Serein.Library.Entity;
using Serein.NodeFlow;
using System.Diagnostics;
using System.Reflection;
namespace Serein.FlowStartTool
{
@@ -9,50 +11,66 @@ namespace Serein.FlowStartTool
{
public static void Main(string[] args)
{
Console.WriteLine("Hello~");
// 检查是否传入了参数
if (args.Length == 1)
Console.WriteLine("Hello :) ");
Console.WriteLine($"args : {string.Join(" , ", args)}");
string filePath;
string fileDataPath;
SereinProjectData? flowProjectData;
string exeAssemblyDictPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (args.Length == 1)
{
filePath = args[0];
fileDataPath = Path.GetDirectoryName(filePath) ?? "";
}
else if (args.Length == 0)
{
filePath = Process.GetCurrentProcess().ProcessName + ".dnf";
fileDataPath = exeAssemblyDictPath;
}
else
{
// 获取文件路径
string filePath = args[0];
// 检查文件是否存在
if (!File.Exists(filePath))
{
Console.WriteLine($"文件未找到:{filePath}");
return;
}
Console.WriteLine(filePath);
return;
SereinProjectData? flowProjectData;
string fileDataPath;
try
}
Console.WriteLine($"Current Name : {filePath}");
Console.WriteLine($"Dict Path : {fileDataPath}");
try
{
// 读取文件内容
string content = File.ReadAllText(filePath); // 读取整个文件内容
flowProjectData = JsonConvert.DeserializeObject<SereinProjectData>(content);
if (flowProjectData is null || string.IsNullOrEmpty(fileDataPath))
{
// 读取文件内容
string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容
flowProjectData = JsonConvert.DeserializeObject<SereinProjectData>(content);
fileDataPath = System.IO.Path.GetDirectoryName(filePath) ?? "";
if (flowProjectData is null || string.IsNullOrEmpty(fileDataPath))
{
throw new Exception("项目文件读取异常");
}
throw new Exception("项目文件读取异常");
}
catch (Exception ex)
{
Console.WriteLine($"读取文件时发生错误:{ex.Message}");
return;
}
_ = StartFlow(flowProjectData, fileDataPath);
}
catch (Exception ex)
{
Console.WriteLine($"读取文件时发生错误:{ex.Message}");
return;
}
IsRuning = true;
StartFlow(flowProjectData, fileDataPath).GetAwaiter().GetResult();
while (IsRuning)
{
}
}
public static IFlowEnvironment? Env;
public static bool IsRuning;
public static async Task StartFlow(SereinProjectData flowProjectData, string fileDataPath)
{
Env = new FlowEnvironment();
Env.LoadProject(flowProjectData, fileDataPath); // 加载项目
await Env.StartAsync();
IsRuning = false;
}
}
}