取消使用流程上下文自定义的字典数据;更改流程环境接口的输出方式

This commit is contained in:
fengjiayi
2024-11-08 17:30:51 +08:00
parent dff9a00fb6
commit 8c54b9a014
41 changed files with 448 additions and 505 deletions

View File

@@ -33,7 +33,8 @@ namespace Serein.Library.Core
/// <summary>
/// 用来在当前流程上下文间传递数据
/// </summary>
public Dictionary<string, object> ContextShareData { get; } = new Dictionary<string, object>();
//public Dictionary<string, object> ContextShareData { get; } = new Dictionary<string, object>();
public object Tag { get; set; }
/// <summary>
/// 当前节点执行完成后,设置该属性,让运行环境判断接下来要执行哪个分支的节点。
@@ -82,7 +83,6 @@ namespace Serein.Library.Core
}
}
/// <summary>
/// 获取节点当前数据
/// </summary>
@@ -128,7 +128,6 @@ namespace Serein.Library.Core
return null;
}
/// <summary>
/// 结束流程
/// </summary>
@@ -148,26 +147,15 @@ namespace Serein.Library.Core
}
}
foreach (var nodeObj in ContextShareData.Values)
if (Tag != null && typeof(IDisposable).IsAssignableFrom(Tag?.GetType()) && Tag is IDisposable tagDisposable)
{
if (nodeObj is null)
{
continue;
}
else
{
if (typeof(IDisposable).IsAssignableFrom(nodeObj?.GetType()) && nodeObj is IDisposable disposable)
{
disposable?.Dispose();
}
}
tagDisposable?.Dispose();
}
this.Tag = null;
this.dictNodeFlowData?.Clear();
this.ContextShareData?.Clear();
RunState = RunState.Completion;
}
private void Dispose(ref IDictionary<string, object> keyValuePairs)
{
foreach (var nodeObj in keyValuePairs.Values)

View File

@@ -33,7 +33,8 @@ namespace Serein.Library.Framework.NodeFlow
/// <summary>
/// 用来在当前流程上下文间传递数据
/// </summary>
public Dictionary<string, object> ContextShareData { get; } = new Dictionary<string, object>();
//public Dictionary<string, object> ContextShareData { get; } = new Dictionary<string, object>();
public object Tag { get; set; }
/// <summary>
/// 当前节点执行完成后,设置该属性,让运行环境判断接下来要执行哪个分支的节点。
@@ -143,22 +144,13 @@ namespace Serein.Library.Framework.NodeFlow
}
}
}
foreach (var nodeObj in ContextShareData.Values)
if (Tag != null && typeof(IDisposable).IsAssignableFrom(Tag?.GetType()) && Tag is IDisposable tagDisposable)
{
if (nodeObj is null)
{
continue;
}
else
{
if (typeof(IDisposable).IsAssignableFrom(nodeObj?.GetType()) && nodeObj is IDisposable disposable)
{
disposable?.Dispose();
}
}
tagDisposable?.Dispose();
}
this.Tag = null;
this.dictNodeFlowData?.Clear();
this.ContextShareData?.Clear();
RunState = RunState.Completion;
}
// public NodeRunCts NodeRunCts { get; set; }

View File

@@ -24,7 +24,9 @@ namespace Serein.Library.Api
/// <summary>
/// 用来在当前流程上下文间传递数据
/// </summary>
Dictionary<string, object> ContextShareData { get; }
//Dictionary<string, object> ContextShareData { get; }
object Tag { get; set; }
/// <summary>
/// 下一个要执行的节点类别

View File

@@ -89,8 +89,9 @@ namespace Serein.Library.Api
/// <summary>
/// 远程环境内容输出
/// </summary>
/// <param name="type">输出的日志类别</param>
/// <param name="value">输出的文本信息</param>
public delegate void EnvOutHandler(string value);
public delegate void EnvOutHandler(InfoType type, string value);
#endregion
@@ -486,6 +487,7 @@ namespace Serein.Library.Api
public double Y { get; private set; }
}
#endregion
@@ -497,12 +499,16 @@ namespace Serein.Library.Api
public interface IFlowEnvironment
{
#region
/// <summary>
/// <para>单例模式IOC容器内部维护了一个实例字典默认使用类型的FullName作为Key如果以“接口-实现类”的方式注册那么将使用接口类型的FullName作为Key。</para>
/// <para>当某个类型注册绑定成功后,将不会因为其它地方尝试注册相同类型的行为导致类型被重新创建。</para>
/// </summary>
ISereinIOC IOC { get; }
/// <summary>
/// 环境名称
/// </summary>
@@ -520,9 +526,9 @@ namespace Serein.Library.Api
bool IsControlRemoteEnv { get; }
/// <summary>
/// 是否运行在控制台上
/// 信息输出等级
/// </summary>
// bool IsRuningOnConsole { get; }
InfoClass InfoClass { get; set; }
/// <summary>
/// 流程运行状态
@@ -626,13 +632,20 @@ namespace Serein.Library.Api
/// </summary>
// <param name="output"></param>
// <param name="clearMsg"></param>
void SetConsoleOut(); // Action<string> output, Action clearMsg
///void SetConsoleOut(); // Action<string> output, Action clearMsg
/// <summary>
/// 使用JSON处理库输出对象信息
/// 输出信息
/// </summary>
/// <param name="obj"></param>
void WriteLineObjToJson(object obj);
/// <param name="message"></param>
/// <param name="type"></param>
void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial);
///// <summary>
///// 使用JSON处理库输出对象信息
///// </summary>
///// <param name="obj"></param>
//void WriteLineObjToJson(object obj);
/// <summary>
/// 启动远程服务

47
Library/Enums/InfoType.cs Normal file
View File

@@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Library
{
/// <summary>
/// 信息输出等级
/// </summary>
public enum InfoClass
{
/// <summary>
/// 琐碎的
/// </summary>
Trivial,
/// <summary>
/// 一般的
/// </summary>
General,
/// <summary>
/// 重要的
/// </summary>
Important,
}
/// <summary>
/// 信息类别
/// </summary>
public enum InfoType
{
/// <summary>
/// 普通信息
/// </summary>
INFO,
/// <summary>
/// 错误信息(但不影响运行)
/// </summary>
WARN,
/// <summary>
/// 异常信息(影响了运行)
/// </summary>
ERROR,
}
}

View File

@@ -9,6 +9,8 @@ using System.Threading;
namespace Serein.Library
{
/// <summary>
/// 节点基类(数据):条件控件,动作控件,条件区域,动作区域
/// </summary>

View File

@@ -21,6 +21,8 @@ using static Serein.Library.Utils.ChannelFlowInterrupt;
namespace Serein.Library
{
/// <summary>
/// 节点基类(数据):条件控件,动作控件,条件区域,动作区域
/// </summary>
@@ -124,7 +126,8 @@ namespace Serein.Library
{
if(i >= pds.Length)
{
Console.WriteLine($"保存的参数数量大于方法此时的入参参数数量:[{nodeInfo.Guid}][{nodeInfo.MethodName}]");
Env.WriteLine(InfoType.ERROR, $"保存的参数数量大于方法此时的入参参数数量:[{nodeInfo.Guid}][{nodeInfo.MethodName}]");
break;
}
var pd = pds[i];
@@ -269,9 +272,6 @@ namespace Serein.Library
#region
// 首先将指定类别后继分支的所有节点逆序推入栈中
var nextNodes = currentNode.SuccessorNodes[context.NextOrientation];
for (int index = nextNodes.Count - 1; index >= 0; index--)
@@ -350,7 +350,6 @@ namespace Serein.Library
}
object[] parameters;
Array paramsArgs = null; // 初始化可选参数
int paramsArgIndex = 0; // 可选参数下标,与 object[] paramsArgs 一起使用
@@ -533,7 +532,8 @@ namespace Serein.Library
#region
object tmpVaue = null; // 临时存放数据,最后才判断是否放置可选参数数组
if (inputParameter.GetType() == argDataType)
var inputParameterType = inputParameter.GetType();
if (inputParameterType == argDataType)
{
tmpVaue = inputParameter; // 类型一致无需转换,直接装入入参数组
}
@@ -551,12 +551,12 @@ namespace Serein.Library
var valueStr = inputParameter?.ToString();
tmpVaue = valueStr;
}
else if(argDataType.IsSubclassOf(inputParameter.GetType())) // 入参类型 是 预入参数据类型 的 子类/实现类
else if(argDataType.IsSubclassOf(inputParameterType)) // 入参类型 是 预入参数据类型 的 子类/实现类
{
// 方法入参中,父类不能隐式转为子类,这里需要进行强制转换
tmpVaue = ObjectConvertHelper.ConvertParentToChild(inputParameter, argDataType);
}
else if(argDataType.IsAssignableFrom(inputParameter.GetType())) // 入参类型 是 预入参数据类型 的 父类/接口
else if(argDataType.IsAssignableFrom(inputParameterType)) // 入参类型 是 预入参数据类型 的 父类/接口
{
tmpVaue = inputParameter;
}

View File

@@ -195,68 +195,5 @@ namespace Serein.Library
///// <summary>
///// 节点入参参数详情
///// </summary>
//public partial class TempParameterDetails
//{
// private readonly MethodDetails methodDetails;
// /// <summary>
// /// 参数索引
// /// </summary>
// public int Index { get; set; }
// /// <summary>
// /// 是否为显式参数(固定值/表达式)
// /// </summary>
// public bool IsExplicitData { get; set; }
// /// <summary>
// /// 转换器 IEnumConvertor&lt;,&gt;
// /// </summary>
// public Func<object, object> Convertor { get; set; }
// /// <summary>
// /// 显式类型
// /// </summary>
// public Type ExplicitType { get; set; }
// /// <summary>
// /// 目前存在三种状态Select/Bool/Value
// /// <para>Select : 枚举值</para>
// /// <para>Bool : 布尔类型</para>
// /// <para>Value 除以上类型之外的任意参数</para>
// /// </summary>
// public string ExplicitTypeName { get; set; }
// /// <summary>
// /// 方法需要的类型
// /// </summary>
// public Type DataType { get; set; }
// /// <summary>
// /// 方法入参参数名称
// /// </summary>
// public string Name { get; set; }
// private string _dataValue;
// /// <summary>
// /// 入参值在UI上输入的文本内容
// /// </summary>
// public string DataValue
// {
// get => _dataValue; set
// {
// _dataValue = value;
// Console.WriteLine($"更改了{value}");
// }
// }
// /// <summary>
// /// 如果是引用类型,拷贝时不会发生改变。
// /// </summary>
// public string[] Items { get; set; }
//}
}

