public override object GetValue(SysExpression expr, EntityCache cache, ExpressionCache expr_cache, SysProcessInstance pi, SysActivityInstance ai) { SysProcess process = pi.Process; if (process.ProcessEntity == null) { throw new ApplicationException("流程实体为空"); } SysOneMoreRelation relation = expr.Relation; if (relation == null) { throw new ApplicationException("表达式的关系为空"); } if (!relation.ChildEntityId.HasValue) { throw new ApplicationException("表达式的子实体为空"); } if (!process.EntityId.HasValue) { throw new ApplicationException("流程的实体为空"); } if (expr.Relation.ChildEntityId.Value != process.EntityId.Value) { throw new ApplicationException("不正确的关系"); } if (!relation.ParentEntityId.HasValue) { throw new ApplicationException("关系的父实体为空"); } if (!relation.ChildFieldId.HasValue) { throw new ApplicationException("关系的ChildFieldId为空"); } long local1 = relation.ChildFieldId.Value; if (relation.ChildField == null) { throw new ApplicationException("关系的对应字段为空"); } SysEntity processEntity = pi.Process.ProcessEntity; int objectId = pi.ObjectId; EntityData data = cache.GetObject(processEntity, objectId); SysEntity parentEntity = relation.ParentEntity; if (data.ContainsKey(relation.ChildField.FieldName)) { int num2 = Convert.ToInt32(data[relation.ChildField.FieldName]); if (num2 != 0) { object obj2 = cache.GetObject(parentEntity, num2)[expr.Field.FieldName]; expr_cache.Add(expr, obj2); return(obj2); } } throw new ApplicationException(string.Format("计算表达式时需要字段{0},但其未赋值或为空", relation.ChildField.FieldName)); }
public override object GetValue(SysExpression expr, EntityCache cache, ExpressionCache expr_cache, SysProcessInstance pi, SysActivityInstance ai) { SysProcess process = pi.Process; SysEntity activityEntity = process.ActivityEntity; if (activityEntity == null) { throw new ApplicationException("活动实体为空"); } SysOneMoreRelation relation = expr.Relation; if (relation == null) { throw new ApplicationException("表达式的关系为空"); } if (!relation.ChildEntityId.HasValue) { throw new ApplicationException("表达式的子实体为空"); } if (!process.ActivityEntityId.HasValue) { throw new ApplicationException("活动的实体为空"); } if (expr.Relation.ChildEntityId.Value != process.ActivityEntityId.Value) { throw new ApplicationException("不正确的关系"); } if (!relation.ParentEntityId.HasValue) { throw new ApplicationException("关系的父实体为空"); } if (!relation.ChildFieldId.HasValue) { throw new ApplicationException("关系的ChildFieldId为空"); } long local1 = relation.ChildFieldId.Value; if (relation.ChildField == null) { throw new ApplicationException("关系的对应字段为空"); } int activityInstanceId = ai.ActivityInstanceId; EntityData data = cache.GetObject(activityEntity, activityInstanceId); SysEntity parentEntity = relation.ParentEntity; int num2 = Convert.ToInt32(data[relation.ChildField.FieldName]); object obj2 = cache.GetObject(parentEntity, num2)[expr.Field.FieldName]; expr_cache.Add(expr, obj2); return(obj2); }
private static void LoadEntitySchema() { EntityCacheBase cache = EntityCacheBase.LoadCache(); using (List <SysEntity> .Enumerator enumerator = cache.SysEntity.GetEnumerator()) { while (enumerator.MoveNext()) { Func <SysMobileStepEntity, bool> predicate = null; SysEntity e = enumerator.Current; EntitySchema es = new EntitySchema(); bool? isHistory = e.IsHistory; es.IsHistory = isHistory.HasValue ? isHistory.GetValueOrDefault() : false; SysOneMoreRelation relation = e.ChildOneMoreRelations.FirstOrDefault <SysOneMoreRelation>(p => p.Is_Tree == true); if (relation != null) { es.TreeRelationFieldName = relation.ChildField.FieldName; } es.IsChangeTableVersion = false; if (predicate == null) { predicate = delegate(SysMobileStepEntity p) { long?entityId = p.EntityId; long num = e.EntityId; return((entityId.GetValueOrDefault() == num) && entityId.HasValue); }; } if (cache.SysMobileStepEntity.Where <SysMobileStepEntity>(predicate).Count <SysMobileStepEntity>() > 0) { es.IsChangeTableVersion = true; } es.EntityId = e.EntityId; es.EntityName = e.EntityName; es.KeyName = e.GetKeyFieldName(); es.EntityType = cache.GetEntityType(e.EntityId); es.DisplayName = e.GetDisplayFieldName(); int?privilegeMode = e.PrivilegeMode; es.PrivilegeMode = privilegeMode.HasValue ? privilegeMode.GetValueOrDefault() : -2147483647; privilegeMode = e.RequiredLevel; es.RequiredLevel = privilegeMode.HasValue ? privilegeMode.GetValueOrDefault() : -2147483647; LoadUniqueKey(es, e, cache); LoadFields(es, e, cache); LoadRelations(es, e, cache); Add(es); } } }