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);
        }
        protected override void FillPropertiesToTable(SCObjectAndRelation obj, DataRow row)
        {
            base.FillPropertiesToTable(obj, row);

            row["FIRST_NAME"] = obj.Detail.Properties.GetValue("FirstName", string.Empty);
            row["LAST_NAME"]  = obj.Detail.Properties.GetValue("LastName", string.Empty);

            row["AccountDisabled"]     = obj.Detail.Properties.GetValue("AccountDisabled", false);
            row["PasswordNotRequired"] = obj.Detail.Properties.GetValue("PasswordNotRequired", false);
            row["DontExpirePassword"]  = obj.Detail.Properties.GetValue("DontExpirePassword", false);

            row["AccountInspires"] = obj.Detail.Properties.GetValue("AccountInspires", DateTime.MinValue);
            row["AccountExpires"]  = obj.Detail.Properties.GetValue("AccountExpires", DateTime.MinValue);

            row["Address"] = obj.Detail.Properties.GetValue("Address", string.Empty);
            row["MP"]      = obj.Detail.Properties.GetValue("MP", string.Empty);
            row["WP"]      = obj.Detail.Properties.GetValue("WP", string.Empty);
            row["Sip"]     = obj.Detail.Properties.GetValue("Sip", string.Empty);

            row["OtherMP"]        = obj.Detail.Properties.GetValue("OtherMP", string.Empty);
            row["CompanyName"]    = obj.Detail.Properties.GetValue("CompanyName", string.Empty);
            row["DepartmentName"] = obj.Detail.Properties.GetValue("DepartmentName", string.Empty);

            string photoKey   = obj.Detail.Properties.GetValue("PhotoKey", string.Empty);
            string photoStamp = string.Empty;

            if (string.IsNullOrEmpty(photoKey) == false)
            {
                ImageProperty ip = (ImageProperty)MCS.Web.Library.Script.JSONSerializerExecute.Deserialize <ImageProperty>(photoKey);
                photoStamp = ip.UpdateTime.ToString("yyyyMMddHHmmss") + "|" + ip.ID;
            }

            row["PhotoTimestamp"] = photoStamp;
        }
Beispiel #4
0
        public override void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
        {
            base.Fill(target, src, relation);

            if (src.SchemaType != "Users")
            {
                throw new ArgumentException(string.Format("SchemaType不匹配", src), "src");
            }
            var wrapper = target as OGUPermission.IUserPropertyAccessible;

            if (wrapper == null)
            {
                throw new InvalidCastException("工厂创建的对象未实现IUserPropertyAccessible");
            }

            //wrapper.Levels = src.Properties.GetValue<int>("Levels", 0);

            wrapper.Attributes = src.Properties.GetValue <UserAttributesType>("CadreType", UserAttributesType.Unspecified);
            wrapper.Email      = src.Properties.GetValue <string>("Mail", string.Empty);
            wrapper.LogOnName  = src.Properties.GetValue <string>("CodeName", string.Empty);
            wrapper.ObjectType = SchemaType.Users;
            wrapper.Occupation = src.Properties.GetValue <string>("Occupation", string.Empty);
            wrapper.Rank       = src.Properties.GetValue <UserRankType>("UserRank", UserRankType.Unspecified);
            if (relation != null)
            {
                wrapper.IsSideline = !relation.Default;
            }
        }
        protected virtual void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation, SCSimpleObjectCollection parentsInfo)
        {
            Fill(target, src, relation);

            var wrapper = target as IOguPropertyAccessible;

            if (parentsInfo != null && parentsInfo.Count > 0)
                wrapper.FullPath = parentsInfo.JoinNameToFullPath() + "\\" + wrapper.Name;
        }
Beispiel #6
0
        protected virtual void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation, SCSimpleObjectCollection parentsInfo)
        {
            Fill(target, src, relation);

            var wrapper = target as IOguPropertyAccessible;

            if (parentsInfo != null && parentsInfo.Count > 0)
            {
                wrapper.FullPath = parentsInfo.JoinNameToFullPath() + "\\" + wrapper.Name;
            }
        }
        public DataSet GetRootDSE()
        {
            SCObjectAndRelationCollection root = new SCObjectAndRelationCollection()
            {
                SCObjectAndRelation.GetRoot()
            };

            DataSet ds = new DataSet();

            ds.Tables.Add(QueryHelper.GetOguTableBuilder(new string[] { "Organizations" }).Convert(root));

            return(ds);
        }
        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);
        }
