private bool IsChildAllFunction(BuiltInFunctionIDType idType, string parentID, SCConditionCalculatingContext callerContext) { parentID.CheckStringIsNullOrEmpty("parentID"); bool result = false; SCUser currentUser = (SCUser)callerContext.CurrentObject; switch (idType) { case BuiltInFunctionIDType.CodeName: result = currentUser.CurrentParents.AllAndNotEmpty(p => string.Compare(p.Properties.GetValue("CodeName", string.Empty), parentID, true) == 0); break; case BuiltInFunctionIDType.Guid: result = currentUser.CurrentParentRelations.AllAndNotEmpty(r => string.Compare(r.ParentID, parentID, true) == 0); break; case BuiltInFunctionIDType.FullPath: { SCObjectAndRelation parent = GetObjectByID(idType, parentID, callerContext); if (parent != null) { result = currentUser.CurrentParentRelations.AllAndNotEmpty(r => string.Compare(r.ParentID, parent.ID, true) == 0); } break; } default: throw new NotSupportedException(string.Format("不支持的BuiltInFunctionIDType类型{0}", idType)); } return(result); }
private SCObjectAndRelation GetObjectByID(BuiltInFunctionIDType idType, string objectID, SCConditionCalculatingContext callerContext) { SCCalculatorObjectCache cache = null; if (callerContext.ExtendedData.ContainsKey("SCCalculatorObjectCache")) { cache = (SCCalculatorObjectCache)callerContext.ExtendedData["SCCalculatorObjectCache"]; } if (cache == null) { cache = new SCCalculatorObjectCache(); callerContext.ExtendedData.Add("SCCalculatorObjectCache", cache); } SCObjectAndRelation result = null; if (cache.TryGetValue(idType, objectID, out result) == false) { result = QueryObjectByID(idType, objectID); cache.AddObject(idType, objectID, result); } return(result); }
private bool IsChildAllFunction(BuiltInFunctionIDType idType, string parentID, SCConditionCalculatingContext callerContext) { parentID.CheckStringIsNullOrEmpty("parentID"); bool result = false; SCUser currentUser = (SCUser)callerContext.CurrentObject; switch (idType) { case BuiltInFunctionIDType.CodeName: result = currentUser.CurrentParents.AllAndNotEmpty(p => string.Compare(p.Properties.GetValue("CodeName", string.Empty), parentID, true) == 0); break; case BuiltInFunctionIDType.Guid: result = currentUser.CurrentParentRelations.AllAndNotEmpty(r => string.Compare(r.ParentID, parentID, true) == 0); break; case BuiltInFunctionIDType.FullPath: { SCObjectAndRelation parent = GetObjectByID(idType, parentID, callerContext); if (parent != null) result = currentUser.CurrentParentRelations.AllAndNotEmpty(r => string.Compare(r.ParentID, parent.ID, true) == 0); break; } default: throw new NotSupportedException(string.Format("不支持的BuiltInFunctionIDType类型{0}", idType)); } return result; }
public void AddObject(BuiltInFunctionIDType idType, string objectID, SCObjectAndRelation relation) { if (relation != null) { AddObjectToDictionary(this._CacheByCodeName, relation.CodeName, relation); AddObjectToDictionary(this._CacheByID, relation.ID, relation); AddObjectToDictionary(this._CacheByFullPath, relation.FullPath, relation); } else { Dictionary <string, SCObjectAndRelation> dictionary = IDTypeToDictionary(idType); dictionary[objectID] = relation; //null } }
public void AddObject(BuiltInFunctionIDType idType, string objectID, SCObjectAndRelation relation) { if (relation != null) { AddObjectToDictionary(this._CacheByCodeName, relation.CodeName, relation); AddObjectToDictionary(this._CacheByID, relation.ID, relation); AddObjectToDictionary(this._CacheByFullPath, relation.FullPath, relation); } else { Dictionary<string, SCObjectAndRelation> dictionary = IDTypeToDictionary(idType); dictionary[objectID] = relation; //null } }
private bool IsDescendantFunction(BuiltInFunctionIDType idType, string ancestorID, SCConditionCalculatingContext callerContext) { ancestorID.CheckStringIsNullOrEmpty("ancestorID"); bool result = false; SCObjectAndRelation ancestor = GetObjectByID(idType, ancestorID, callerContext); if (ancestor != null) { result = callerContext.CurrentObject.CurrentParentRelations.Exists(r => r.FullPath.IndexOf(ancestor.FullPath, StringComparison.OrdinalIgnoreCase) == 0); } return(result); }
private Dictionary<string, SCObjectAndRelation> IDTypeToDictionary(BuiltInFunctionIDType idType) { Dictionary<string, SCObjectAndRelation> result = null; switch (idType) { case BuiltInFunctionIDType.CodeName: result = this._CacheByCodeName; break; case BuiltInFunctionIDType.Guid: result = this._CacheByID; break; case BuiltInFunctionIDType.FullPath: result = this._CacheByFullPath; break; default: throw new NotSupportedException(string.Format("不支持的BuiltInFunctionIDType类型{0}", idType)); } return result; }
private static SCObjectAndRelation QueryObjectByID(BuiltInFunctionIDType idType, string objectID) { SCObjectAndRelation result = null; switch (idType) { case BuiltInFunctionIDType.Guid: result = SCSnapshotAdapter.Instance.QueryObjectAndRelationByIDs(_AllSchemaTypes, new string[] { objectID }, false, DateTime.MinValue).FirstOrDefault(); break; case BuiltInFunctionIDType.CodeName: result = SCSnapshotAdapter.Instance.QueryObjectAndRelationByCodeNames(_AllSchemaTypes, new string[] { objectID }, false, DateTime.MinValue).FirstOrDefault(); break; case BuiltInFunctionIDType.FullPath: result = SCSnapshotAdapter.Instance.QueryObjectAndRelationByFullPaths(_AllSchemaTypes, new string[] { objectID }, false, DateTime.MinValue).FirstOrDefault(); break; default: throw new NotSupportedException(string.Format("不支持的BuiltInFunctionIDType类型{0}", idType)); } return(result); }
private Dictionary <string, SCObjectAndRelation> IDTypeToDictionary(BuiltInFunctionIDType idType) { Dictionary <string, SCObjectAndRelation> result = null; switch (idType) { case BuiltInFunctionIDType.CodeName: result = this._CacheByCodeName; break; case BuiltInFunctionIDType.Guid: result = this._CacheByID; break; case BuiltInFunctionIDType.FullPath: result = this._CacheByFullPath; break; default: throw new NotSupportedException(string.Format("不支持的BuiltInFunctionIDType类型{0}", idType)); } return(result); }
private static SCObjectAndRelation QueryObjectByID(BuiltInFunctionIDType idType, string objectID) { SCObjectAndRelation result = null; switch (idType) { case BuiltInFunctionIDType.Guid: result = SCSnapshotAdapter.Instance.QueryObjectAndRelationByIDs(_AllSchemaTypes, new string[] { objectID }, false, DateTime.MinValue).FirstOrDefault(); break; case BuiltInFunctionIDType.CodeName: result = SCSnapshotAdapter.Instance.QueryObjectAndRelationByCodeNames(_AllSchemaTypes, new string[] { objectID }, false, DateTime.MinValue).FirstOrDefault(); break; case BuiltInFunctionIDType.FullPath: result = SCSnapshotAdapter.Instance.QueryObjectAndRelationByFullPaths(_AllSchemaTypes, new string[] { objectID }, false, DateTime.MinValue).FirstOrDefault(); break; default: throw new NotSupportedException(string.Format("不支持的BuiltInFunctionIDType类型{0}", idType)); } return result; }
private SCObjectAndRelation GetObjectByID(BuiltInFunctionIDType idType, string objectID, SCConditionCalculatingContext callerContext) { SCCalculatorObjectCache cache = null; if (callerContext.ExtendedData.ContainsKey("SCCalculatorObjectCache")) cache = (SCCalculatorObjectCache)callerContext.ExtendedData["SCCalculatorObjectCache"]; if (cache == null) { cache = new SCCalculatorObjectCache(); callerContext.ExtendedData.Add("SCCalculatorObjectCache", cache); } SCObjectAndRelation result = null; if (cache.TryGetValue(idType, objectID, out result) == false) { result = QueryObjectByID(idType, objectID); cache.AddObject(idType, objectID, result); } return result; }
private bool IsDescendantFunction(BuiltInFunctionIDType idType, string ancestorID, SCConditionCalculatingContext callerContext) { ancestorID.CheckStringIsNullOrEmpty("ancestorID"); bool result = false; SCObjectAndRelation ancestor = GetObjectByID(idType, ancestorID, callerContext); if (ancestor != null) result = callerContext.CurrentObject.CurrentParentRelations.Exists(r => r.FullPath.IndexOf(ancestor.FullPath, StringComparison.OrdinalIgnoreCase) == 0); return result; }
public bool TryGetValue(BuiltInFunctionIDType idType, string objectID, out SCObjectAndRelation result) { Dictionary <string, SCObjectAndRelation> dictionary = IDTypeToDictionary(idType); return(dictionary.TryGetValue(objectID, out result)); }
public bool TryGetValue(BuiltInFunctionIDType idType, string objectID, out SCObjectAndRelation result) { Dictionary<string, SCObjectAndRelation> dictionary = IDTypeToDictionary(idType); return dictionary.TryGetValue(objectID, out result); }