From f76f09da947ec79235aecef351d6921ec706dba0 Mon Sep 17 00:00:00 2001 From: fengjiayi <12821976+ning_xi@user.noreply.gitee.com> Date: Sun, 13 Oct 2024 19:36:45 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=96=B0=E7=A1=AE=E8=AE=A4=E5=BC=80?= =?UTF-8?q?=E5=8F=91=E6=96=B9=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Library/Api/IFlowEnvironment.cs | 5 +- Library/Entity/ExplicitData.cs | 69 ---------- Library/Entity/MethodDetails.cs | 62 ++++++++- Library/Entity/ParameterDetails.cs | 116 +++++++++++++++++ Library/Entity/SereinProjectData.cs | 1 - NodeFlow/Base/NodeModelBaseFunc.cs | 10 +- NodeFlow/FlowEnvironment.cs | 47 +++++-- NodeFlow/Model/SingleActionNode.cs | 4 +- NodeFlow/Model/SingleFlipflopNode.cs | 4 +- NodeFlow/Tool/NodeMethodDetailsHelper.cs | 16 +-- README.md | 8 +- .../FlowRemoteManagement.cs | 121 ++++++++---------- .../Serein.FlowRemoteManagement.csproj | 2 +- Serein.FlowStartTool/Program.cs | 78 ++++++----- .../Serein.FlowStartTool.csproj | 10 ++ WorkBench/App.xaml.cs | 5 +- WorkBench/MainWindow.xaml.cs | 3 - WorkBench/Themes/MethodDetailsControl.xaml | 8 +- 18 files changed, 358 insertions(+), 211 deletions(-) delete mode 100644 Library/Entity/ExplicitData.cs create mode 100644 Library/Entity/ParameterDetails.cs diff --git a/Library/Api/IFlowEnvironment.cs b/Library/Api/IFlowEnvironment.cs index 2b0ae72..9b4b5e0 100644 --- a/Library/Api/IFlowEnvironment.cs +++ b/Library/Api/IFlowEnvironment.cs @@ -390,7 +390,10 @@ namespace Serein.Library.Api /// /// 是否全局中断 /// - bool IsGlobalInterrupt { get; } + bool IsGlobalInterrupt { get; } + + + #endregion #region 事件 diff --git a/Library/Entity/ExplicitData.cs b/Library/Entity/ExplicitData.cs deleted file mode 100644 index ad486c3..0000000 --- a/Library/Entity/ExplicitData.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace Serein.Library.Entity -{ - - /// - /// 节点入参参数信息 - /// - public class ExplicitData - { - /// - /// 参数索引 - /// - public int Index { get; set; } - /// - /// 是否为显式参数(固定值/表达式) - /// - public bool IsExplicitData { get; set; } - /// - /// 转换器 IEnumConvertor<,> - /// - public Func Convertor { get; set; } - ///// - ///// 显式类型 - ///// - public Type ExplicitType { get; set; } - - ///// - ///// 显示类型编号> - ///// - public string ExplicitTypeName { get; set; } - - /// - /// 方法需要的类型 - /// - public Type DataType { get; set; } - - /// - /// 方法入参参数名称 - /// - public string ParameterName { get; set; } - - /// - /// 入参值(在UI上输入的文本内容) - /// - - public string DataValue { get; set; } - - public object[] Items { get; set; } - - public ExplicitData Clone() => new ExplicitData() - { - Index = Index, - IsExplicitData = IsExplicitData, - ExplicitType = ExplicitType, - ExplicitTypeName = ExplicitTypeName, - Convertor = Convertor, - DataType = DataType, - ParameterName = ParameterName, - DataValue = string.IsNullOrEmpty(DataValue) ? string.Empty : DataValue, - Items = Items.Select(it => it).ToArray(), - }; - } - - -} diff --git a/Library/Entity/MethodDetails.cs b/Library/Entity/MethodDetails.cs index d36aeef..00efadc 100644 --- a/Library/Entity/MethodDetails.cs +++ b/Library/Entity/MethodDetails.cs @@ -5,6 +5,44 @@ using System.Linq; namespace Serein.Library.Entity { + /// + /// 方法描述信息 + /// + public class MethodDetailsInfo + { + /// + /// 属于哪个DLL文件 + /// + public string LibraryName { get; set; } + + /// + /// 方法名称 + /// + public string MethodName { get; set; } + + /// + /// 节点类型 + /// + public string NodeType { get; set; } + + /// + /// 方法说明 + /// + public string MethodTips { get; set; } + + /// + /// 参数内容 + /// + + public ParameterDetailsInfo[] ParameterDetailsInfos { get; set; } + + /// + /// 出参类型 + /// + + public string ReturnTypeFullName { get; set; } + } + /// @@ -12,6 +50,24 @@ namespace Serein.Library.Entity /// public class MethodDetails { + /// + /// 转为信息 + /// + /// + public MethodDetailsInfo ToInfo() + { + return new MethodDetailsInfo + { + MethodName = MethodName, + MethodTips = MethodTips, + NodeType = MethodDynamicType.ToString(), + ParameterDetailsInfos = this.ParameterDetailss.Select(p => p.ToInfo()).ToArray(), + ReturnTypeFullName = ReturnType.FullName, + + }; + } + + /// /// 从DLL拖动出来时拷贝新的实例 /// @@ -28,7 +84,7 @@ namespace Serein.Library.Entity MethodName = MethodName, MethodLockName = MethodLockName, IsProtectionParameter = IsProtectionParameter, - ExplicitDatas = ExplicitDatas?.Select(it => it.Clone()).ToArray(), + ParameterDetailss = ParameterDetailss?.Select(it => it.Clone()).ToArray(), }; } @@ -70,10 +126,10 @@ namespace Serein.Library.Entity /// - /// 参数内容 + /// 参数描述 /// - public ExplicitData[] ExplicitDatas { get; set; } + public ParameterDetails[] ParameterDetailss { get; set; } /// /// 出参类型 diff --git a/Library/Entity/ParameterDetails.cs b/Library/Entity/ParameterDetails.cs new file mode 100644 index 0000000..1ac8289 --- /dev/null +++ b/Library/Entity/ParameterDetails.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace Serein.Library.Entity +{ + + /// + /// 方法入参描述 + /// + public class ParameterDetailsInfo + { + /// + /// 参数索引 + /// + public int Index { get; set; } + + /// + /// 方法需要的类型 + /// + public string DataTypeFullName { get; set; } + + /// + /// 方法入参参数名称 + /// + public string Name { get; set; } + } + + /// + /// 节点入参参数详情 + /// + public class ParameterDetails + { + /// + /// 转为描述 + /// + /// + public ParameterDetailsInfo ToInfo() + { + return new ParameterDetailsInfo + { + Index = Index, + DataTypeFullName = DataType.FullName, + Name = Name + }; + } + + /// + /// 拷贝新的对象。 + /// + /// + public ParameterDetails Clone() => new ParameterDetails() + { + Index = Index, + IsExplicitData = IsExplicitData, + ExplicitType = ExplicitType, + ExplicitTypeName = ExplicitTypeName, + Convertor = Convertor, + DataType = DataType, + Name = Name, + DataValue = string.IsNullOrEmpty(DataValue) ? string.Empty : DataValue, + Items = Items.Select(it => it).ToArray(), + }; + + /// + /// 参数索引 + /// + public int Index { get; set; } + /// + /// 是否为显式参数(固定值/表达式) + /// + public bool IsExplicitData { get; set; } + /// + /// 转换器 IEnumConvertor<,> + /// + public Func Convertor { get; set; } + /// + /// 显式类型 + /// + public Type ExplicitType { get; set; } + + /// + /// 目前存在三种状态:Select/Bool/Value + /// Select : 枚举值 + /// Bool : 布尔类型 + /// Value : 除以上类型之外的任意参数 + /// + public string ExplicitTypeName { get; set; } + + /// + /// 方法需要的类型 + /// + public Type DataType { get; set; } + + /// + /// 方法入参参数名称 + /// + public string Name { get; set; } + + /// + /// 入参值(在UI上输入的文本内容) + /// + + public string DataValue { get; set; } + + /// + /// 如果是引用类型,拷贝时不会发生改变。 + /// + public object[] Items { get; set; } + + + } + + +} diff --git a/Library/Entity/SereinProjectData.cs b/Library/Entity/SereinProjectData.cs index 5ad4603..64cff65 100644 --- a/Library/Entity/SereinProjectData.cs +++ b/Library/Entity/SereinProjectData.cs @@ -39,7 +39,6 @@ namespace Serein.Library.Entity public NodeInfo[] Nodes { get; set; } - } /// diff --git a/NodeFlow/Base/NodeModelBaseFunc.cs b/NodeFlow/Base/NodeModelBaseFunc.cs index 92a078a..b2ff125 100644 --- a/NodeFlow/Base/NodeModelBaseFunc.cs +++ b/NodeFlow/Base/NodeModelBaseFunc.cs @@ -82,8 +82,8 @@ namespace Serein.NodeFlow.Base for (int i = 0; i < nodeInfo.ParameterData.Length; i++) { Parameterdata? pd = nodeInfo.ParameterData[i]; - this.MethodDetails.ExplicitDatas[i].IsExplicitData = pd.State; - this.MethodDetails.ExplicitDatas[i].DataValue = pd.Value; + this.MethodDetails.ParameterDetailss[i].IsExplicitData = pd.State; + this.MethodDetails.ParameterDetailss[i].DataValue = pd.Value; } } @@ -232,12 +232,12 @@ namespace Serein.NodeFlow.Base public static object?[]? GetParameters(IDynamicContext context, NodeModelBase nodeModel, MethodDetails md) { // 用正确的大小初始化参数数组 - if (md.ExplicitDatas.Length == 0) + if (md.ParameterDetailss.Length == 0) { return null;// md.ActingInstance } - object?[]? parameters = new object[md.ExplicitDatas.Length]; + object?[]? parameters = new object[md.ParameterDetailss.Length]; var flowData = nodeModel.PreviousNode?.FlowData; // 当前传递的数据 var previousDataType = flowData?.GetType(); @@ -245,7 +245,7 @@ namespace Serein.NodeFlow.Base { object? inputParameter; // 存放解析的临时参数 - var ed = md.ExplicitDatas[i]; // 方法入参描述 + var ed = md.ParameterDetailss[i]; // 方法入参描述 if (ed.IsExplicitData) // 判断是否使用显示的输入参数 diff --git a/NodeFlow/FlowEnvironment.cs b/NodeFlow/FlowEnvironment.cs index 097dc75..c92bd8b 100644 --- a/NodeFlow/FlowEnvironment.cs +++ b/NodeFlow/FlowEnvironment.cs @@ -36,7 +36,26 @@ namespace Serein.NodeFlow - + /* + + public List get(){ + } + + libray + { + string dllname, + MethodInfo[] nodeinfos + } + + methodInfo{ + + } + + + + */ + + /// /// 运行环境 @@ -58,8 +77,6 @@ namespace Serein.NodeFlow sereinIOC.OnIOCMembersChanged += e => this?.OnIOCMembersChanged?.Invoke(e) ; // 监听IOC容器的注册 } - - /// /// 节点的命名空间 /// @@ -169,9 +186,8 @@ namespace Serein.NodeFlow public List NodeLibrarys { get; } = []; /// - /// 存储所有方法信息 + /// 描述所有DLL中NodeAction特性的方法的原始副本 /// - //private MethodDetailss { get; } = []; public Dictionary> MethodDetailss { get; } = []; /// @@ -184,6 +200,10 @@ namespace Serein.NodeFlow /// 存放触发器节点(运行时全部调用) /// public List FlipflopNodes { get; } = []; + + /// + /// 从dll中加载的类的注册类型 + /// public Dictionary> AutoRegisterTypes { get; } = []; /// @@ -336,16 +356,18 @@ namespace Serein.NodeFlow var dllPaths = project.Librarys.Select(it => it.Path).ToList(); List methodDetailss = []; + //string currentPath = Environment.CurrentDirectory; // 获取当前目录 + //string path = Assembly.GetExecutingAssembly().Location; // 获取当前正在执行的文件的路径 + //string exePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); // 获取包含可执行文件的目录 + //string basePath = AppDomain.CurrentDomain.BaseDirectory; // 获取应用程序的执行路径: + // 遍历依赖项中的特性注解,生成方法详情 - foreach (var dll in dllPaths) + foreach (var dllPath in dllPaths) { - var dllFilePath = System.IO.Path.GetFullPath(System.IO.Path.Combine(filePath, dll)); + var dllFilePath = Path.GetFullPath(Path.Combine(filePath, dllPath)); + //var dllFilePath = Path.GetFullPath(Path.Combine(Path.GetDirectoryName(filePath)!, dllPath)); LoadDllNodeInfo(dllFilePath); } - // 方法加载完成,缓存到运行环境中。 - //MethodDetailss.AddRange(methodDetailss); - //methodDetailss.Clear(); - List<(NodeModelBase, string[])> regionChildNodes = new List<(NodeModelBase, string[])>(); List<(NodeModelBase, Position)> ordinaryNodes = new List<(NodeModelBase, Position)>(); @@ -1325,10 +1347,11 @@ namespace Serein.NodeFlow { public static Library.Entity.Library ToLibrary(this Assembly assembly) { + var tmp = assembly.ManifestModule.Name; return new Library.Entity.Library { Name = assembly.GetName().Name, - Path = assembly.Location, + Path = assembly.ManifestModule.Name, }; } diff --git a/NodeFlow/Model/SingleActionNode.cs b/NodeFlow/Model/SingleActionNode.cs index 1bdb005..d29b82c 100644 --- a/NodeFlow/Model/SingleActionNode.cs +++ b/NodeFlow/Model/SingleActionNode.cs @@ -12,9 +12,9 @@ namespace Serein.NodeFlow.Model internal override Parameterdata[] GetParameterdatas() { - if (base.MethodDetails.ExplicitDatas.Length > 0) + if (base.MethodDetails.ParameterDetailss.Length > 0) { - return MethodDetails.ExplicitDatas + return MethodDetails.ParameterDetailss .Select(it => new Parameterdata { State = it.IsExplicitData, diff --git a/NodeFlow/Model/SingleFlipflopNode.cs b/NodeFlow/Model/SingleFlipflopNode.cs index 753c81f..bc726fc 100644 --- a/NodeFlow/Model/SingleFlipflopNode.cs +++ b/NodeFlow/Model/SingleFlipflopNode.cs @@ -82,9 +82,9 @@ namespace Serein.NodeFlow.Model } internal override Parameterdata[] GetParameterdatas() { - if (base.MethodDetails.ExplicitDatas.Length > 0) + if (base.MethodDetails.ParameterDetailss.Length > 0) { - return MethodDetails.ExplicitDatas + return MethodDetails.ParameterDetailss .Select(it => new Parameterdata { State = it.IsExplicitData, diff --git a/NodeFlow/Tool/NodeMethodDetailsHelper.cs b/NodeFlow/Tool/NodeMethodDetailsHelper.cs index dfaa766..c5f37d7 100644 --- a/NodeFlow/Tool/NodeMethodDetailsHelper.cs +++ b/NodeFlow/Tool/NodeMethodDetailsHelper.cs @@ -134,7 +134,7 @@ public static class NodeMethodDetailsHelper MethodDynamicType = attribute.MethodDynamicType, MethodLockName = attribute.LockName, MethodTips = methodTips, - ExplicitDatas = explicitDataOfParameters, + ParameterDetailss = explicitDataOfParameters, ReturnType = returnType, }; var dd = new DelegateDetails( emitMethodType, methodDelegate) ; @@ -173,7 +173,7 @@ public static class NodeMethodDetailsHelper /// /// /// - private static ExplicitData[] GetExplicitDataOfParameters(ParameterInfo[] parameters) + private static ParameterDetails[] GetExplicitDataOfParameters(ParameterInfo[] parameters) { return parameters.Select((it, index) => @@ -212,7 +212,7 @@ public static class NodeMethodDetailsHelper return methodInfo?.Invoke(obj, [enumValue]); }; // 确保实例实现了所需接口 - ExplicitData ed = GetExplicitDataOfParameter(it, index, paremType, true, func); + ParameterDetails ed = GetExplicitDataOfParameter(it, index, paremType, true, func); return ed; } @@ -237,7 +237,7 @@ public static class NodeMethodDetailsHelper }).ToArray(); } - private static ExplicitData GetExplicitDataOfParameter(ParameterInfo parameterInfo, + private static ParameterDetails GetExplicitDataOfParameter(ParameterInfo parameterInfo, int index, Type paremType, bool isExplicitData, @@ -247,7 +247,7 @@ public static class NodeMethodDetailsHelper string explicitTypeName = GetExplicitTypeName(paremType); var items = GetExplicitItems(paremType, explicitTypeName); if ("Bool".Equals(explicitTypeName)) explicitTypeName = "Select"; // 布尔值 转为 可选类型 - return new ExplicitData + return new ParameterDetails { IsExplicitData = isExplicitData, //attribute is null ? parameterInfo.HasDefaultValue : true, Index = index, @@ -255,9 +255,9 @@ public static class NodeMethodDetailsHelper ExplicitType = paremType, Convertor = func, DataType = parameterInfo.ParameterType, - ParameterName = parameterInfo.Name, - DataValue = parameterInfo.HasDefaultValue ? parameterInfo?.DefaultValue?.ToString() : "", - Items = items.ToArray(), + Name = parameterInfo.Name, + DataValue = parameterInfo.HasDefaultValue ? parameterInfo?.DefaultValue?.ToString() : "", // 如果存在默认值,则使用默认值 + Items = items.ToArray(), // 如果是枚举值入参,则获取枚举类型的字面量 }; } diff --git a/README.md b/README.md index f5f59c4..c97e931 100644 --- a/README.md +++ b/README.md @@ -3,10 +3,12 @@ 不定期在Bilibili个人空间上更新相关的视频。 https://space.bilibili.com/33526379 -# 计划任务 2024年9月17日更新 -* (重要+优先)正在实现单步执行 +# 计划任务 2024年10月13日更新 +* (优先)正在开发远程管理插件与远程操作客户端 +* 计划实现不停机更新类库(更新整个DLL/某个节点),但似乎难度过大 +* 计划实现单步执行 * 计划实现节点树视图、IOC容器对象视图 -* 正在计划新增基础节点“属性包装器”,用来收集各个节点的数据,包装成匿名对象/Json类型(暂时未想到如何设计) +* 计划新增基础节点“属性包装器”,用来收集各个节点的数据,包装成匿名对象/Json类型(暂时未想到如何设计) # 如何加载我的DLL? diff --git a/Serein.FlowRemoteManagement/FlowRemoteManagement.cs b/Serein.FlowRemoteManagement/FlowRemoteManagement.cs index 825056f..0668f58 100644 --- a/Serein.FlowRemoteManagement/FlowRemoteManagement.cs +++ b/Serein.FlowRemoteManagement/FlowRemoteManagement.cs @@ -11,16 +11,10 @@ using Serein.Library.Core.NodeFlow; using Serein.Library.NodeFlow.Tool; using Serein.Library.Utils; using Serein.FlowRemoteManagement.Model; +using System.Reflection; namespace SereinFlowRemoteManagement { - public enum FlowEnvCommand - { - A, - B, - C, - D - } /// @@ -29,12 +23,12 @@ namespace SereinFlowRemoteManagement [DynamicFlow] [AutoRegister] [AutoSocketModule(ThemeKey ="theme",DataKey ="data")] - public class FlowRemoteManagement : FlowTrigger, ISocketHandleModule + public class FlowRemoteManagement : ISocketHandleModule { #region 初始化 public Guid HandleGuid { get; } = new Guid(); - private readonly FlowEnvironment environment; + private readonly FlowEnvironment environment; public FlowRemoteManagement(IFlowEnvironment environment) { if(environment is FlowEnvironment env) @@ -67,6 +61,7 @@ namespace SereinFlowRemoteManagement ex = ex.Message }); }); + await Console.Out.WriteLineAsync("启动远程管理模块"); await socketServer.StartAsync("http://*:7525/"); }); SereinProjectData projectData = environment.SaveProject(); @@ -76,7 +71,7 @@ namespace SereinFlowRemoteManagement #region 对外接口 /// - /// 更改两个节点的连接关系 + /// 远程更改两个节点的连接关系 /// /// /// @@ -107,36 +102,20 @@ namespace SereinFlowRemoteManagement /// 远程调用某个节点 /// [AutoSocketHandle(ThemeValue = "InvokeNode")] - public async Task InvokeNode(bool isBranchEx, string nodeGuid, Func Send) + public async Task InvokeNode(string nodeGuid, Func Send) { if (string.IsNullOrEmpty(nodeGuid)) { throw new InvalidOperationException("Guid错误"); } - if(!environment.Nodes.TryGetValue(nodeGuid, out var nodeModel) ) + + await environment.StartFlowInSelectNodeAsync(nodeGuid); + + await Send(new { - throw new InvalidOperationException("不存在这样的节点"); - } - IDynamicContext dynamicContext = new DynamicContext(environment); - object? result = null; - if(isBranchEx) - { - await nodeModel.StartFlowAsync(dynamicContext); - } - else - { - result = await nodeModel.ExecutingAsync(dynamicContext); - } - - if(result is not Task) - { - await Send(new - { - state = 200, - tips = "执行完成", - data = result - }) ; - } + state = 200, + tips = "执行完成", + }); } /// @@ -150,37 +129,49 @@ namespace SereinFlowRemoteManagement } + /// + /// 连接到运行环境,获取当前的节点信息 + /// + /// + /// + [AutoSocketHandle] + public async Task ConnectWorkBench(Func Send) + { + await Send("尝试获取"); + + Dictionary> LibraryMds = []; + + foreach (var mdskv in environment.MethodDetailss) + { + var library = mdskv.Key; + var mds = mdskv.Value; + foreach (var md in mds) + { + if(!LibraryMds.TryGetValue(library, out var t_mds)) + { + t_mds = new List(); + LibraryMds[library] = t_mds; + } + var mdInfo = md.ToInfo(); + mdInfo.LibraryName = library.Assembly.GetName().FullName; + t_mds.Add(mdInfo); + } + } + try + { + var project = await GetProjectInfo(); + return new + { + project = project, + envNode = LibraryMds.Values, + }; + } + catch (Exception ex) + { + await Send(ex.Message); + return null; + } + } #endregion - - #region 测试节点 - - [NodeAction(NodeType.Flipflop, "触发器等待")] - public async Task> WaitFlipflop(FlowEnvCommand flowEnvCommand) - { - var result = await this.CreateTaskAsync(flowEnvCommand); - return new FlipflopContext(FlipflopStateType.Succeed, result); - } - - [NodeAction(NodeType.Action, "测试")] - public void Test() - { - Console.WriteLine("Hello World"); - } - - [NodeAction(NodeType.Action, "等待")] - public async Task Wait(int wait = 5) - { - await Task.Delay(1000 * wait); - } - - [NodeAction(NodeType.Action, "输出")] - public void Console2(string value) - { - Console.WriteLine(value); - } - #endregion - - - } } diff --git a/Serein.FlowRemoteManagement/Serein.FlowRemoteManagement.csproj b/Serein.FlowRemoteManagement/Serein.FlowRemoteManagement.csproj index db24704..28986e2 100644 --- a/Serein.FlowRemoteManagement/Serein.FlowRemoteManagement.csproj +++ b/Serein.FlowRemoteManagement/Serein.FlowRemoteManagement.csproj @@ -1,7 +1,7 @@  - net8.0 + net8.0 enable enable D:\Project\C#\DynamicControl\SereinFlow\.Output diff --git a/Serein.FlowStartTool/Program.cs b/Serein.FlowStartTool/Program.cs index b6857db..608df8f 100644 --- a/Serein.FlowStartTool/Program.cs +++ b/Serein.FlowStartTool/Program.cs @@ -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(content); + if (flowProjectData is null || string.IsNullOrEmpty(fileDataPath)) { - // 读取文件内容 - string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容 - flowProjectData = JsonConvert.DeserializeObject(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; } + } } diff --git a/Serein.FlowStartTool/Serein.FlowStartTool.csproj b/Serein.FlowStartTool/Serein.FlowStartTool.csproj index 04d7a2b..124420a 100644 --- a/Serein.FlowStartTool/Serein.FlowStartTool.csproj +++ b/Serein.FlowStartTool/Serein.FlowStartTool.csproj @@ -6,6 +6,16 @@ true enable enable + prompt + project + + + + False + + + + False diff --git a/WorkBench/App.xaml.cs b/WorkBench/App.xaml.cs index 92191c8..8d5dbe7 100644 --- a/WorkBench/App.xaml.cs +++ b/WorkBench/App.xaml.cs @@ -162,11 +162,12 @@ namespace Serein.WorkBench //filePath = @"F:\临时\project\tmp\project.dnf"; //filePath = @"D:\Project\C#\TestNetFramework\Net45DllTest\Net45DllTest\bin\Debug\project.dnf"; //filePath = @"D:\Project\C#\DynamicControl\SereinFlow\Net462DllTest\bin\Debug\project.dnf"; - filePath = @"D:\Project\C#\DynamicControl\SereinFlow\.Output\Debug\net8.0-windows7.0\project.dnf"; + //filePath = @"D:\Project\C#\DynamicControl\SereinFlow\.Output\Debug\net8.0-windows7.0\project.dnf"; + filePath = @"F:\临时\project\linux\project.dnf"; //string filePath = @"D:\Project\C#\DynamicControl\SereinFlow\.Output\Debug\net8.0-windows7.0\U9 project.dnf"; string content = System.IO.File.ReadAllText(filePath); // 读取整个文件内容 App.FlowProjectData = JsonConvert.DeserializeObject(content); - App.FileDataPath = filePath;//System.IO.Path.GetDirectoryName(filePath)!; + App.FileDataPath =System.IO.Path.GetDirectoryName(filePath)!; // filePath;// } #endif diff --git a/WorkBench/MainWindow.xaml.cs b/WorkBench/MainWindow.xaml.cs index feb403b..0b76323 100644 --- a/WorkBench/MainWindow.xaml.cs +++ b/WorkBench/MainWindow.xaml.cs @@ -203,9 +203,6 @@ namespace Serein.WorkBench } - - - private LogWindow InitConsoleOut() { diff --git a/WorkBench/Themes/MethodDetailsControl.xaml b/WorkBench/Themes/MethodDetailsControl.xaml index e5665ca..b0a1f47 100644 --- a/WorkBench/Themes/MethodDetailsControl.xaml +++ b/WorkBench/Themes/MethodDetailsControl.xaml @@ -13,7 +13,7 @@ - + @@ -36,7 +36,7 @@ - + @@ -61,7 +61,7 @@ - + - +