mirror of
https://gitee.com/langsisi_admin/serein-flow
synced 2026-03-05 17:20:47 +08:00
修改了logwindows输出,避免高频输出时卡死。修改了流程运行上下文,使节点具备终止分支运行的能力。
This commit is contained in:
99
WorkBench.Remote/Themes/ConditionControlModel.cs
Normal file
99
WorkBench.Remote/Themes/ConditionControlModel.cs
Normal file
@@ -0,0 +1,99 @@
|
||||
namespace DynamicDemo.Themes;
|
||||
|
||||
public enum ConditionType
|
||||
{
|
||||
GreaterThan,
|
||||
LessThan,
|
||||
EqualTo,
|
||||
Between,
|
||||
NotBetween,
|
||||
NotInRange,
|
||||
IsTrue,
|
||||
IsFalse,
|
||||
Contains,
|
||||
DoesNotContain,
|
||||
IsNotEmpty
|
||||
}
|
||||
|
||||
public abstract class ConditionNode
|
||||
{
|
||||
public ConditionType Condition { get; set; }
|
||||
public abstract bool Evaluate(object value);
|
||||
}
|
||||
|
||||
public class IntConditionNode : ConditionNode
|
||||
{
|
||||
public int Value { get; set; }
|
||||
public int MinValue { get; set; }
|
||||
public int MaxValue { get; set; }
|
||||
public List<int> ExcludeValues { get; set; }
|
||||
|
||||
public override bool Evaluate(object value)
|
||||
{
|
||||
if (value is int intValue)
|
||||
{
|
||||
switch (Condition)
|
||||
{
|
||||
case ConditionType.GreaterThan:
|
||||
return intValue > Value;
|
||||
case ConditionType.LessThan:
|
||||
return intValue < Value;
|
||||
case ConditionType.EqualTo:
|
||||
return intValue == Value;
|
||||
case ConditionType.Between:
|
||||
return intValue >= MinValue && intValue <= MaxValue;
|
||||
case ConditionType.NotBetween:
|
||||
return intValue < MinValue || intValue > MaxValue;
|
||||
case ConditionType.NotInRange:
|
||||
return !ExcludeValues.Contains(intValue);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class BoolConditionNode : ConditionNode
|
||||
{
|
||||
public override bool Evaluate(object value)
|
||||
{
|
||||
if (value is bool boolValue)
|
||||
{
|
||||
switch (Condition)
|
||||
{
|
||||
case ConditionType.IsTrue:
|
||||
return boolValue;
|
||||
case ConditionType.IsFalse:
|
||||
return !boolValue;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public class StringConditionNode : ConditionNode
|
||||
{
|
||||
public string Substring { get; set; }
|
||||
|
||||
public override bool Evaluate(object value)
|
||||
{
|
||||
if (value is string stringValue)
|
||||
{
|
||||
switch (Condition)
|
||||
{
|
||||
case ConditionType.Contains:
|
||||
return stringValue.Contains(Substring);
|
||||
case ConditionType.DoesNotContain:
|
||||
return !stringValue.Contains(Substring);
|
||||
case ConditionType.IsNotEmpty:
|
||||
return !string.IsNullOrEmpty(stringValue);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user