Beispiel #11
0
        public override void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
        {
            base.Fill(target, src, relation);

            if (src.SchemaType != "Groups")
            {
                throw new ArgumentException(string.Format("SchemaType不匹配", src), "src");
            }
            var wrapper = target as OGUPermission.IOguPropertyAccessible;

            if (wrapper == null)
            {
                throw new InvalidCastException("工厂创建的对象未实现IOguPropertyAccessible");
            }

            wrapper.ObjectType = SchemaType.Groups;
        }
        public virtual void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
        {
            var wrapper = target as IOguPropertyAccessible;

            (wrapper != null).FalseThrow("工厂创建的对象未实现IOguPropertyAccessible");

            wrapper.Description = src.Properties.GetValue<string>("Description", string.Empty);
            wrapper.DisplayName = src.Properties.GetValue<string>("DisplayName", string.Empty);
            wrapper.ID = src.ID;
            wrapper.Name = src.Properties.GetValue<string>("Name", string.Empty);

            wrapper.Name.IsNullOrEmpty().TrueThrow<InvalidCastException>("名称不可省略");

            if (relation != null)
            {
                wrapper.SortID = relation.InnerSort.ToString();
                wrapper.Properties["ParentID"] = relation.ParentID;
            }
        }
Beispiel #13
0
        public virtual void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
        {
            var wrapper = target as IOguPropertyAccessible;

            (wrapper != null).FalseThrow("工厂创建的对象未实现IOguPropertyAccessible");

            wrapper.Description = src.Properties.GetValue <string>("Description", string.Empty);
            wrapper.DisplayName = src.Properties.GetValue <string>("DisplayName", string.Empty);
            wrapper.ID          = src.ID;
            wrapper.Name        = src.Properties.GetValue <string>("Name", string.Empty);

            wrapper.Name.IsNullOrEmpty().TrueThrow <InvalidCastException>("名称不可省略");

            if (relation != null)
            {
                wrapper.SortID = relation.InnerSort.ToString();
                wrapper.Properties["ParentID"] = relation.ParentID;
            }
        }
        public override void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
        {
            base.Fill(target, src, relation);

            if (src.SchemaType != "Users")
                throw new ArgumentException(string.Format("SchemaType不匹配", src), "src");
            var wrapper = target as OGUPermission.IUserPropertyAccessible;
            if (wrapper == null)
                throw new InvalidCastException("工厂创建的对象未实现IUserPropertyAccessible");

            //wrapper.Levels = src.Properties.GetValue<int>("Levels", 0);

            wrapper.Attributes = src.Properties.GetValue<UserAttributesType>("CadreType", UserAttributesType.Unspecified);
            wrapper.Email = src.Properties.GetValue<string>("Mail", string.Empty);
            wrapper.LogOnName = src.Properties.GetValue<string>("CodeName", string.Empty);
            wrapper.ObjectType = SchemaType.Users;
            wrapper.Occupation = src.Properties.GetValue<string>("Occupation", string.Empty);
            wrapper.Rank = src.Properties.GetValue<UserRankType>("UserRank", UserRankType.Unspecified);
            if (relation != null)
                wrapper.IsSideline = !relation.Default;
        }
