/// <summary> /// 按照条件列进行数据行的筛选,返回筛选后的行集合 /// </summary> /// <returns></returns> public SOARolePropertyRowCollection FilterByConditionColumn() { WfConditionDescriptor condition = null; SOARoleContext context = SOARoleContext.Current; if (context != null) { if (context.Process != null) { condition = new WfConditionDescriptor(context.Process.Descriptor); } else { condition = new WfConditionDescriptor(null); } } return(this.Query(row => { bool matched = true; if (condition != null) { condition.Expression = row.Values.GetValue(SOARolePropertyDefinition.ConditionColumn, row.GetPropertyDefinitions().GetColumnDefaultValue(SOARolePropertyDefinition.ConditionColumn, string.Empty)); matched = row.EvaluateCondition(condition); } return matched; })); }
private bool ExtractSOARoleMatrixRows(SOARole innerRole, SOARolePropertyRowCollection extractedRows) { bool extracted = false; SOARoleContext.DoAction(innerRole, SOARoleContext.CurrentProcess, (context) => { SOARolePropertyRowCollection subRows = innerRole.Rows.Query(context.QueryParams); if (this.Role != null) { if (((SOARole)this.Role).MatrixType == WfMatrixType.ActivityMatrix && innerRole.MatrixType != WfMatrixType.ActivityMatrix) { subRows = MergeActivityRowPropertiesByRows(subRows); } foreach (SOARolePropertyRow subRow in subRows) { SOARolePropertyRowCollection subExtractedRows = subRow.ExtractMatrixRows(); extractedRows.CopyFrom(subExtractedRows); } } extracted = true; }); return(extracted); }
/// <summary> /// 从矩阵中获得对象。这主要取决于上下文中的参数 /// </summary> /// <returns></returns> public OguDataCollection <IOguObject> GetObjectsFromMatrix() { OguDataCollection <IOguObject> result = new OguDataCollection <IOguObject>(); SOARoleContext context = SOARoleContext.Current; if (context != null && context.QueryParams.Count > 0) { SOARolePropertyRowCollection matchedRows = this.Rows.Query(context.QueryParams); matchedRows = matchedRows.ExtractMatrixRows(); foreach (SOARolePropertyRowUsers rowUsers in matchedRows.GenerateRowsUsers()) { foreach (IUser user in rowUsers.Users) { if (result.Contains(user) == false) { result.Add(user); } } } } return(result); }
public static SOARoleContext CreateContext(SOARolePropertyDefinitionCollection propertyDefines, IWfProcess process) { propertyDefines.NullCheck("propertyDefines"); SOARolePropertiesQueryParamCollection queryParams = CreateQueryParams(propertyDefines, process); SOARoleContext context = SOARoleContext.CreateContext(queryParams, process); context.PropertyDefinitions = propertyDefines; return(context); }
public void FillCreateActivityParams(WfCreateActivityParamCollection capc, PropertyDefineCollection definedProperties) { SOARoleContext context = SOARoleContext.Current; if (context != null && context.QueryParams.Count > 0) { SOARolePropertyRowCollection matchedRows = this.Rows.Query(context.QueryParams); matchedRows = matchedRows.ExtractMatrixRows(); matchedRows.FillCreateActivityParams(capc, this.PropertyDefinitions, definedProperties); } }
public static SOARoleContext CreateContext(IEnumerable <SOARolePropertiesQueryParam> queryParams, IWfProcess process) { queryParams.NullCheck("queryParams"); ObjectContextCache.Instance.ContainsKey(CacheKey).TrueThrow("SOARoleContext已经在使用中,不能嵌套使用"); SOARoleContext context = new SOARoleContext(); context._Process = process; context.QueryParams.CopyFrom(queryParams); ObjectContextCache.Instance.Add(CacheKey, context); return(context); }
internal static void FillInternalDynamicRoleUsers(string roleName, OguDataCollection <IUser> users) { SOARoleContext context = SOARoleContext.Current; WfDynamicResourceDescriptor dynResource = new WfDynamicResourceDescriptor(); if (context != null) { dynResource.SetProcessInstance(context.Process); } dynResource.Condition.Expression = roleName; dynResource.FillUsers(users); }
/// <summary> /// 创建一个新的上下文,并且使用它进行计算。计算完成后恢复上下文。 /// </summary> /// <param name="propertyDefines"></param> /// <param name="process"></param> /// <param name="action"></param> public static void DoNewContextAction(SOARolePropertyDefinitionCollection propertyDefines, IWfProcess process, Action <SOARoleContext> action) { if (action != null) { SOARoleContext originalRoleContext = SOARoleContext.Current; try { SOARoleContext.Current = null; SOARoleContext.CreateContext(propertyDefines, process); action(SOARoleContext.Current); } finally { SOARoleContext.Current = originalRoleContext; } } }
/// <summary> /// 创建一个新的上下文,并且使用它进行计算。计算完成后恢复上下文。 /// </summary> /// <param name="role"></param> /// <param name="process"></param> /// <param name="action"></param> public static void DoNewContextAction(IRole role, IWfProcess process, Action <SOARoleContext> action) { if (action != null) { SOARoleContext originalRoleContext = SOARoleContext.Current; try { SOARoleContext.Current = null; SOARoleContext.CreateContext(role, process); action(SOARoleContext.Current); } finally { SOARoleContext.Current = originalRoleContext; } } }
/// <summary> /// 不带条件地筛选 /// </summary> /// <param name="queryParams"></param> /// <param name="matchAny"></param> /// <returns></returns> public SOARolePropertyRowCollection QueryWithoutCondition(IEnumerable <SOARolePropertiesQueryParam> queryParams, bool matchAny = false) { WfConditionDescriptor condition = null; SOARoleContext context = SOARoleContext.Current; if (context != null) { if (context.Process != null) { condition = new WfConditionDescriptor(context.Process.Descriptor); } else { condition = new WfConditionDescriptor(null); } } return(this.Query(row => row.Values.MatchQueryValues(queryParams, matchAny))); }
/// <summary> /// 展开内部角色的行 /// </summary> /// <param name="innerRole"></param> /// <param name="extractedRows"></param> /// <returns></returns> private bool ExtractSOARoleRows(SOARole innerRole, SOARolePropertyRowCollection extractedRows) { bool extracted = false; if (innerRole.PropertyDefinitions.Count > 0) { SOARoleContext originalContext = SOARoleContext.Current; SOARoleContext.Current = null; try { using (SOARoleContext innerContext = SOARoleContext.CreateContext(innerRole, originalContext.Process)) { extracted = this.ExtractSOARoleMatrixRows(innerRole, extractedRows); } } finally { SOARoleContext.Current = originalContext; } } return(extracted); }
public SOARolePropertyRowCollection Query(IEnumerable <SOARolePropertiesQueryParam> queryParams, bool matchAny = false) { WfConditionDescriptor condition = null; SOARoleContext context = SOARoleContext.Current; if (context != null) { if (context.Process != null) { condition = new WfConditionDescriptor(context.Process.Descriptor); } else { condition = new WfConditionDescriptor(null); } } return(this.Query(row => { bool matched = row.Values.MatchQueryValues(queryParams, matchAny); if (matched) { if (condition != null) { condition.Expression = row.Values.GetValue(SOARolePropertyDefinition.ConditionColumn, row.GetPropertyDefinitions().GetColumnDefaultValue(SOARolePropertyDefinition.ConditionColumn, string.Empty)); matched = row.EvaluateCondition(condition); } } return matched; })); }
public static SOARoleContext CreateContext(IEnumerable<SOARolePropertiesQueryParam> queryParams, IWfProcess process) { queryParams.NullCheck("queryParams"); ObjectContextCache.Instance.ContainsKey(CacheKey).TrueThrow("SOARoleContext已经在使用中,不能嵌套使用"); SOARoleContext context = new SOARoleContext(); context._Process = process; context.QueryParams.CopyFrom(queryParams); ObjectContextCache.Instance.Add(CacheKey, context); return context; }