View File

@@ -106,7 +106,7 @@ namespace Serein.Library.Web
var url = AddRoutesUrl(autoHostingAttribute, routeAttribute, controllerType, method);
if (url is null) continue;
Console.WriteLine(url);
SereinEnv.WriteLine(InfoType.INFO, url);
var apiType = routeAttribute.ApiType.ToString();
var config = new ApiHandleConfig(method);
@@ -248,7 +248,7 @@ namespace Serein.Library.Web
catch (Exception ex1)
{
Console.WriteLine(ex1);
SereinEnv.WriteLine(InfoType.ERROR, ex1.ToString());
}
}

View File

@@ -1,4 +1,5 @@
using System;
using Serein.Library.Utils;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Net;
@@ -54,7 +55,7 @@ namespace Serein.Library.Web
catch(Exception ex)
{
listener = null;
Console.WriteLine(ex);
SereinEnv.WriteLine(InfoType.INFO, ex.ToString());
}
//_ = Task.Run(async () =>
@@ -120,7 +121,7 @@ namespace Serein.Library.Web
// 获取用户的IP地址和端口
IPAddress ipAddress = remoteEndPoint.Address;
int port = remoteEndPoint.Port;
Console.WriteLine("外部连接:" + ipAddress.ToString() + ":" + port);
SereinEnv.WriteLine(InfoType.INFO, "外部连接:" + ipAddress.ToString() + ":" + port);
}
// 停止服务器
@@ -132,9 +133,9 @@ namespace Serein.Library.Web
listener?.Stop(); // 停止监听
listener?.Close(); // 关闭监听器
}
catch (Exception EX)
catch (Exception ex)
{
Console.WriteLine(EX);
SereinEnv.WriteLine(InfoType.ERROR, ex.ToString());
}
}

View File

@@ -1,5 +1,6 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Serein.Library.Utils;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -97,7 +98,7 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
string msgId = jsonObject.GetValue(moduleConfig.MsgIdJsonKey)?.ToString();
if (_myMsgIdHash.Contains(msgId))
{
Console.WriteLine($"[{msgId}]{theme} 消息重复");
SereinEnv.WriteLine(InfoType.WARN, $"[{msgId}]{theme} 消息重复");
return;
}
context.MsgId = msgId; // 添加 ID
@@ -118,7 +119,7 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
}
catch (Exception ex)
{
Console.WriteLine($"error in ws : {ex.Message}{Environment.NewLine}json value:{jsonObject}");
SereinEnv.WriteLine(InfoType.ERROR, $"error in ws : {ex.Message}{Environment.NewLine}json value:{jsonObject}");
}
finally
{

View File

@@ -1,4 +1,5 @@
using System;
using Serein.Library.Utils;
using System;
using System.Collections.Concurrent;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
@@ -169,13 +170,13 @@ namespace Serein.Library.Network.WebSocketCommunication.Handle
return;
}
Console.WriteLine($"add websocket handle model :");
Console.WriteLine($"theme key, data key : {themeKey}, {dataKey}");
SereinEnv.WriteLine(InfoType.INFO, $"add websocket handle model :");
SereinEnv.WriteLine(InfoType.ERROR, $"theme key, data key : {themeKey}, {dataKey}");
foreach (var config in configs)
{
Console.WriteLine($"theme value : {config.ThemeValue} ");
SereinEnv.WriteLine(InfoType.ERROR, $"theme value : {config.ThemeValue} ");
var result = handleModule.AddHandleConfigs(config);
}

View File

@@ -56,17 +56,11 @@ namespace Serein.Library.Network.WebSocketCommunication
/// <summary>
/// 发送消息
/// </summary>
/// <param name="webSocket"></param>
/// <param name="message"></param>
/// <returns></returns>
public async Task SendAsync(string message)
{
//Console.WriteLine("发送消息");
//await Task.Delay(2000);
await SocketExtension.SendAsync(this._client, message); // 回复客户端
//Console.WriteLine();
//var buffer = Encoding.UTF8.GetBytes(message);
//await _client.SendAsync(new ArraySegment<byte>(buffer), WebSocketMessageType.Text, true, CancellationToken.None);
}
/// <summary>

View File

@@ -83,7 +83,7 @@ namespace Serein.Library
{
foreach (var item in value)
{
Console.WriteLine(item);
SereinEnv.WriteLine(InfoType.INFO, item.ToString());
}
return value;
}

View File

@@ -34,31 +34,31 @@ namespace Serein.Library.Utils
foreach (var prop in objType.GetProperties())
{
var value = prop.GetValue(obj);
Console.WriteLine($"{indent}{prop.Name} (Type: {prop.PropertyType.Name}): {value}");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}{prop.Name} (Type: {prop.PropertyType.Name}): {value}");
if (value != null)
{
if (prop.PropertyType.IsArray) // 处理数组类型
{
var array = (Array)value;
Console.WriteLine($"{indent}{prop.Name} is an array with {array.Length} elements:");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}{prop.Name} is an array with {array.Length} elements:");
for (int i = 0; i < array.Length; i++)
{
var element = array.GetValue(i);
if (element != null && element.GetType().IsClass && !(element is string))
{
Console.WriteLine($"{indent}\tArray[{i}] (Type: {element.GetType().Name}) contains a nested object:");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}\tArray[{i}] (Type: {element.GetType().Name}) contains a nested object:");
PrintObjectProperties(element, indent + "\t\t");
}
else
{
Console.WriteLine($"{indent}\tArray[{i}] (Type: {element?.GetType().Name}): {element}");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}\tArray[{i}] (Type: {element?.GetType().Name}): {element}");
}
}
}
else if (value.GetType().IsClass && !(value is string)) // 处理嵌套对象
{
Console.WriteLine($"{indent}{prop.Name} contains a nested object:");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}{prop.Name} contains a nested object:");
PrintObjectProperties(value, indent + "\t");
}
}
@@ -196,7 +196,7 @@ namespace Serein.Library.Utils
if (propInfo == null)
{
// 属性不存在,打印警告并标记失败
Console.WriteLine($"Warning: 属性 '{propName}' 不存在于类型 '{objType.Name}' 中,跳过赋值。");
SereinEnv.WriteLine(InfoType.WARN, $"属性 '{propName}' 不存在于类型 '{objType.Name}' 中,跳过赋值。");
allSuccessful = false;
continue;
}
@@ -206,7 +206,7 @@ namespace Serein.Library.Utils
if (!IsCompatibleType(targetType, propValue))
{
// 如果类型不兼容,打印错误并标记失败
Console.WriteLine($"Error: 无法将类型 '{propValue?.GetType().Name}' 赋值给属性 '{propName}' (Type: {targetType.Name}),跳过赋值。");
SereinEnv.WriteLine(InfoType.ERROR, $"无法将类型 '{propValue?.GetType().Name}' 赋值给属性 '{propName}' (Type: {targetType.Name}),跳过赋值。");
allSuccessful = false;
continue;
}
@@ -257,7 +257,7 @@ namespace Serein.Library.Utils
}
catch (Exception ex)
{
Console.WriteLine($"Error: 为属性 '{propName}' 赋值时发生异常:{ex.Message}");
SereinEnv.WriteLine(InfoType.ERROR, $"为属性 '{propName}' 赋值时发生异常:{ex.Message}");
allSuccessful = false;
}
}

View File

@@ -83,7 +83,7 @@ namespace Serein.Library.Utils
public async Task<bool> ConnectAsync()
{
// 第2种WebSocket连接到远程环境实时接收远程环境的响应
Console.WriteLine($"准备连接:{Config.Addres}:{Config.Port},{Config.Token}");
SereinEnv.WriteLine(InfoType.INFO, $"准备连接:{Config.Addres}:{Config.Port},{Config.Token}");
bool success = false;
try
{
@@ -97,7 +97,7 @@ namespace Serein.Library.Utils
}
if (!success)
{
Console.WriteLine($"无法连通远程端口 {Config.Addres}:{Config.Port}");
SereinEnv.WriteLine(InfoType.ERROR, $"无法连通远程端口 {Config.Addres}:{Config.Port}");
return false;
}
else
@@ -150,7 +150,6 @@ namespace Serein.Library.Utils
};
}
var msg = jsonData.ToString();
//Console.WriteLine($"[{msgId}] => {theme}");
await EnvClient.SendAsync(msg);
}

