From 5b15871f65628c2343836688522617f5b06a7f52 Mon Sep 17 00:00:00 2001
From: fengjiayi <12821976+ning_xi@user.noreply.gitee.com>
Date: Mon, 5 Aug 2024 19:43:57 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E4=BA=86=E6=8B=96=E5=85=A5?=
=?UTF-8?q?=E7=9A=84DLL=E6=98=BE=E7=A4=BA=E5=90=8D=E7=A7=B0=20=E5=B0=9D?=
=?UTF-8?q?=E8=AF=95=E6=B7=BB=E5=8A=A0=E4=BA=86web=E8=87=AA=E5=8A=A8?=
=?UTF-8?q?=E5=8C=96=E6=B5=8B=E8=AF=95=EF=BC=88=E5=9F=BA=E4=BA=8ESelenium)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Library/DbSql/DBSync.cs | 30 ++++
Library/DbSql/RepositoryBase.cs | 22 +++
Library/DynamicFlow/DynamicContext.cs | 2 +
Library/DynamicFlow/MethodDetails.cs | 32 +++-
Library/DynamicFlow/NodeFlowStarter.cs | 22 +++
.../NodeModel/CompositeActionNode.cs | 1 +
.../NodeModel/CompositeConditionNode.cs | 2 +
Library/DynamicFlow/NodeModel/NodeBase.cs | 45 ++++++
.../NodeModel/SingleConditionNode.cs | 3 +
.../DynamicFlow/NodeModel/SingleExpOpNode.cs | 12 +-
.../SerinExpression/ConditionResolver.cs | 19 ++-
.../SerinExpression/SerinConditionParser.cs | 15 +-
.../SerinExpressionEvaluator.cs | 18 +++
Library/DynamicFlow/Tool/DelegateGenerator.cs | 13 ++
Library/DynamicFlow/Tool/ExpressionHelper.cs | 6 +-
Library/DynamicFlow/Tool/TcsSignal.cs | 23 +--
Library/Serein.Library.csproj | 8 +-
Library/ServiceContainer.cs | 42 +++++
Library/Tool/DataHelper.cs | 16 ++
Library/Web/Attribute.cs | 10 +-
Library/Web/ControllerBase.cs | 4 +
Library/Web/Router.cs | 57 +++++++
Library/Web/WebAPIAttribute.cs | 2 +
MyDll/SampleCondition.cs | 1 +
SereinFlow.sln | 6 +
SereinWAT/Serein.Module.WAT.csproj | 18 +++
SereinWAT/SereinWAT.cs | 152 ++++++++++++++++++
WorkBench/App.xaml.cs | 4 +
WorkBench/MainWindow.xaml.cs | 102 +++++++++---
WorkBench/Node/View/ActionNodeControl.xaml | 4 +-
.../Node/View/ActionRegionControl.xaml.cs | 2 +
WorkBench/Node/View/DllControlControl.xaml.cs | 16 +-
WorkBench/Node/View/FlipflopNodeControl.xaml | 4 +-
WorkBench/Node/View/NodeControlBase.cs | 11 ++
.../ViewModel/ActionNodeControlViewModel.cs | 2 -
WorkBench/SereinOutputFileData.cs | 52 ++++++
WorkBench/Themes/TypeViewerWindow.xaml.cs | 2 +
37 files changed, 700 insertions(+), 80 deletions(-)
create mode 100644 SereinWAT/Serein.Module.WAT.csproj
create mode 100644 SereinWAT/SereinWAT.cs
diff --git a/Library/DbSql/DBSync.cs b/Library/DbSql/DBSync.cs
index 5caa4a9..c8abbbc 100644
--- a/Library/DbSql/DBSync.cs
+++ b/Library/DbSql/DBSync.cs
@@ -114,7 +114,9 @@ namespace Serein.DbSql
{
// Console.WriteLine($"主数据库无法连接,IP:{IP},端口:{Port}");
DBSync.SetIsNeedSyncData(true); // 网络不可达
+
return null;
+
}
// 检查是否需要同步数据
@@ -134,7 +136,9 @@ namespace Serein.DbSql
catch // (Exception ex)
{
// Console.WriteLine($"发生异常:{ex.Message}");
+
return null;
+
}
}
@@ -168,8 +172,14 @@ namespace Serein.DbSql
}
public static string GetDescription(DBSyncExType value)
{
+
FieldInfo field = value.GetType().GetField(value.ToString());
+
+
+
DescriptionAttribute attribute = (DescriptionAttribute)field.GetCustomAttribute(typeof(DescriptionAttribute));
+
+
return attribute == null ? value.ToString() : attribute.Description;
}
@@ -184,15 +194,21 @@ namespace Serein.DbSql
///
/// 主数据库配置
///
+
private static ConnectionConfig PrimaryConfig { get; set; }
+
///
/// 从数据库配置
///
+
private static ConnectionConfig SecondaryConfig { get; set; }
+
///
/// 主数据库IP
///
+
private static string Host { get; set; }
+
///
/// 主数据库端口
///
@@ -200,8 +216,12 @@ namespace Serein.DbSql
///
/// 同步数据事件(远程数据库,本地数据库,是否执行成功)
///
+
private static Func SyncDataEvent { get; set; }
+
+
private static Action StateChangeEvent { get; set; }
+
///
/// 数据库设置锁
///
@@ -467,8 +487,14 @@ namespace Serein.DbSql
public static string GetDescription(DBSyncStart value)
{
+
FieldInfo field = value.GetType().GetField(value.ToString());
+
+
+
DescriptionAttribute attribute = (DescriptionAttribute)field.GetCustomAttribute(typeof(DescriptionAttribute));
+
+
return attribute == null ? value.ToString() : attribute.Description;
}
@@ -565,11 +591,15 @@ namespace Serein.DbSql
};
break;
default:
+
config = null;
+
break;
}
+
return config;
+
}
}
diff --git a/Library/DbSql/RepositoryBase.cs b/Library/DbSql/RepositoryBase.cs
index e98ba8f..0cd8253 100644
--- a/Library/DbSql/RepositoryBase.cs
+++ b/Library/DbSql/RepositoryBase.cs
@@ -398,7 +398,9 @@ namespace Serein.Helper
isHaveErr = true;
ErrMsg = ex.Message;
+
return null;
+
}
}
@@ -503,7 +505,9 @@ namespace Serein.Helper
}
+
public virtual string GetPageList(Pagination pagination, Expression> where = null)
+
{
//DatabaseSync.StartcaControls();
return new
@@ -523,7 +527,9 @@ namespace Serein.Helper
}
+
public virtual List GetTop(int Top, Expression> expression, OrderByType _OrderByType = OrderByType.Asc, Expression> where = null, string selstr = "*")
+
{
return SyncRead(db => db.Queryable().Select(selstr).WhereIF(where != null, where)
.Take(Top)
@@ -539,14 +545,18 @@ namespace Serein.Helper
///
///
///
+
public virtual TEntity GetFirst(Expression> OrderExpression, OrderByType _OrderByType = OrderByType.Asc, Expression> where = null)
+
{
return SyncRead(db => db.Queryable().Filter(filterName, isDisabledGobalFilter: true).WhereIF(where != null, where)
.OrderBy(OrderExpression, _OrderByType)
.First());
}
+
public virtual List GetList(Pagination pagination, Expression> where = null)
+
{
int totalNumber = 0;
List result = SyncRead(db => db.Queryable().WhereIF(where != null, where).OrderBy(pagination.sidx + " " + pagination.sord)
@@ -557,7 +567,9 @@ namespace Serein.Helper
}
+
public virtual List GetList(Expression> where = null)
+
{
return SyncRead(db => db.Queryable().WhereIF(where != null, where).Filter(filterName, isDisabledGobalFilter: true)
.ToList());
@@ -569,7 +581,11 @@ namespace Serein.Helper
}
+
+
public virtual DataTable GetDataTable(Expression> where = null, Pagination pagination = null)
+
+
{
if (pagination != null)
{
@@ -598,7 +614,9 @@ namespace Serein.Helper
return 0;
});
+
filterName = null;
+
}
@@ -818,13 +836,17 @@ namespace Serein.Helper
///
/// /排序列
///
+
public string sidx { get; set; }
+
///
/// 排序类型
///
+
public string sord { get; set; }
+
///
/// 总记录数
///
diff --git a/Library/DynamicFlow/DynamicContext.cs b/Library/DynamicFlow/DynamicContext.cs
index 82c9ffa..eee62b7 100644
--- a/Library/DynamicFlow/DynamicContext.cs
+++ b/Library/DynamicFlow/DynamicContext.cs
@@ -39,7 +39,9 @@ namespace Serein.DynamicFlow
///
/// 动态流程上下文
///
+
public class DynamicContext(IServiceContainer serviceContainer)
+
{
private readonly string contextGuid = "";//System.Guid.NewGuid().ToString();
diff --git a/Library/DynamicFlow/MethodDetails.cs b/Library/DynamicFlow/MethodDetails.cs
index bc0e99b..b766f19 100644
--- a/Library/DynamicFlow/MethodDetails.cs
+++ b/Library/DynamicFlow/MethodDetails.cs
@@ -34,19 +34,25 @@ namespace Serein.DynamicFlow
/// 方法需要的类型
///
public Type DataType { get; set; }
+
///
/// 方法入参参数名称
///
public string ParameterName { get; set; }
+
///
/// 入参值
///
+
public string DataValue { get; set; }
+
+
public string[] Items { get; set; }
+
public ExplicitData Clone() => new()
{
Index = Index,
@@ -64,7 +70,7 @@ namespace Serein.DynamicFlow
public class MethodDetails
{
- public MethodDetails CpoyNew()
+ public MethodDetails Clone()
{
return new MethodDetails
{
@@ -73,37 +79,45 @@ namespace Serein.DynamicFlow
MethodDelegate = MethodDelegate,
MethodDynamicType = MethodDynamicType,
MethodGuid = Guid.NewGuid().ToString(),
- MethodTips = MethodTips + " Cpoy",
- //ParameterTypes = ParameterTypes,
+ MethodTips = MethodTips ,
ReturnType = ReturnType,
MethodName = MethodName,
MethodLockName = MethodLockName,
- //ExplicitDataValues = ExplicitDataValues.Select(it => "").ToArray(),
+
ExplicitDatas = ExplicitDatas.Select(it => it.Clone()).ToArray(),
- //IsExplicits = IsExplicits,
};
}
///
/// 作用实例
///
+
public Type ActingInstanceType { get; set; }
+
///
/// 作用实例
///
+
public object ActingInstance { get; set; }
+
///
/// 方法GUID
///
+
public string MethodGuid { get; set; }
+
///
/// 方法名称
///
+
public string MethodName { get; set; }
+
///
/// 方法委托
///
+
public Delegate MethodDelegate { get; set; }
+
///
/// 节点类型
///
@@ -111,28 +125,36 @@ namespace Serein.DynamicFlow
///
/// 锁名称
///
+
public string MethodLockName { get; set; }
+
///
/// 方法说明
///
+
public string MethodTips { get; set; }
+
///
/// 参数内容
///
+
public ExplicitData[] ExplicitDatas { get; set; }
+
///
/// 出参类型
///
+
public Type ReturnType { get; set; }
+
public bool IsCanConnect(Type returnType)
{
if (ExplicitDatas.Length == 0)
diff --git a/Library/DynamicFlow/NodeFlowStarter.cs b/Library/DynamicFlow/NodeFlowStarter.cs
index bcad046..672e84c 100644
--- a/Library/DynamicFlow/NodeFlowStarter.cs
+++ b/Library/DynamicFlow/NodeFlowStarter.cs
@@ -4,7 +4,12 @@ using Serein.DynamicFlow.NodeModel;
using Serein.DynamicFlow.Tool;
using Serein.Web;
using SqlSugar;
+using System;
using System.Collections.Concurrent;
+using System.Collections.Generic;
+using System.Linq;
+using System.Threading;
+using System.Threading.Tasks;
namespace DynamicDemo.Node
{
@@ -14,13 +19,19 @@ namespace DynamicDemo.Node
}
+
public class NodeFlowStarter(IServiceContainer serviceContainer,List methodDetails)
+
{
private readonly IServiceContainer ServiceContainer = serviceContainer;
private readonly List methodDetails = methodDetails;
+
private Action ExitAction = null;
+
+
private DynamicContext context = null;
+
public NodeRunTcs MainCts;
///
@@ -28,6 +39,11 @@ namespace DynamicDemo.Node
///
///
///
+ //public async Task RunAsync1(List nodes)
+ //{
+ // await Task.Run(async ()=> await StartRunAsync(nodes));
+ //}
+
public async Task RunAsync(List nodes)
{
var startNode = nodes.FirstOrDefault(p => p.IsStart);
@@ -109,18 +125,24 @@ namespace DynamicDemo.Node
try
{
+
if (!DelegateCache.GlobalDicDelegates.TryGetValue(md.MethodName, out Delegate del))
{
return;
}
+
var func = md.ExplicitDatas.Length == 0 ? ((Func