コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
		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;
		}
コード例 #4
0
        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
            }
        }
コード例 #5
0
		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
			}
		}
コード例 #6
0
        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);
        }
コード例 #7
0
		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;
		}
コード例 #8
0
        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);
        }
コード例 #9
0
        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);
        }
コード例 #10
0
		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;
		}
コード例 #11
0
		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;
		}
コード例 #12
0
		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;
		}
コード例 #13
0
        public bool TryGetValue(BuiltInFunctionIDType idType, string objectID, out SCObjectAndRelation result)
        {
            Dictionary <string, SCObjectAndRelation> dictionary = IDTypeToDictionary(idType);

            return(dictionary.TryGetValue(objectID, out result));
        }
コード例 #14
0
		public bool TryGetValue(BuiltInFunctionIDType idType, string objectID, out SCObjectAndRelation result)
		{
			Dictionary<string, SCObjectAndRelation> dictionary = IDTypeToDictionary(idType);

			return dictionary.TryGetValue(objectID, out result);
		}