View File

@@ -0,0 +1,27 @@
using Serein.Library.Api;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Serein.Library.Utils
{
public static class SereinEnv
{
private static IFlowEnvironment environment;
public static void SetEnv(IFlowEnvironment environment)
{
if (environment != null)
{
SereinEnv.environment = environment;
}
}
public static void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial)
{
SereinEnv.environment.WriteLine(type,message,@class);
}
}
}

View File

@@ -74,7 +74,7 @@ namespace Serein.Library.Utils.SereinExpression
}
catch (Exception ex)
{
Console.WriteLine(ex);
SereinEnv.WriteLine(InfoType.ERROR, ex.ToString());
throw;
}
}

View File

@@ -5,6 +5,7 @@ using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
namespace Serein.Library.Utils
{
@@ -130,7 +131,7 @@ namespace Serein.Library.Utils
var instance = Get(type.FullName);
if(instance is null)
{
Console.WriteLine("类型没有注册:" + type.FullName);
SereinEnv.WriteLine(InfoType.INFO, "类型没有注册:" + type.FullName);
}
return Get(type.FullName);
@@ -254,8 +255,8 @@ namespace Serein.Library.Utils
private ConstructorInfo[] GetConstructor(Type type)
{
return type.GetConstructors()
.OrderByDescending(c => c.GetParameters().Length)
.OrderBy(ctor => ctor.GetParameters().Length).ToArray();
//.OrderByDescending(c => c.GetParameters().Length)
.OrderByDescending(ctor => ctor.GetParameters().Length).ToArray();
}
// 生成顺序
@@ -315,11 +316,13 @@ namespace Serein.Library.Utils
var tmpList = indegree.Where(kv => kv.Value > 0).Select(kv => kv.Key).ToList();
if (tmpList.Count > 0)
{
Console.WriteLine("以下类型可能产生循环依赖,请避免循环依赖,如果确实需要循环引用,请使用 [AutoInjection] 特性注入属性");
StringBuilder sb = new StringBuilder();
sb.Append("以下类型可能产生循环依赖,请避免循环依赖,如果确实需要循环引用,请使用 [AutoInjection] 特性注入属性");
foreach (var kv in tmpList)
{
Console.WriteLine($"Class Name : {kv}");
sb.AppendLine($"Class Name : {kv}");
}
SereinEnv.WriteLine(InfoType.ERROR, sb.ToString());
}
return creationOrder;
@@ -369,7 +372,7 @@ namespace Serein.Library.Utils
argObj = CreateInstance(fullName);
if (argObj is null)
{
Console.WriteLine("构造参数创建失败"); //
SereinEnv.WriteLine(InfoType.WARN, "构造参数创建失败");
continue;
}
}

View File

@@ -1,7 +1,9 @@
using Net462DllTest.Signal;
using Net462DllTest.ViewModel;
using Serein.Library;
using Serein.Library.Api;
using Serein.Library.Utils;
using System;
using System.Windows.Forms;
@@ -18,7 +20,7 @@ namespace Net462DllTest
ViewModel = env.IOC.Get<FromWorkBenchViewModel>();
if (ViewModel is null)
{
Console.WriteLine("创建对象并注入依赖项");
SereinEnv.WriteLine(InfoType.INFO, "创建对象并注入依赖项");
ViewModel = env.IOC.Instantiate<FromWorkBenchViewModel>();
}
BindData();

View File

