mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-03 00:00:49 +08:00
优化了接口设计,提供Event属性。
This commit is contained in:
@@ -12,48 +12,22 @@ namespace Serein.FlowStartTool
|
|||||||
{
|
{
|
||||||
internal class FlowEnv
|
internal class FlowEnv
|
||||||
{
|
{
|
||||||
public IFlowEnvironment? Env;
|
public readonly IFlowEnvironment flowEnvironment = new FlowEnvironment();
|
||||||
public bool IsRuning;
|
public bool IsRuning;
|
||||||
public async Task StartFlow(SereinProjectData flowProjectData, string fileDataPath)
|
public async Task StartFlow(SereinProjectData flowProjectData, string fileDataPath)
|
||||||
{
|
{
|
||||||
IsRuning = true;
|
IsRuning = true;
|
||||||
SynchronizationContext? uiContext = SynchronizationContext.Current; // 在UI线程上获取UI线程上下文信息
|
SynchronizationContext? uiContext = SynchronizationContext.Current; // 在UI线程上获取UI线程上下文信息
|
||||||
var uIContextOperation = new UIContextOperation(uiContext); // 封装一个调用UI线程的工具类
|
var uIContextOperation = new UIContextOperation(uiContext); // 封装一个调用UI线程的工具类
|
||||||
|
flowEnvironment.SetUIContextOperation(uIContextOperation);
|
||||||
|
flowEnvironment.LoadProject(new FlowEnvInfo { Project = flowProjectData }, fileDataPath); // 加载项目
|
||||||
|
|
||||||
//if (OperatingSystem.IsLinux())
|
flowEnvironment.Event.OnEnvOut += (infoType, value) =>
|
||||||
//{
|
|
||||||
|
|
||||||
//}
|
|
||||||
|
|
||||||
// if (uIContextOperation is null)
|
|
||||||
//{
|
|
||||||
// throw new Exception("无法封装 UIContextOperation ");
|
|
||||||
//}
|
|
||||||
//else
|
|
||||||
//{
|
|
||||||
// env = new FlowEnvironment(uIContextOperation);
|
|
||||||
// this.window = window;
|
|
||||||
//}
|
|
||||||
|
|
||||||
Env = new FlowEnvironment();
|
|
||||||
Env.SetUIContextOperation(uIContextOperation);
|
|
||||||
Env.LoadProject(new FlowEnvInfo { Project = flowProjectData }, fileDataPath); // 加载项目
|
|
||||||
|
|
||||||
if(Env is IFlowEnvironmentEvent @event)
|
|
||||||
{
|
{
|
||||||
// 获取环境输出
|
Console.WriteLine($"{DateTime.Now} [{infoType}] : {value}{Environment.NewLine}");
|
||||||
@event.OnEnvOut += (infoType, value) =>
|
};
|
||||||
{
|
|
||||||
Console.WriteLine($"{DateTime.Now} [{infoType}] : {value}{Environment.NewLine}");
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
await Env.StartRemoteServerAsync(7525); // 启动 web socket 监听远程请求
|
|
||||||
|
|
||||||
//await Env.StartAsync();
|
|
||||||
|
|
||||||
|
await flowEnvironment.StartRemoteServerAsync(7525); // 启动 web socket 监听远程请求
|
||||||
IsRuning = false;
|
IsRuning = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -754,6 +754,12 @@ namespace Serein.Library.Api
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
ISereinIOC IOC { get; }
|
ISereinIOC IOC { get; }
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程事件接口
|
||||||
|
/// </summary>
|
||||||
|
IFlowEnvironmentEvent Event { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 环境名称
|
/// 环境名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -80,7 +80,11 @@ namespace Serein.NodeFlow.Env
|
|||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public NodeMVVMManagement NodeMVVMManagement => currentFlowEnvironment.NodeMVVMManagement;
|
public NodeMVVMManagement NodeMVVMManagement => currentFlowEnvironment.NodeMVVMManagement;
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public ISereinIOC IOC => (ISereinIOC)currentFlowEnvironment;
|
public ISereinIOC IOC => currentFlowEnvironment.IOC;
|
||||||
|
|
||||||
|
/// <inheritdoc/>
|
||||||
|
public IFlowEnvironmentEvent Event => currentFlowEnvironment.Event;
|
||||||
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public string EnvName => currentFlowEnvironment.EnvName;
|
public string EnvName => currentFlowEnvironment.EnvName;
|
||||||
|
|||||||
@@ -224,6 +224,11 @@ namespace Serein.NodeFlow.Env
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IFlowEnvironment CurrentEnv { get => this; }
|
public IFlowEnvironment CurrentEnv { get => this; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程事件
|
||||||
|
/// </summary>
|
||||||
|
public IFlowEnvironmentEvent Event { get => this; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// UI线程操作类
|
/// UI线程操作类
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ namespace Serein.NodeFlow.Env
|
|||||||
|
|
||||||
public ISereinIOC IOC => throw new NotImplementedException();
|
public ISereinIOC IOC => throw new NotImplementedException();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 流程事件
|
||||||
|
/// </summary>
|
||||||
|
public IFlowEnvironmentEvent Event { get => this; }
|
||||||
public string EnvName => LocalFlowEnvironment.SpaceName;
|
public string EnvName => LocalFlowEnvironment.SpaceName;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user