mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-04-11 18:36:34 +08:00
修改了logwindows输出,避免高频输出时卡死。修改了流程运行上下文,使节点具备终止分支运行的能力。
This commit is contained in:
76
FlowStartTool/Program.cs
Normal file
76
FlowStartTool/Program.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using Newtonsoft.Json;
|
||||
using Serein.Library.Api;
|
||||
using Serein.Library.Entity;
|
||||
using Serein.NodeFlow;
|
||||
using System.Diagnostics;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Serein.FlowStartTool
|
||||
{
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
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
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
throw new Exception("项目文件读取异常");
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
30
FlowStartTool/Serein.FlowStartTool.csproj
Normal file
30
FlowStartTool/Serein.FlowStartTool.csproj
Normal file
@@ -0,0 +1,30 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>net8.0</TargetFrameworks>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<AssemblyName>project</AssemblyName>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net8.0|AnyCPU'">
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net8.0|AnyCPU'">
|
||||
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Library\Serein.Library.csproj" />
|
||||
<ProjectReference Include="..\NodeFlow\Serein.NodeFlow.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
Reference in New Issue
Block a user