@@ -2,6 +2,7 @@
using Net462DllTest.Enums;
using Net462DllTest.Signal;
using Net462DllTest.Trigger;
using Serein.Library;
using Serein.Library.Utils;
using Serein.Library.Web;
using System;
@@ -36,7 +37,7 @@ namespace Net462DllTest.Web
{
if (EnumHelper.TryConvertEnum<PlcVarName>(var, out var signal))
{
Console.WriteLine($"外部触发 {signal} 信号,信号内容 {value} ");
SereinEnv.WriteLine(InfoType.INFO, $"外部触发 {signal} 信号,信号内容 {value} ");
plcDevice.Trigger(signal, value);// 通过 Web Api 模拟外部输入信号
return new { state = "succeed" };
}
@@ -61,7 +62,7 @@ namespace Net462DllTest.Web
{
if (EnumHelper.TryConvertEnum<CommandSignal>(command, out var signal))
{
Console.WriteLine($"外部触发 {signal} 信号,信号内容 {value} ");
SereinEnv.WriteLine(InfoType.INFO, $"外部触发 {signal} 信号,信号内容 {value} ");
viewManagement.Trigger(signal, value);// 通过 Web Api 模拟外部输入信号
return new { state = "succeed" };
}

View File

@@ -96,7 +96,7 @@ namespace Serein.NodeFlow.Env
}
catch (Exception ex)
{
Console.WriteLine("结束远程管理异常:" + ex);
SereinEnv.WriteLine(InfoType.ERROR, "结束远程管理异常:" + ex);
}
}
@@ -192,6 +192,10 @@ namespace Serein.NodeFlow.Env
/// </summary>
public UIContextOperation UIContextOperation { get; set; }
/// <summary>
/// 信息输出等级
/// </summary>
public InfoClass InfoClass { get ; set ; } = InfoClass.General;
/// <summary>
/// 如果没有全局触发器,且没有循环分支,流程执行完成后自动为 Completion 。
@@ -325,29 +329,44 @@ namespace Serein.NodeFlow.Env
#region
/// <summary>
/// 重定向Console输出
/// </summary>
public void SetConsoleOut()
{
var logTextWriter = new LogTextWriter(msg => Output(msg));
Console.SetOut(logTextWriter);
}
///// <summary>
///// 重定向Console输出
///// </summary>
//public void SetConsoleOut()
//{
// var logTextWriter = new LogTextWriter(msg => Output(msg));
// Console.SetOut(logTextWriter);
//}
/// <summary>
/// 使用JSON处理库输出对象信息
/// 输出信息
/// </summary>
/// <param name="obj"></param>
public void WriteLineObjToJson(object obj)
/// <param name="message">日志内容</param>
/// <param name="type">日志类别</param>
/// <param name="class">日志级别</param>
public void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial)
{
var msg = JsonConvert.SerializeObject(obj);
if (OperatingSystem.IsWindows())
if (@class >= this.InfoClass)
{
UIContextOperation?.Invoke(() => OnEnvOut?.Invoke(msg + Environment.NewLine));
}
OnEnvOut?.Invoke(type, message);
}
///// <summary>
///// 使用JSON处理库输出对象信息
///// </summary>
///// <param name="obj"></param>
//public void WriteLineObjToJson(object obj)
//{
// var msg = JsonConvert.SerializeObject(obj);
// if (OperatingSystem.IsWindows())
// {
// UIContextOperation?.Invoke(() => OnEnvOut?.Invoke(msg + Environment.NewLine));
// }
//}
/// <summary>
/// 异步运行
/// </summary>
@@ -391,7 +410,7 @@ namespace Serein.NodeFlow.Env
if (flowStarter is null)
{
Console.WriteLine("没有启动流程,无法运行单个节点");
SereinEnv.WriteLine(InfoType.ERROR, "没有启动流程,无法运行单个节点");
return;
}
if (true || FlowState == RunState.Running || FlipFlopState == RunState.Running)
@@ -488,7 +507,7 @@ namespace Serein.NodeFlow.Env
var libraryMdss = this.FlowLibraryManagement.GetAllLibraryMds().ToArray();
// 获取当前项目的信息(节点相关的数据)
var project = await GetProjectInfoAsync();
Console.WriteLine("已将当前环境信息发送到远程客户端");
SereinEnv.WriteLine(InfoType.INFO, "已将当前环境信息发送到远程客户端");
return new FlowEnvInfo
{
Project = project, // 项目信息
@@ -747,7 +766,7 @@ namespace Serein.NodeFlow.Env
}
catch (Exception ex)
{
Console.WriteLine($"{ex}");
SereinEnv.WriteLine(InfoType.ERROR, $"无法加载DLL文件{ex}");
}
}
@@ -775,7 +794,7 @@ namespace Serein.NodeFlow.Env
NodeModelBase? node = groupedNodes[i];
sb.AppendLine($"{i} => {node.Guid}");
}
Console.WriteLine($"无法卸载[{assemblyName}]程序集,因为这些节点依赖于此程序集:{sb.ToString()}");
SereinEnv.WriteLine(InfoType.ERROR, $"无法卸载[{assemblyName}]程序集,因为这些节点依赖于此程序集:{sb.ToString()}");
return false;
}
@@ -964,7 +983,7 @@ namespace Serein.NodeFlow.Env
(var type, var state) = CheckConnect(fromNode, toNode, fromNodeJunctionType, toNodeJunctionType);
if (!state)
{
Console.WriteLine("出现非预期的连接行为");
SereinEnv.WriteLine(InfoType.WARN, "出现非预期的连接行为");
return false; // 出现不符预期的连接行为,忽略此次连接行为
}
@@ -1026,7 +1045,7 @@ namespace Serein.NodeFlow.Env
(var type, var state) = CheckConnect(fromNode, toNode, fromNodeJunctionType, toNodeJunctionType);
if (!state)
{
Console.WriteLine("出现非预期的连接行为");
SereinEnv.WriteLine(InfoType.WARN, "出现非预期的连接行为");
return false; // 出现不符预期的连接行为,忽略此次连接行为
}
@@ -1585,99 +1604,6 @@ namespace Serein.NodeFlow.Env
return true;
}
#region
/*/// <summary>
/// 动态加载程序集
/// </summary>
/// <param name="assembly">程序集本身</param>
/// <returns></returns>
private (Dictionary<RegisterSequence, List<Type>>, List<MethodDetails>) LoadAssembly(Assembly assembly)
{
try
{
List<Type> types = assembly.GetTypes().ToList(); // 获取程序集中的所有类型
#region 获取所有需要注册的类型
Dictionary<RegisterSequence, List<Type>> autoRegisterTypes = new Dictionary<RegisterSequence, List<Type>>();
foreach (Type type in types)
{
var autoRegisterAttribute = type.GetCustomAttribute<AutoRegisterAttribute>();
if (autoRegisterAttribute is not null)
{
if (!autoRegisterTypes.TryGetValue(autoRegisterAttribute.Class, out var valus))
{
valus = new List<Type>();
autoRegisterTypes.Add(autoRegisterAttribute.Class, valus);
}
valus.Add(type);
}
}
#endregion
#region 获取 DynamicFlow 特性的流程控制器,如果没有返回空
List<(Type, string)> scanTypes = types.Select(t =>
{
if (t.GetCustomAttribute<DynamicFlowAttribute>() is DynamicFlowAttribute dynamicFlowAttribute
&& dynamicFlowAttribute.Scan == true)
{
return (t, dynamicFlowAttribute.Name);
}
else
{
return (null, null);
}
}).Where(it => it.t is not null).ToList();
if (scanTypes.Count == 0)
{
return ([], []);
}
#endregion
#region 创建对应的方法元数据
List<MethodDetails> methodDetails = new List<MethodDetails>();
// 遍历扫描的类型
foreach ((var type, var flowName) in scanTypes)
{
// 加载DLL创建 MethodDetails、实例作用对象、委托方法
var assemblyName = type.Assembly.GetName().Name;
if (string.IsNullOrEmpty(assemblyName))
{
continue;
}
var methods = NodeMethodDetailsHelper.GetMethodsToProcess(type);
foreach (var method in methods)
{
(var md, var del) = NodeMethodDetailsHelper.CreateMethodDetails(type, method, assemblyName);
if (md is null || del is null)
{
Console.WriteLine($"无法加载方法信息:{assemblyName}-{type}-{method}");
continue;
}
md.MethodAnotherName = flowName + md.MethodAnotherName;
if (MethodDelegates.TryAdd(md.MethodName, del))
{
methodDetails.Add(md);
}
else
{
Console.WriteLine($"节点委托创建失败:{md.MethodName}");
}
}
}
#endregion
return (autoRegisterTypes, methodDetails);
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
return ([], []);
}
}*/
#endregion
/// <summary>
/// 创建节点
@@ -1801,7 +1727,7 @@ namespace Serein.NodeFlow.Env
FromExistInTo = ToOnF.Length > 0;
if (ToExistOnFrom && FromExistInTo)
{
Console.WriteLine("起始节点已与目标节点存在连接");
SereinEnv.WriteLine(InfoType.WARN, "起始节点已与目标节点存在连接");
isPass = false;
}
else
@@ -1809,13 +1735,13 @@ namespace Serein.NodeFlow.Env
// 检查是否可能存在异常
if (!ToExistOnFrom && FromExistInTo)
{
Console.WriteLine("目标节点不是起始节点的子节点,起始节点却是目标节点的父节点");
SereinEnv.WriteLine(InfoType.WARN, "目标节点不是起始节点的子节点,起始节点却是目标节点的父节点");
isPass = false;
}
else if (ToExistOnFrom && !FromExistInTo)
{
//
Console.WriteLine(" 起始节点不是目标节点的父节点,目标节点却是起始节点的子节点");
SereinEnv.WriteLine(InfoType.WARN, " 起始节点不是目标节点的父节点,目标节点却是起始节点的子节点");
isPass = false;
}
else
@@ -1871,16 +1797,6 @@ namespace Serein.NodeFlow.Env
if (!string.IsNullOrEmpty(toNodeArgSourceGuid))
{
await RemoteConnectAsync(fromNode, toNode, argIndex);
//Console.WriteLine("目标入参已确定参数来源,不可连接");
//return false;
//if (toNodeArgSourceGuid.Equals(fromNode.Guid))
//{
// //await RemoteConnectAsync(fromNode, toNode, argIndex); // 相同起始节点不同控制点已经连接,将其移除
//}
//else
//{
//}
}
toNode.MethodDetails.ParameterDetailss[argIndex].ArgDataSourceNodeGuid = fromNode.Guid;
toNode.MethodDetails.ParameterDetailss[argIndex].ArgDataSourceType = connectionArgSourceType;
@@ -1914,18 +1830,18 @@ namespace Serein.NodeFlow.Env
}
/// <summary>
/// 输出内容
/// </summary>
/// <param name="msg"></param>
private void Output(string msg)
{
if (OperatingSystem.IsWindows())
{
UIContextOperation?.Invoke(() => OnEnvOut?.Invoke(msg));
}
///// <summary>
///// 输出内容
///// </summary>
///// <param name="msg"></param>
//private void Output(string msg)
//{
// if (OperatingSystem.IsWindows())
// {
// UIContextOperation?.Invoke(() => OnEnvOut?.Invoke(msg));
// }
}
//}
#endregion

View File

@@ -16,6 +16,8 @@ namespace Serein.NodeFlow.Env
flowEnvironment = new FlowEnvironment(uiContextOperation);
// 默认使用本地环境
currentFlowEnvironment = flowEnvironment;
SereinEnv.SetEnv(currentFlowEnvironment);
}
/// <summary>
@@ -65,14 +67,18 @@ namespace Serein.NodeFlow.Env
public UIContextOperation UIContextOperation => currentFlowEnvironment.UIContextOperation;
public ISereinIOC IOC => (ISereinIOC)currentFlowEnvironment;
public string EnvName => currentFlowEnvironment.EnvName;
public bool IsGlobalInterrupt => currentFlowEnvironment.IsGlobalInterrupt;
public bool IsControlRemoteEnv => currentFlowEnvironment.IsControlRemoteEnv;
/// <summary>
/// 信息输出等级
/// </summary>
public InfoClass InfoClass { get => currentFlowEnvironment.InfoClass; set => currentFlowEnvironment.InfoClass = value; }
public RunState FlowState { get => currentFlowEnvironment.FlowState; set => currentFlowEnvironment.FlowState = value; }
public RunState FlipFlopState { get => currentFlowEnvironment.FlipFlopState; set => currentFlowEnvironment.FlipFlopState = value; }
@@ -335,9 +341,20 @@ namespace Serein.NodeFlow.Env
}
public void SetConsoleOut()
//public void SetConsoleOut()
//{
// currentFlowEnvironment.SetConsoleOut();
//}
/// <summary>
/// 输出信息
/// </summary>
/// <param name="message">日志内容</param>
/// <param name="type">日志类别</param>
/// <param name="class">日志级别</param>
public void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial)
{
currentFlowEnvironment.SetConsoleOut();
currentFlowEnvironment.WriteLine(type, message, @class);
}
public void SetMonitorObjState(string key, bool isMonitor)
@@ -400,10 +417,10 @@ namespace Serein.NodeFlow.Env
return currentFlowEnvironment.TryGetMethodDetailsInfo(libraryName, methodName, out mdInfo);
}
public void WriteLineObjToJson(object obj)
{
currentFlowEnvironment.WriteLineObjToJson(obj);
}
//public void WriteLineObjToJson(object obj)
//{
// currentFlowEnvironment.WriteLineObjToJson(obj);
//}
/// <summary>
/// (用于远程)通知节点属性变更

View File

@@ -50,7 +50,7 @@ namespace Serein.NodeFlow.Env
{
var msgId = MsgIdHelper.GenerateId().ToString();
Console.WriteLine($"[{msgId}] => {theme}");
SereinEnv.WriteLine(InfoType.INFO, $"[{msgId}] => {theme}");
await SendCommandAsync(msgId, theme, data); // 客户端发送消息
}

View File

