using DS.Module.Core.Data;
namespace DS.Module.Core.Condition
{
public class ConditionHelper
{
///
/// 根据ContitionContent条件,从数据上下文TaskFlowDataContext中取出指定数据,然后判断条件是否符合
///
public static bool IsPass(ConditionContent conditionContent, TaskFlowDataContext dataContext)
{
bool? thisScopeResult = null;
if (conditionContent == null || conditionContent.Conditions == null || conditionContent.Conditions.Count == 0)
{
return true;
}
IDictionary? dataDic = null;
if (!string.IsNullOrEmpty(conditionContent.SourceName) && 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 && dataDic.TryGetValue(item.Field, out object? objVal))
{
valStr = objVal?.ToString();
}
else if (dataContext.ContainsKey(item.Field))
{
var obj = dataContext.Get