using DS.Module.Core.Data;
using Fasterflect;
namespace DS.Module.Core.Condition
{
public class ConditionHelper
{
///
/// 根据ContitionContent条件,从数据上下文TaskFlowDataContext中取出指定数据,然后判断条件是否符合
///
public static bool IsPass(ContitionContent conditionContent, TaskFlowDataContext dataContext)
{
bool? thisScopeResult = null;
if (conditionContent == null || conditionContent.Conditions == null || conditionContent.Conditions.Count == 0)
{
return true;
}
IDictionary? dataDic = null;
if (dataContext.ContainsKey(conditionContent.SourceName))
{
dataDic = dataContext[conditionContent.SourceName] as IDictionary;
}
foreach (var item in conditionContent.Conditions)
{
var itemResult = false;
string? valStr = null;
if (dataDic != null)
{
var obj = dataDic[item.Field];
valStr = obj?.ToString();
}
else if (dataContext.ContainsKey(item.Field))
{
var obj = dataContext.Get