@@ -61,7 +61,7 @@ namespace Serein.NodeFlow.Env
{
if (string.IsNullOrEmpty(token))
{
Console.WriteLine("当前没有设置token但使用了token验证的服务端");
SereinEnv.WriteLine(InfoType.WARN, "当前没有设置token但使用了token验证的服务端");
}
this.environment = environment;
@@ -96,7 +96,7 @@ namespace Serein.NodeFlow.Env
catch (Exception ex)
{
FlowEnvRemoteWebSocket.MsgHandleHelper.RemoveModule(this);
Console.WriteLine("打开远程管理异常:" + ex);
SereinEnv.WriteLine(InfoType.ERROR, "打开远程管理异常:" + ex);
}
}
@@ -112,7 +112,7 @@ namespace Serein.NodeFlow.Env
}
catch (Exception ex)
{
Console.WriteLine("结束远程管理异常:" + ex);
SereinEnv.WriteLine(InfoType.ERROR, "结束远程管理异常:" + ex);
}
}
@@ -263,7 +263,7 @@ namespace Serein.NodeFlow.Env
// [AutoSocketHandle]
public void ExitRemoteEnv()
{
Console.WriteLine("暂未实现远程退出远程环境");
SereinEnv.WriteLine(InfoType.ERROR, "暂未实现远程退出远程环境");
IsLcR = false;
}
@@ -385,10 +385,9 @@ namespace Serein.NodeFlow.Env
{
return new { state = false }; // 非预期的控制点连接
}
Console.WriteLine();
Console.WriteLine($"起始节点:{fromNodeGuid}");
Console.WriteLine($"目标节点:{toNodeGuid}");
Console.WriteLine($"链接请求:{(tmpFromJunctionType, tmpToJunctionType)}");
SereinEnv.WriteLine(InfoType.INFO, $"起始节点:{fromNodeGuid}");
SereinEnv.WriteLine(InfoType.INFO, $"目标节点:{toNodeGuid}");
SereinEnv.WriteLine(InfoType.INFO, $"链接请求:{(tmpFromJunctionType, tmpToJunctionType)}");
var result = await environment.ConnectInvokeNodeAsync(fromNodeGuid, toNodeGuid, tmpFromJunctionType, tmpToJunctionType, tmpConnectionType);
return new { state = result };
@@ -477,10 +476,7 @@ namespace Serein.NodeFlow.Env
{
return new { state = false }; // 非预期的控制点连接
}
//Console.WriteLine();
//Console.WriteLine($"起始节点:{fromNodeGuid}");
//Console.WriteLine($"目标节点:{toNodeGuid}");
//Console.WriteLine($"链接请求:{(tmpFromJunctionType, tmpToJunctionType)}");
// 调用环境接口进行连接
var result = await environment.ConnectArgSourceNodeAsync(fromNodeGuid, toNodeGuid, tmpFromJunctionType, tmpToJunctionType, tmpArgSourceType, argIndex);
return new { state = result };

View File

