mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-20 16:26:34 +08:00
1. 移除了FlipflopContext,统一流程API
2. Script项目脚本修复了 RawString 原始字符串存在的问题 3. Script使用了ValueNode统一了值类型节点,为后续扩展更多的值类型做准备 4. TypeHelper.ToTypeOfString()方法中添加了部分值类型的"Type[]”与“List<Type>”的显式定义,用于脚本在类型中定义数组成员 5. Script项目脚本默认挂载的json方法拆分为jsonObj(String)与jsonStr(Object)以支持序列化与反序列化 6. 项目保存为dnf项目文件时,将不再保存名称为”Default"并且没有节点的画布,避免重复保存时默认画布增多。
This commit is contained in:
@@ -48,8 +48,6 @@ namespace Serein.NodeFlow.Env
|
||||
private readonly FlowLibraryService flowLibraryManagement;
|
||||
private readonly FlowOperationService flowOperationService;
|
||||
private readonly FlowModelService flowModelService;
|
||||
//private readonly NodeMVVMService nodeMVVMService;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 注册基本节点类型
|
||||
@@ -633,33 +631,31 @@ namespace Serein.NodeFlow.Env
|
||||
}
|
||||
|
||||
|
||||
/* var nodeModels = flowModelService.GetAllNodeModel();
|
||||
foreach (var toNode in nodeModels)
|
||||
{
|
||||
var canvasGuid = toNode.CanvasDetails.Guid;
|
||||
if (toNode.MethodDetails.ParameterDetailss == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (var i = 0; i < toNode.MethodDetails.ParameterDetailss.Length; i++)
|
||||
{
|
||||
var pd = toNode.MethodDetails.ParameterDetailss[i];
|
||||
if (!string.IsNullOrEmpty(pd.ArgDataSourceNodeGuid)
|
||||
&& TryGetNodeModel(pd.ArgDataSourceNodeGuid, out var fromNode))
|
||||
{
|
||||
*//*if (fromNode.NeedResultNodes[pd.ArgDataSourceType].Contains(toNode)
|
||||
&& pd.ArgDataSourceNodeGuid == fromNode.Guid
|
||||
&& )
|
||||
{
|
||||
continue;
|
||||
}*//*
|
||||
ConnectArgSourceNode(canvasGuid, fromNode.Guid, toNode.Guid, JunctionType.ReturnData, JunctionType.ArgData, pd.ArgDataSourceType, pd.Index);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
/* var nodeModels = flowModelService.GetAllNodeModel();
|
||||
foreach (var toNode in nodeModels)
|
||||
{
|
||||
var canvasGuid = toNode.CanvasDetails.Guid;
|
||||
if (toNode.MethodDetails.ParameterDetailss == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (var i = 0; i < toNode.MethodDetails.ParameterDetailss.Length; i++)
|
||||
{
|
||||
var pd = toNode.MethodDetails.ParameterDetailss[i];
|
||||
if (!string.IsNullOrEmpty(pd.ArgDataSourceNodeGuid)
|
||||
&& TryGetNodeModel(pd.ArgDataSourceNodeGuid, out var fromNode))
|
||||
{
|
||||
*//*if (fromNode.NeedResultNodes[pd.ArgDataSourceType].Contains(toNode)
|
||||
&& pd.ArgDataSourceNodeGuid == fromNode.Guid
|
||||
&& )
|
||||
{
|
||||
continue;
|
||||
}*//*
|
||||
ConnectArgSourceNode(canvasGuid, fromNode.Guid, toNode.Guid, JunctionType.ReturnData, JunctionType.ArgData, pd.ArgDataSourceType, pd.Index);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
@@ -339,9 +339,14 @@ namespace Serein.NodeFlow.Env
|
||||
var projectData = new SereinProjectData()
|
||||
{
|
||||
Librarys = this._flowLibraryService.GetAllLibraryInfo().ToArray(),
|
||||
Nodes = _flowModelService.GetAllNodeModel().Select(node => node.ToInfo()).Where(info => info is not null).ToArray(),
|
||||
Canvass = _flowModelService.GetAllCanvasModel().Select(canvas => canvas.ToInfo()).ToArray(),
|
||||
//StartNode = NodeModels.Values.FirstOrDefault(it => it.IsStart)?.Guid,
|
||||
Nodes = _flowModelService.GetAllNodeModel()
|
||||
.Select(node => node.ToInfo())
|
||||
.Where(info => info is not null)
|
||||
.ToArray(),
|
||||
Canvass = _flowModelService.GetAllCanvasModel()
|
||||
.Where(canvas => canvas.Nodes.Count != 0 && !"Default".Equals(canvas.Name))
|
||||
.Select(canvas => canvas.ToInfo())
|
||||
.ToArray(),
|
||||
};
|
||||
|
||||
return projectData;
|
||||
|
||||
@@ -110,7 +110,7 @@ namespace Serein.NodeFlow
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/*/// <summary>
|
||||
/// 触发器运行后状态转为对应的后继分支类别
|
||||
/// </summary>
|
||||
/// <param name="flowStateType"></param>
|
||||
@@ -126,7 +126,7 @@ namespace Serein.NodeFlow
|
||||
FlipflopStateType.Cancel => ConnectionInvokeType.None,
|
||||
_ => throw new NotImplementedException("未定义的流程状态")
|
||||
};
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -72,23 +72,12 @@ namespace Serein.NodeFlow.Model.Nodes
|
||||
instance = ioc.Get(md.ActingInstanceType);
|
||||
}
|
||||
|
||||
var args = MethodDetails.ParameterDetailss.Length == 0 ? [] : await this.GetParametersAsync(context, token);
|
||||
var args = MethodDetails.ParameterDetailss.Length == 0 ? []
|
||||
: await this.GetParametersAsync(context, token);
|
||||
|
||||
// 因为这里会返回不确定的泛型 IFlipflopContext<TRsult>
|
||||
// 而我们只需要获取到 State 和 Value(返回的数据)
|
||||
// 所以使用 dynamic 类型接收
|
||||
dynamic flipflopContext = await dd.InvokeAsync(instance, args);
|
||||
FlipflopStateType flipflopStateType = flipflopContext.State;
|
||||
context.NextOrientation = flipflopStateType.ToContentType();
|
||||
|
||||
|
||||
if (flipflopContext.Type == TriggerDescription.Overtime)
|
||||
{
|
||||
throw new FlipflopException(MethodDetails.MethodName + "触发器超时触发。Guid" + Guid);
|
||||
}
|
||||
object result = flipflopContext.Value;
|
||||
var flowReslt = FlowResult.OK(this.Guid, context, result);
|
||||
return flowReslt;
|
||||
var result = await dd.InvokeAsync(instance, args);
|
||||
var flowResult = FlowResult.OK(this.Guid, context, result);
|
||||
return flowResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -409,16 +409,6 @@ namespace Serein.NodeFlow.Services
|
||||
continue;
|
||||
}
|
||||
await CallSuccessorNodesAsync(flipflopNode, token, pool, context);
|
||||
/*if (flipflopNode.IsWaitSuccessorNodes)
|
||||
{
|
||||
_ = Task.Run(async () => await CallSuccessorNodesAsync(flipflopNode, token, pool, context));
|
||||
}
|
||||
else
|
||||
{
|
||||
await CallSuccessorNodesAsync(flipflopNode, token, pool, context);
|
||||
}*/
|
||||
|
||||
|
||||
}
|
||||
catch (FlipflopException ex)
|
||||
{
|
||||
|
||||
@@ -103,20 +103,34 @@ public static class NodeMethodDetailsHelper
|
||||
if (methodInfo.ReturnType.IsGenericType && methodInfo.ReturnType.GetGenericTypeDefinition() == typeof(Task<>))
|
||||
{
|
||||
// 获取 Task<> 的泛型参数类型
|
||||
var innerType = methodInfo.ReturnType.GetGenericArguments()[0];
|
||||
if (innerType.IsGenericType && innerType.GetGenericTypeDefinition() == typeof(IFlipflopContext<>))
|
||||
var innerTypes = methodInfo.ReturnType.GetGenericArguments();
|
||||
if(innerTypes.Length == 1)
|
||||
{
|
||||
var flipflopType = innerType.GetGenericArguments()[0];
|
||||
returnType = flipflopType;
|
||||
var innerType = innerTypes[0];
|
||||
returnType = innerType;
|
||||
}
|
||||
else
|
||||
{
|
||||
SereinEnv.WriteLine(InfoType.WARN, $"[{methodName}]跳过创建,返回类型非预期的Task<IFlipflopContext<TResult>>。");
|
||||
SereinEnv.WriteLine(InfoType.WARN, $"[{methodName}]跳过创建,返回类型非预期的Task<TResult>。");
|
||||
outMethodInfo = null;
|
||||
methodDetails = null;
|
||||
delegateDetails = null;
|
||||
return false;
|
||||
}
|
||||
//var innerType = methodInfo.ReturnType.GetGenericArguments()[0];
|
||||
//if (innerType.IsGenericType && innerType.GetGenericTypeDefinition() == typeof(IFlipflopContext<>))
|
||||
//{
|
||||
// var flipflopType = innerType.GetGenericArguments()[0];
|
||||
// returnType = flipflopType;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SereinEnv.WriteLine(InfoType.WARN, $"[{methodName}]跳过创建,返回类型非预期的Task<IFlipflopContext<TResult>>。");
|
||||
// outMethodInfo = null;
|
||||
// methodDetails = null;
|
||||
// delegateDetails = null;
|
||||
// return false;
|
||||
//}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user