Beispiel #15
0
        protected override void FillPropertiesToTable(SCObjectAndRelation obj, DataRow row)
        {
            row["OBJECTCLASS"]   = obj.SchemaType.ToUpper();
            row["STATUS"]        = (int)obj.Status;
            row["OBJ_NAME"]      = obj.Name;
            row["DISPLAY_NAME"]  = obj.DisplayName;
            row["LOGON_NAME"]    = obj.CodeName;
            row["RANK_NAME"]     = obj.Detail.Properties.GetValue("Occupation", string.Empty);
            row["E_MAIL"]        = obj.Detail.Properties.GetValue("Mail", string.Empty);
            row["GLOBAL_SORT"]   = obj.GlobalSort;
            row["ORIGINAL_SORT"] = obj.GlobalSort;
            row["ALL_PATH_NAME"] = obj.FullPath;

            row["PARENT_GUID"] = obj.ParentID;
            row["GUID"]        = obj.ID;
            row["INNER_SORT"]  = obj.InnerSort;
            row["SIDELINE"]    = obj.Default ? 0 : 1;

            string userRank = obj.Detail.Properties.GetValue("UserRank", UserRankType.Unspecified.ToString());

            if (userRank.IsNullOrEmpty())
            {
                userRank = UserRankType.Unspecified.ToString();
            }

            row["RANK_CODE"]          = Enum.Parse(typeof(UserRankType), userRank);
            row["CODE_NAME"]          = obj.CodeName;
            row["VERSION_START_TIME"] = obj.Detail.VersionStartTime;

            //string photoKey = obj.Detail.Properties.GetValue("PhotoKey", string.Empty);
            //string photoStamp = string.Empty;

            //if (string.IsNullOrEmpty(photoKey) == false)
            //{
            //    ImageProperty ip = (ImageProperty)MCS.Web.Library.Script.JSONSerializerExecute.Deserialize<ImageProperty>(photoKey);
            //    photoStamp = ip.UpdateTime.ToBinary().ToString("X") + "|" + ip.ID;
            //}

            //row["PhotoTimestamp"] = photoStamp;
        }
Beispiel #16
0
        public override void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
        {
            base.Fill(target, src, relation);

            if (src.SchemaType != "Organizations")
            {
                throw new ArgumentException(string.Format("SchemaType {0}不匹配", src), "src");
            }
            var wrapper = target as OGUPermission.IOrganizationPropertyAccessible;

            if (wrapper == null)
            {
                throw new InvalidCastException("工厂创建的对象未实现IOrganizationPropertyAccessible");
            }

            wrapper.CustomsCode     = src.Properties.GetValue <string>("CustomsCode", string.Empty); // 关区号
            wrapper.DepartmentClass = src.Properties.GetValue <DepartmentClassType>("DepartmentClass", DepartmentClassType.Unspecified);
            wrapper.DepartmentType  = src.Properties.GetValue <DepartmentTypeDefine>("DepartmentType", DepartmentTypeDefine.Unspecified);
            //wrapper.Levels = src.Properties.GetValue<int>("Levels", 0);
            wrapper.ObjectType = SchemaType.Organizations;
            wrapper.Rank       = src.Properties.GetValue <DepartmentRankType>("DepartmentRank", DepartmentRankType.None);
        }
		protected override void FillPropertiesToTable(SCObjectAndRelation obj, DataRow row)
		{
			row["OBJECTCLASS"] = obj.SchemaType.ToUpper();
			row["STATUS"] = (int)obj.Status;
			row["OBJ_NAME"] = obj.Name;
			row["DISPLAY_NAME"] = obj.DisplayName;
			row["LOGON_NAME"] = obj.CodeName;
			row["RANK_NAME"] = obj.Detail.Properties.GetValue("Occupation", string.Empty);
			row["E_MAIL"] = obj.Detail.Properties.GetValue("Mail", string.Empty);
			row["GLOBAL_SORT"] = obj.GlobalSort;
			row["ORIGINAL_SORT"] = obj.GlobalSort;
			row["ALL_PATH_NAME"] = obj.FullPath;

			row["PARENT_GUID"] = obj.ParentID;
			row["GUID"] = obj.ID;
			row["INNER_SORT"] = obj.InnerSort;
			row["SIDELINE"] = obj.Default ? 0 : 1;

			string userRank = obj.Detail.Properties.GetValue("UserRank", UserRankType.Unspecified.ToString());

			if (userRank.IsNullOrEmpty())
				userRank = UserRankType.Unspecified.ToString();

			row["RANK_CODE"] = Enum.Parse(typeof(UserRankType), userRank);
			row["CODE_NAME"] = obj.CodeName;
			row["VERSION_START_TIME"] = obj.Detail.VersionStartTime;

			//string photoKey = obj.Detail.Properties.GetValue("PhotoKey", string.Empty);
			//string photoStamp = string.Empty;

			//if (string.IsNullOrEmpty(photoKey) == false)
			//{
			//    ImageProperty ip = (ImageProperty)MCS.Web.Library.Script.JSONSerializerExecute.Deserialize<ImageProperty>(photoKey);
			//    photoStamp = ip.UpdateTime.ToBinary().ToString("X") + "|" + ip.ID;
			//}

			//row["PhotoTimestamp"] = photoStamp;
		}
        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);
        }