@@ -66,6 +66,10 @@ namespace Serein.NodeFlow.Env
public bool IsControlRemoteEnv => true;
/// <summary>
/// 信息输出等级
/// </summary>
public InfoClass InfoClass { get; set; }
public RunState FlowState { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public RunState FlipFlopState { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
@@ -82,28 +86,40 @@ namespace Serein.NodeFlow.Env
/// </summary>
private bool IsLoadingNode = false;
public void SetConsoleOut()
//public void SetConsoleOut()
//{
// var logTextWriter = new LogTextWriter(msg =>
// {
// OnEnvOut?.Invoke(msg);
// });
// Console.SetOut(logTextWriter);
//}
/// <summary>
/// 输出信息
/// </summary>
/// <param name="message">日志内容</param>
/// <param name="type">日志类别</param>
/// <param name="class">日志级别</param>
public void WriteLine(InfoType type, string message, InfoClass @class = InfoClass.Trivial)
{
var logTextWriter = new LogTextWriter(msg =>
{
OnEnvOut?.Invoke(msg);
});
Console.SetOut(logTextWriter);
OnEnvOut?.Invoke(type, message);
}
public void WriteLineObjToJson(object obj)
{
Console.WriteLine("远程环境尚未实现的接口WriteLineObjToJson");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口WriteLineObjToJson");
}
public async Task StartRemoteServerAsync(int port = 7525)
{
await Console.Out.WriteLineAsync("远程环境尚未实现的接口StartRemoteServerAsync");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口StartRemoteServerAsync");
await Task.CompletedTask;
}
public void StopRemoteServer()
{
Console.WriteLine("远程环境尚未实现的接口StopRemoteServer");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口StopRemoteServer");
}
public async Task<SereinProjectData> GetProjectInfoAsync()
@@ -119,7 +135,7 @@ namespace Serein.NodeFlow.Env
/// <param name="filePath"></param>
public void LoadProject(FlowEnvInfo flowEnvInfo, string filePath)
{
Console.WriteLine("加载远程环境");
this.WriteLine(InfoType.INFO, "加载远程环境");
IsLoadingProject = true;
#region DLL功能区创建
var libmds = flowEnvInfo.LibraryMds;
@@ -339,7 +355,7 @@ namespace Serein.NodeFlow.Env
FromExistInTo = ToOnF.Length > 0;
if (ToExistOnFrom && FromExistInTo)
{
Console.WriteLine("起始节点已与目标节点存在连接");
this.WriteLine(InfoType.ERROR, "起始节点已与目标节点存在连接");
//return;
}
@@ -348,13 +364,13 @@ namespace Serein.NodeFlow.Env
// 检查是否可能存在异常
if (!ToExistOnFrom && FromExistInTo)
{
Console.WriteLine("目标节点不是起始节点的子节点,起始节点却是目标节点的父节点");
this.WriteLine(InfoType.ERROR, "目标节点不是起始节点的子节点,起始节点却是目标节点的父节点");
return;
}
else if (ToExistOnFrom && !FromExistInTo)
{
//
Console.WriteLine(" 起始节点不是目标节点的父节点,目标节点却是起始节点的子节点");
this.WriteLine(InfoType.ERROR, " 起始节点不是目标节点的父节点,目标节点却是起始节点的子节点");
return;
}
else // if (!ToExistOnFrom && !FromExistInTo)
@@ -394,25 +410,25 @@ namespace Serein.NodeFlow.Env
public void ExitRemoteEnv()
{
Console.WriteLine("远程环境尚未实现的接口ExitRemoteEnv");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口ExitRemoteEnv");
}
public void LoadLibrary(string dllPath)
{
// 将dll文件发送到远程环境由远程环境进行加载
Console.WriteLine("远程环境尚未实现的接口LoadDll");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口LoadDll");
}
public bool UnloadLibrary(string assemblyName)
{
// 尝试移除远程环境中的加载了的依赖
Console.WriteLine("远程环境尚未实现的接口RemoteDll");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口RemoteDll");
return false;
}
public void ClearAll()
{
Console.WriteLine("远程环境尚未实现的接口ClearAll");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口ClearAll");
}
public async Task StartAsync()
@@ -467,7 +483,7 @@ namespace Serein.NodeFlow.Env
public async Task<object> InvokeNodeAsync(IDynamicContext context, string nodeGuid)
{
Console.WriteLine("远程环境尚未实现接口 InvokeNodeAsync");
this.WriteLine(InfoType.INFO, "远程环境尚未实现接口 InvokeNodeAsync");
_ = msgClient.SendAsync(EnvMsgTheme.SetStartNode, new
{
nodeGuid
@@ -717,7 +733,7 @@ namespace Serein.NodeFlow.Env
}
else
{
Console.WriteLine("删除失败");
this.WriteLine(InfoType.ERROR, "删除失败");
}
return result;
}
@@ -763,7 +779,7 @@ namespace Serein.NodeFlow.Env
public void SetMonitorObjState(string key, bool isMonitor)
{
Console.WriteLine("远程环境尚未实现的接口SetMonitorObjState");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口SetMonitorObjState");
}
public async Task<(bool, string[])> CheckObjMonitorStateAsync(string key)
@@ -788,20 +804,20 @@ namespace Serein.NodeFlow.Env
public async Task<ChannelFlowInterrupt.CancelType> GetOrCreateGlobalInterruptAsync()
{
await Console.Out.WriteLineAsync("远程环境尚未实现的接口GetOrCreateGlobalInterruptAsync");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口GetOrCreateGlobalInterruptAsync");
return ChannelFlowInterrupt.CancelType.Error;
}
public bool TryGetMethodDetailsInfo(string libraryName, string methodName, out MethodDetailsInfo mdInfo)
{
Console.WriteLine("远程环境尚未实现的接口TryGetMethodDetailsInfo");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口TryGetMethodDetailsInfo");
mdInfo = null;
return false;
}
public bool TryGetDelegateDetails(string libraryName, string methodName, out DelegateDetails del)
{
Console.WriteLine("远程环境尚未实现的接口TryGetDelegateDetails");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口TryGetDelegateDetails");
del = null;
return false;
}
@@ -810,13 +826,13 @@ namespace Serein.NodeFlow.Env
public void MonitorObjectNotification(string nodeGuid, object monitorData, MonitorObjectEventArgs.ObjSourceType sourceType)
{
Console.WriteLine("远程环境尚未实现的接口MonitorObjectNotification");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口MonitorObjectNotification");
}
public void TriggerInterrupt(string nodeGuid, string expression, InterruptTriggerEventArgs.InterruptTriggerType type)
{
Console.WriteLine("远程环境尚未实现的接口TriggerInterrupt");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口TriggerInterrupt");
}
public void NodeLocated(string nodeGuid)
@@ -832,7 +848,7 @@ namespace Serein.NodeFlow.Env
{
return;
}
Console.WriteLine($"通知远程环境修改节点数据:{nodeGuid},name:{path},value:{value}");
this.WriteLine(InfoType.INFO, $"通知远程环境修改节点数据:{nodeGuid},name:{path},value:{value}");
_ = msgClient.SendAsync(EnvMsgTheme.ValueNotification, new
{
@@ -852,7 +868,7 @@ namespace Serein.NodeFlow.Env
/// <returns></returns>
public async Task<bool> ChangeParameter(string nodeGuid, bool isAdd, int paramIndex)
{
Console.WriteLine("远程环境尚未实现的接口ChangeParameter");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口ChangeParameter");
return false;
}
@@ -865,7 +881,7 @@ namespace Serein.NodeFlow.Env
/// <returns></returns>
public bool LoadNativeLibraryOfRuning(string file)
{
Console.WriteLine("远程环境尚未实现的接口LoadNativeLibraryOfRuning");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口LoadNativeLibraryOfRuning");
return false;
}
@@ -876,7 +892,7 @@ namespace Serein.NodeFlow.Env
/// <param name="isRecurrence">是否递归加载</param>
public void LoadAllNativeLibraryOfRuning(string path, bool isRecurrence = true)
{
Console.WriteLine("远程环境尚未实现的接口LoadAllNativeLibraryOfRuning");
this.WriteLine(InfoType.INFO, "远程环境尚未实现的接口LoadAllNativeLibraryOfRuning");
}
#endregion

View File

@@ -290,7 +290,7 @@ namespace Serein.NodeFlow
finally
{
env.FlowState = RunState.Completion;
Console.WriteLine($"流程运行完毕{Environment.NewLine}");;
SereinEnv.WriteLine(InfoType.INFO, $"流程运行完毕{Environment.NewLine}");;
}
#endregion
}
@@ -355,14 +355,15 @@ namespace Serein.NodeFlow
{
if(_flipFlopCts is null)
{
Console.WriteLine("flowStarter -> FlipflopExecuteAsync -> _flipFlopCts is null");
SereinEnv.WriteLine(InfoType.INFO, "流程尚未启动flowStarter尚未创建无法启动该节点");
return;
}
while (!_flipFlopCts.IsCancellationRequested && !cts.IsCancellationRequested)
{
var context = new DynamicContext(env); // 启动全局触发器时新建上下文
try
{
var context = new DynamicContext(env); // 启动全局触发器时新建上下文
var newFlowData = await singleFlipFlopNode.ExecutingAsync(context); // 获取触发器等待Task
context.AddOrUpdate(singleFlipFlopNode.Guid, newFlowData);
await NodeModelBase.RefreshFlowDataAndExpInterrupt(context, singleFlipFlopNode, newFlowData); // 全局触发器触发后刷新该触发器的节点数据

View File

@@ -1,5 +1,6 @@
using Serein.Library;
using Serein.Library.Api;
using Serein.Library.Utils;
namespace Serein.NodeFlow.Model
@@ -34,7 +35,7 @@ namespace Serein.NodeFlow.Model
/// </summary>
public override void OnCreating()
{
Console.WriteLine("CompositeConditionNode 暂未实现 OnLoading");
SereinEnv.WriteLine(InfoType.WARN, "CompositeConditionNode 暂未实现 OnLoading");
}
public void AddNode(SingleConditionNode node)
@@ -72,7 +73,7 @@ namespace Serein.NodeFlow.Model
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
SereinEnv.WriteLine(InfoType.WARN, ex.Message);
context.NextOrientation = ConnectionInvokeType.IsError;
context.ExceptionOfRuning = ex;
return context.TransmissionData(this); // 条件区域透传上一节点的数据

View File

@@ -19,7 +19,6 @@ namespace Serein.NodeFlow.Model
/// </summary>
public override void OnCreating()
{
// Console.WriteLine("SingleActionNode 暂未实现 OnLoading");
}
public override ParameterData[] GetParameterdatas()

View File

@@ -110,8 +110,8 @@ namespace Serein.NodeFlow.Model
context.NextOrientation = ConnectionInvokeType.IsError;
context.ExceptionOfRuning = ex;
}
Console.WriteLine($"{result} {Expression} -> " + context.NextOrientation);
SereinEnv.WriteLine(InfoType.INFO, $"{result} {Expression} -> " + context.NextOrientation);
return result;
}

View File

@@ -81,7 +81,6 @@ namespace Serein.NodeFlow.Model
try
{
var newData = SerinExpressionEvaluator.Evaluate(Expression, parameter, out bool isChange);
Console.WriteLine(newData);
object? result = null;
if (isChange)
{

View File

@@ -21,7 +21,6 @@ namespace Serein.NodeFlow.Model
/// </summary>
public override void OnCreating()
{
// Console.WriteLine("SingleFlipflopNode 暂未实现 OnLoading");
}

View File

@@ -1,4 +1,5 @@
using Serein.Library;
using Serein.Library.Utils;
using Serein.NodeFlow.Tool;
using System;
using System.Collections.Concurrent;
@@ -104,109 +105,97 @@ namespace Serein.NodeFlow
var loaderExceptions = ex.LoaderExceptions;
foreach (var loaderException in loaderExceptions)
{
Console.WriteLine(loaderException.Message);
SereinEnv.WriteLine(InfoType.ERROR, loaderException.Message);
}
return false;
}
#endregion
try
#region DynamicFlow 退
// Type 具有 DynamicFlowAttribute 标记的类型
// string 类型元数据 DynamicFlowAttribute 特性中的 Name 属性 (用于生成方法描述时,添加在方法别名中提高可读性)
List<(Type Type, string Name)> scanTypes = new List<(Type Type, string Name)>();
// (Type, string)
// Type 具有 DynamicFlowAttribute 标记的类型
// string 类型元数据 DynamicFlowAttribute 特性中的 Name 属性
types = types.Where(type => type.GetCustomAttribute<DynamicFlowAttribute>() is DynamicFlowAttribute dynamicFlowAttribute
&& dynamicFlowAttribute.Scan).ToList();
foreach (var type in types)
{
#region DynamicFlow 退
// Type 具有 DynamicFlowAttribute 标记的类型
// string 类型元数据 DynamicFlowAttribute 特性中的 Name 属性 (用于生成方法描述时,添加在方法别名中提高可读性)
List<(Type Type, string Name)> scanTypes = new List<(Type Type, string Name)>();
// (Type, string)
// Type 具有 DynamicFlowAttribute 标记的类型
// string 类型元数据 DynamicFlowAttribute 特性中的 Name 属性
types = types.Where(type => type.GetCustomAttribute<DynamicFlowAttribute>() is DynamicFlowAttribute dynamicFlowAttribute
&& dynamicFlowAttribute.Scan).ToList();
foreach (var type in types)
if (type.GetCustomAttribute<DynamicFlowAttribute>() is DynamicFlowAttribute dynamicFlowAttribute)
{
if (type.GetCustomAttribute<DynamicFlowAttribute>() is DynamicFlowAttribute dynamicFlowAttribute)
{
scanTypes.Add((type, dynamicFlowAttribute.Name));
}
scanTypes.Add((type, dynamicFlowAttribute.Name));
}
if (scanTypes.Count == 0)
{
// 类型没有流程控制器
return false;
}
#endregion
#region
// 从 scanTypes.Type 创建的方法信息
// Md : 方法描述
// Dd 方法对应的Emit委托
List<(MethodDetails Md, DelegateDetails Dd)> detailss = new List<(MethodDetails Md, DelegateDetails Dd)>();
// 遍历扫描的类型
foreach ((var type, var flowName) in scanTypes)
{
var methodInfos = NodeMethodDetailsHelper.GetMethodsToProcess(type);
foreach (var methodInfo in methodInfos) // 遍历流程控制器类型中的方法信息
{
// 尝试创建
if (!NodeMethodDetailsHelper.TryCreateDetails(type, methodInfo, assemblyName,
out var md, out var dd)) // 返回的描述
{
Console.WriteLine($"无法加载方法信息:{assemblyName}-{type}-{methodInfo}");
continue;
}
md.MethodAnotherName = flowName + md.MethodAnotherName; // 方法别名
detailss.Add((md, dd));
}
}
#endregion
#region
if(detailss.Count == 0)
{
return false;
}
#region
foreach((var md,var dd) in detailss)
{
MethodDetailss.TryAdd(md.MethodName, md);
DelegateDetailss.TryAdd(md.MethodName, dd);
}
#endregion
#region
foreach (Type type in types)
{
if (type.GetCustomAttribute<AutoRegisterAttribute>() is AutoRegisterAttribute attribute)
{
if (!RegisterTypes.TryGetValue(attribute.Class, out var valus))
{
valus = new List<Type>();
RegisterTypes.TryAdd(attribute.Class, valus);
}
valus.Add(type);
}
}
#endregion
#endregion
return true;
}
catch (Exception ex)
if (scanTypes.Count == 0)
{
Console.WriteLine(ex.ToString());
// 类型没有流程控制器
return false;
}
#endregion
#region
// 从 scanTypes.Type 创建的方法信息
// Md : 方法描述
// Dd 方法对应的Emit委托
List<(MethodDetails Md, DelegateDetails Dd)> detailss = new List<(MethodDetails Md, DelegateDetails Dd)>();
// 遍历扫描的类型
foreach ((var type, var flowName) in scanTypes)
{
var methodInfos = NodeMethodDetailsHelper.GetMethodsToProcess(type);
foreach (var methodInfo in methodInfos) // 遍历流程控制器类型中的方法信息
{
// 尝试创建
if (!NodeMethodDetailsHelper.TryCreateDetails(type, methodInfo, assemblyName,
out var md, out var dd)) // 返回的描述
{
SereinEnv.WriteLine(InfoType.ERROR, $"无法加载方法信息:{assemblyName}-{type}-{methodInfo}");
continue;
}
md.MethodAnotherName = flowName + md.MethodAnotherName; // 方法别名
detailss.Add((md, dd));
}
}
#endregion
#region
if (detailss.Count == 0)
{
return false;
}
#region
foreach ((var md, var dd) in detailss)
{
MethodDetailss.TryAdd(md.MethodName, md);
DelegateDetailss.TryAdd(md.MethodName, dd);
}
#endregion
#region
foreach (Type type in types)
{
if (type.GetCustomAttribute<AutoRegisterAttribute>() is AutoRegisterAttribute attribute)
{
if (!RegisterTypes.TryGetValue(attribute.Class, out var valus))
{
valus = new List<Type>();
RegisterTypes.TryAdd(attribute.Class, valus);
}
valus.Add(type);
}
}
#endregion
#endregion
return true;
}

View File

@@ -1,6 +1,7 @@
using Serein.Library;
using Serein.Library.Api;
using Serein.Library.FlowNode;
using Serein.Library.Utils;
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
@@ -58,7 +59,7 @@ namespace Serein.NodeFlow.Tool
}
catch (Exception ex)
{
Console.WriteLine($"尝试卸载程序集[{assemblyName}]发生错误:{ex}");
SereinEnv.WriteLine(InfoType.ERROR, $"尝试卸载程序集[{assemblyName}]发生错误:{ex}");
return false;
}
@@ -210,7 +211,7 @@ namespace Serein.NodeFlow.Tool
{
return LoadAssembly(typeof(IFlowEnvironment).Assembly, () => {
//Console.WriteLine("基础模块不能卸载");
//SereinEnv.PrintInfo(InfoType.WRAN, "基础模块不能卸载");
});
}
else

View File

@@ -1,4 +1,6 @@
using System;
using Serein.Library;
using Serein.Library.Utils;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -58,7 +60,7 @@ namespace Serein.NodeFlow.Tool
}
else
{
Console.WriteLine("Unsupported OS.");
SereinEnv.WriteLine(InfoType.ERROR, "非预期的OS系统");
return false;
}
}
@@ -82,7 +84,7 @@ namespace Serein.NodeFlow.Tool
}
else
{
Console.WriteLine("Unsupported OS.");
SereinEnv.WriteLine(InfoType.ERROR, "非预期的OS系统");
}
foreach (var dir in Directory.GetDirectories(path))
@@ -108,18 +110,18 @@ namespace Serein.NodeFlow.Tool
if (hModule != IntPtr.Zero)
{
Nints.Add(hModule);
Console.WriteLine($"Loaded: {file}");
SereinEnv.WriteLine(InfoType.INFO, $"Loaded: {file}");
return true;
}
else
{
Console.WriteLine($"Failed to load {file}: {Marshal.GetLastWin32Error()}");
SereinEnv.WriteLine(InfoType.INFO, $"Failed to load {file}: {Marshal.GetLastWin32Error()}");
return false;
}
}
catch (Exception ex)
{
Console.WriteLine($"Error loading {file}: {ex.Message}");
SereinEnv.WriteLine(InfoType.ERROR, $"Error loading {file}: {ex.Message}");
return false;
}
}
@@ -140,20 +142,20 @@ namespace Serein.NodeFlow.Tool
if (handle != IntPtr.Zero)
{
Nints.Add(handle);
Console.WriteLine($"Loaded: {file}");
SereinEnv.WriteLine(InfoType.INFO, $"Loaded: {file}");
return true;
// 可以调用共享库中的函数
// IntPtr procAddress = dlsym(handle, "my_function");
}
else
{
Console.WriteLine($"Failed to load {file}: {Marshal.GetLastWin32Error()}");
SereinEnv.WriteLine(InfoType.INFO, $"Failed to load {file}: {Marshal.GetLastWin32Error()}");
return false;
}
}
catch (Exception ex)
{
Console.WriteLine($"Error loading {file}: {ex.Message}");
SereinEnv.WriteLine(InfoType.ERROR, $"Error loading {file}: {ex.Message}");
return false;
}