Beispiel #19
0
 public override void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
 {
     base.Fill(target, src, relation);
 }
		/// <summary>
		/// 将对象的属性填充到DataTable中
		/// </summary>
		/// <param name="obj"></param>
		/// <param name="table"></param>
		protected abstract void FillPropertiesToTable(SCObjectAndRelation obj, DataRow row);
Beispiel #21
0
 /// <summary>
 /// 将对象的属性填充到DataTable中
 /// </summary>
 /// <param name="obj"></param>
 /// <param name="table"></param>
 protected abstract void FillPropertiesToTable(SCObjectAndRelation obj, DataRow row);
		private void AddObjectToDictionary(Dictionary<string, SCObjectAndRelation> dictionary, string key, SCObjectAndRelation relation)
		{
			if (dictionary.ContainsKey(key) == false)
				dictionary.Add(key, relation);
		}
        public override void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
        {
            base.Fill(target, src, relation);

            if (src.SchemaType != "Groups")
                throw new ArgumentException(string.Format("SchemaType不匹配", src), "src");
            var wrapper = target as OGUPermission.IOguPropertyAccessible;

            if (wrapper == null)
                throw new InvalidCastException("工厂创建的对象未实现IOguPropertyAccessible");

            wrapper.ObjectType = SchemaType.Groups;
        }
		public bool TryGetValue(BuiltInFunctionIDType idType, string objectID, out SCObjectAndRelation result)
		{
			Dictionary<string, SCObjectAndRelation> dictionary = IDTypeToDictionary(idType);

			return dictionary.TryGetValue(objectID, out result);
		}
        public override void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
        {
            base.Fill(target, src, relation);

            if (src.SchemaType != "Organizations")
                throw new ArgumentException(string.Format("SchemaType {0}不匹配", src), "src");
            var wrapper = target as OGUPermission.IOrganizationPropertyAccessible;
            if (wrapper == null)
                throw new InvalidCastException("工厂创建的对象未实现IOrganizationPropertyAccessible");

            wrapper.CustomsCode = src.Properties.GetValue<string>("CustomsCode", string.Empty); // 关区号
            wrapper.DepartmentClass = src.Properties.GetValue<DepartmentClassType>("DepartmentClass", DepartmentClassType.Unspecified);
            wrapper.DepartmentType = src.Properties.GetValue<DepartmentTypeDefine>("DepartmentType", DepartmentTypeDefine.Unspecified);
            //wrapper.Levels = src.Properties.GetValue<int>("Levels", 0);
            wrapper.ObjectType = SchemaType.Organizations;
            wrapper.Rank = src.Properties.GetValue<DepartmentRankType>("DepartmentRank", DepartmentRankType.None);
        }
 public override void Fill(IOguObject target, SchemaObjectBase src, SCObjectAndRelation relation)
 {
     base.Fill(target, src, relation);
 }
        public bool TryGetValue(BuiltInFunctionIDType idType, string objectID, out SCObjectAndRelation result)
        {
            Dictionary <string, SCObjectAndRelation> dictionary = IDTypeToDictionary(idType);

            return(dictionary.TryGetValue(objectID, out result));
        }
 private void AddObjectToDictionary(Dictionary <string, SCObjectAndRelation> dictionary, string key, SCObjectAndRelation relation)
 {
     if (dictionary.ContainsKey(key) == false)
     {
         dictionary.Add(key, relation);
     }
 }