View File

@@ -46,8 +46,8 @@ public static class NodeMethodDetailsHelper
return false;
}
var methodName = $"{assemblyName}.{type.Name}.{methodInfo.Name}";
Console.WriteLine("loading method : " + methodName);
var methodName = $"{assemblyName}.{type.Name}.{methodInfo.Name}";
SereinEnv.WriteLine(InfoType.INFO, "loading method : " + methodName);
// 创建参数信息
var explicitDataOfParameters = GetExplicitDataOfParameters(methodInfo.GetParameters());
@@ -78,7 +78,7 @@ public static class NodeMethodDetailsHelper
}
else
{
Console.WriteLine($"[{methodName}]跳过创建返回类型非预期的Task<IFlipflopContext<TResult>>。");
SereinEnv.WriteLine(InfoType.WARN, $"[{methodName}]跳过创建返回类型非预期的Task<IFlipflopContext<TResult>>。");
methodDetails = null;
delegateDetails = null;
return false;
@@ -86,7 +86,7 @@ public static class NodeMethodDetailsHelper
}
else
{
Console.WriteLine($"[{methodName}]跳过创建因为触发器方法的返回值并非Task<>,将无法等待。");
SereinEnv.WriteLine(InfoType.WARN, $"[{methodName}]跳过创建因为触发器方法的返回值并非Task<>,将无法等待。");
methodDetails = null;
delegateDetails = null;
return false;

View File

@@ -1,4 +1,6 @@
using System.Reflection;
using Serein.Library;
using Serein.Library.Utils;
using System.Reflection;
using System.Reflection.Emit;
@@ -31,31 +33,31 @@ namespace Serein.NodeFlow.Tool
foreach (var prop in objType.GetProperties())
{
var value = prop.GetValue(obj);
Console.WriteLine($"{indent}{prop.Name} (Type: {prop.PropertyType.Name}): {value}");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}{prop.Name} (Type: {prop.PropertyType.Name}): {value}");
if (value != null)
{
if (prop.PropertyType.IsArray) // 处理数组类型
{
var array = (Array)value;
Console.WriteLine($"{indent}{prop.Name} is an array with {array.Length} elements:");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}{prop.Name} is an array with {array.Length} elements:");
for (int i = 0; i < array.Length; i++)
{
var element = array.GetValue(i);
if (element != null && element.GetType().IsClass && !(element is string))
{
Console.WriteLine($"{indent}\tArray[{i}] (Type: {element.GetType().Name}) contains a nested object:");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}\tArray[{i}] (Type: {element.GetType().Name}) contains a nested object:");
PrintObjectProperties(element, indent + "\t\t");
}
else
{
Console.WriteLine($"{indent}\tArray[{i}] (Type: {element?.GetType().Name}): {element}");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}\tArray[{i}] (Type: {element?.GetType().Name}): {element}");
}
}
}
else if (value.GetType().IsClass && !(value is string)) // 处理嵌套对象
{
Console.WriteLine($"{indent}{prop.Name} contains a nested object:");
SereinEnv.WriteLine(InfoType.INFO, $"{indent}{prop.Name} contains a nested object:");
PrintObjectProperties(value, indent + "\t");
}
}
@@ -193,7 +195,7 @@ namespace Serein.NodeFlow.Tool
if (propInfo == null)
{
// 属性不存在,打印警告并标记失败
Console.WriteLine($"Warning: 属性 '{propName}' 不存在于类型 '{objType.Name}' 中,跳过赋值。");
SereinEnv.WriteLine(InfoType.WARN, $"属性 '{propName}' 不存在于类型 '{objType.Name}' 中,跳过赋值。");
allSuccessful = false;
continue;
}
@@ -203,7 +205,7 @@ namespace Serein.NodeFlow.Tool
if (!IsCompatibleType(targetType, propValue))
{
// 如果类型不兼容,打印错误并标记失败
Console.WriteLine($"Error: 无法将类型 '{propValue?.GetType().Name}' 赋值给属性 '{propName}' (Type: {targetType.Name}),跳过赋值。");
SereinEnv.WriteLine(InfoType.WARN, $"无法将类型 '{propValue?.GetType().Name}' 赋值给属性 '{propName}' (Type: {targetType.Name}),跳过赋值。");
allSuccessful = false;
continue;
}
@@ -254,7 +256,7 @@ namespace Serein.NodeFlow.Tool
}
catch (Exception ex)
{
Console.WriteLine($"Error: 为属性 '{propName}' 赋值时发生异常:{ex.Message}");
SereinEnv.WriteLine(InfoType.ERROR, $"为属性 '{propName}' 赋值时发生异常:{ex.Message}");
allSuccessful = false;
}
}

View File

@@ -238,13 +238,12 @@ namespace Serein.Library.NodeGenerator
sb.AppendLine(" protected void SetProperty<T>(ref T storage, T value, [System.Runtime.CompilerServices.CallerMemberName] string propertyName = null) ");
sb.AppendLine(" { ");
sb.AppendLine(" if (Equals(storage, value)) ");
sb.AppendLine(" { ");
sb.AppendLine(" return; ");
sb.AppendLine(" } ");
sb.AppendLine(" //if (Equals(storage, value)) ");
sb.AppendLine(" //{ ");
sb.AppendLine(" // return; ");
sb.AppendLine(" //} ");
sb.AppendLine(" ");
sb.AppendLine(" storage = value; ");
//sb.AppendLine(" OnPropertyChanged(propertyName); ");
sb.AppendLine(" PropertyChanged?.Invoke(this, new System.ComponentModel.PropertyChangedEventArgs(propertyName)); ");
sb.AppendLine(" } ");

View File

@@ -202,7 +202,7 @@ namespace Serein.Workbench
EnvDecorator.OnNodeLocated += FlowEnvironment_OnNodeLocate;
EnvDecorator.OnNodeMoved += FlowEnvironment_OnNodeMoved;
EnvDecorator.OnEnvOut += FlowEnvironment_OnEnvOut;
this.EnvDecorator.SetConsoleOut(); // 设置输出
// this.EnvDecorator.SetConsoleOut(); // 设置输出
}
/// <summary>
@@ -242,7 +242,7 @@ namespace Serein.Workbench
}
private void Window_ContentRendered(object sender, EventArgs e)
{
Console.WriteLine("load project...");
SereinEnv.WriteLine(InfoType.INFO, "load project...");
var project = App.FlowProjectData;
if (project is null)
{
@@ -253,7 +253,7 @@ namespace Serein.Workbench
//{
// connection.RefreshLine(); // 窗体完成加载后试图刷新所有连接线
//}
Console.WriteLine($"运行环境当前工作目录:{System.IO.Directory.GetCurrentDirectory()}");
SereinEnv.WriteLine(InfoType.INFO, $"运行环境当前工作目录:{System.IO.Directory.GetCurrentDirectory()}");
var canvasData = project.Basic.Canvas;
if (canvasData is not null)
@@ -273,7 +273,7 @@ namespace Serein.Workbench
}
#endregion
@@ -283,10 +283,11 @@ namespace Serein.Workbench
/// <summary>
/// 环境内容输出
/// </summary>
/// <param name="type"></param>
/// <param name="value"></param>
private void FlowEnvironment_OnEnvOut(string value)
private void FlowEnvironment_OnEnvOut(InfoType type, string value)
{
LogOutWindow.AppendText(value);
LogOutWindow.AppendText($"{DateTime.UtcNow} [{type}] : {value}{Environment.NewLine}");
}
/// <summary>
@@ -304,7 +305,7 @@ namespace Serein.Workbench
/// <exception cref="NotImplementedException"></exception>
private void FlowEnvironment_OnFlowRunComplete(FlowEventArgs eventArgs)
{
Console.WriteLine("-------运行完成---------\r\n");
SereinEnv.WriteLine(InfoType.INFO, "-------运行完成---------\r\n");
this.Dispatcher.Invoke(() =>
{
IOCObjectViewer.ClearObjItem();
@@ -347,7 +348,7 @@ namespace Serein.Workbench
}
else
{
Console.WriteLine("卸载失败");
SereinEnv.WriteLine(InfoType.INFO, "卸载失败");
}
}));
@@ -383,7 +384,7 @@ namespace Serein.Workbench
{
if (fromNodeControl is not INodeJunction IFormJunction || toNodeControl is not INodeJunction IToJunction)
{
Console.WriteLine("非预期的情况");
SereinEnv.WriteLine(InfoType.INFO, "非预期的连接");
return;
}
JunctionControlBase startJunction = IFormJunction.NextStepJunction;
@@ -449,7 +450,7 @@ namespace Serein.Workbench
{
if (fromNodeControl is not INodeJunction IFormJunction || toNodeControl is not INodeJunction IToJunction)
{
Console.WriteLine("非预期的情况");
SereinEnv.WriteLine(InfoType.INFO, "非预期的情况");
return;
}
@@ -565,7 +566,7 @@ namespace Serein.Workbench
if(nodeModelBase is null)
{
Console.WriteLine("OnNodeCreateEvent事件接收到意外的返回值");
SereinEnv.WriteLine(InfoType.WARN, "OnNodeCreateEvent事件接收到意外的返回值");
return;
}
// MethodDetails methodDetailss = eventArgs.MethodDetailss;
@@ -723,11 +724,11 @@ namespace Serein.Workbench
if (!TryGetControl(nodeGuid, out var nodeControl)) return;
if(eventArgs.Type == InterruptTriggerEventArgs.InterruptTriggerType.Exp)
{
Console.WriteLine($"表达式触发了中断:{eventArgs.Expression}");
SereinEnv.WriteLine(InfoType.INFO, $"表达式触发了中断:{eventArgs.Expression}");
}
else
{
Console.WriteLine($"节点触发了中断:{nodeGuid}");
SereinEnv.WriteLine(InfoType.INFO, $"节点触发了中断:{nodeGuid}");
}
}
@@ -1140,7 +1141,7 @@ namespace Serein.Workbench
}
catch (Exception ex)
{
Console.WriteLine(ex);
SereinEnv.WriteLine(InfoType.ERROR, ex.ToString());
}
}
#endregion
@@ -1308,7 +1309,7 @@ namespace Serein.Workbench
}
catch (Exception ex)
{
Console.WriteLine(ex);
SereinEnv.WriteLine(InfoType.ERROR, ex.ToString());
}
}
@@ -2433,11 +2434,11 @@ namespace Serein.Workbench
{
if (selectNodeControls.Count == 0)
{
Console.WriteLine("请至少选择一个节点");
SereinEnv.WriteLine(InfoType.INFO, "请至少选择一个节点");
}
else if (selectNodeControls.Count > 1)
{
Console.WriteLine("请只选择一个节点");
SereinEnv.WriteLine(InfoType.INFO, "请只选择一个节点");
}
else
{
@@ -2487,28 +2488,25 @@ namespace Serein.Workbench
//}
if (!SaveContentToFile(out string savePath, out Action<string, string>? savaProjectFile))
{
Console.WriteLine("保存项目DLL时返回了意外的文件保存路径");
SereinEnv.WriteLine(InfoType.ERROR, "保存项目DLL时返回了意外的文件保存路径");
return;
}
string? librarySavePath = System.IO.Path.GetDirectoryName(savePath);
if (string.IsNullOrEmpty(librarySavePath))
{
Console.WriteLine("保存项目DLL时返回了意外的文件保存路径");
SereinEnv.WriteLine(InfoType.ERROR, "保存项目DLL时返回了意外的文件保存路径");
return;
}
Console.WriteLine(savePath);
SereinEnv.WriteLine(InfoType.INFO, "项目文件保存路径:" + savePath);
for (int index = 0; index < projectData.Librarys.Length; index++)
{
NodeLibraryInfo? library = projectData.Librarys[index];
try
{
string targetPath = System.IO.Path.Combine(librarySavePath, library.FileName); // 目标文件夹
//Console.WriteLine("targetPath:" + targetPath);
#if WINDOWS
//library.Path
string sourceFile = library.FilePath; // 源文件夹
//Console.WriteLine("sourceFile:" + sourceFile);
#else
string sourceFile = new Uri(library.Path).LocalPath;
#endif
@@ -2517,13 +2515,11 @@ namespace Serein.Workbench
// 获取相对路径
string relativePath = System.IO.Path.GetRelativePath(savePath, targetPath);
//Console.WriteLine("Relative Path: " + relativePath);
projectData.Librarys[index].FilePath = relativePath;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
//WriteLog($"DLL复制失败{dll.CodeBase} \r\n错误{ex}\r\n");
SereinEnv.WriteLine(InfoType.ERROR, ex.Message);
}
}
@@ -2730,16 +2726,15 @@ namespace Serein.Workbench
if (!ObjDynamicCreateHelper.TryResolve(externalData, "RootType",out var result))
{
Console.WriteLine("赋值过程中有错误,请检查属性名和类型!");
SereinEnv.WriteLine(InfoType.ERROR, "赋值过程中有错误,请检查属性名和类型!");
return;
}
ObjDynamicCreateHelper.PrintObjectProperties(result!);
Console.WriteLine( );
var exp = "@set .Addresses[1].Street = 233";
var data = SerinExpressionEvaluator.Evaluate(exp, result!, out bool isChange);
exp = "@get .Addresses[1].Street";
data = SerinExpressionEvaluator.Evaluate(exp,result!, out isChange);
Console.WriteLine($"{exp} => {data}");
SereinEnv.WriteLine(InfoType.INFO, $"{exp} => {data}");
}
/// <summary>

View File

@@ -1,4 +1,6 @@
using System;
using Serein.Library;
using Serein.Library.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
@@ -45,13 +47,13 @@ namespace Serein.Workbench.Themes
var result = tcpClient.BeginConnect(addres, port, null, null);
success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(3));
}
catch (Exception ex)
catch
{
success = false;
}
if (!success)
{
Console.WriteLine($"无法连接远程:{addres}:{port}");
SereinEnv.WriteLine(InfoType.ERROR, $"无法连接远程:{addres}:{port}");
}
});

View File

@@ -295,7 +295,6 @@ namespace Serein.Workbench.Node.View
{
IsMouseOver = false;
e.Handled = true;
//Console.WriteLine("控件失去鼠标焦点");
}