/// <summary>
        /// 根据父级ID和对象ID和时间点载入对象
        /// </summary>
        /// <param name="parentID">父级ID</param>
        /// <param name="objectID">对象ID</param>
        /// <param name="timePoint">表示时间点的<see cref="DateTime"/>或 DateTime.MinValue 表示当前时间</param>
        /// <returns></returns>
        public SCRelationObject Load(string parentID, string objectID, DateTime timePoint)
        {
            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendItem("ParentID", parentID);
            builder.AppendItem("ObjectID", objectID);

            SCRelationObjectCollection relations = Load(builder, timePoint);

            return(relations.FirstOrDefault());
        }
        private void DoFullPathValidate(SCRelationObject relation, string fullPath, string key, ValidationResults validateResults)
        {
            SCRelationObjectCollection relations = SchemaRelationObjectAdapter.Instance.LoadByFullPath(fullPath, this.includingDeleted, DateTime.MinValue);

            SCRelationObject existedRelation = relations.Find(r => r.ParentID == relation.ParentID && r.ID != relation.ID);

            if (existedRelation != null)
            {
                RecordValidationResult(validateResults, string.Format(this.MessageTemplate, existedRelation.FullPath), relation, key);
            }
        }
Example #3
0
        protected void dataSourceMain_Selected(object sender, ObjectDataSourceStatusEventArgs e)
        {
            if (e.ReturnValue is DataView && Util.SuperVisiorMode == false)
            {
                var view = e.ReturnValue as DataView;

                string[] ids = new string[view.Count];
                for (int i = 0; i < view.Count; i++)
                {
                    ids[i] = view[i]["ID"].ToString();
                }

                this.relations = ids.Length > 0 ? DbUtil.LoadCurrentParentRelations(ids, SchemaInfo.FilterByCategory("Organizations").ToSchemaNames()) : new SCRelationObjectCollection();

                this.acls = this.relations.Count > 0 ? SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, this.relations.ToParentIDArray()) : new SCContainerAndPermissionCollection();
            }
        }
        /// <summary>
        /// 根据条件和时间点载入对象
        /// </summary>
        /// <param name="builder">包含条件的<see cref="IConnectiveSqlClause"/></param>
        /// <param name="timePoint">表示时间点的<see cref="DateTime"/>或 DateTime.MinValue 表示当前时间</param>
        /// <returns></returns>
        public SCRelationObjectCollection Load(IConnectiveSqlClause builder, DateTime timePoint)
        {
            IConnectiveSqlClause timeBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);

            ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(builder, timeBuilder);

            SCRelationObjectCollection result = null;

            VersionedObjectAdapterHelper.Instance.FillData(GetMappingInfo().TableName, connectiveBuilder, this.GetConnectionName(),
                                                           view =>
            {
                result = new SCRelationObjectCollection();

                result.LoadFromDataView(view);
            });

            return(result);
        }
Example #5
0
        /// <summary>
        /// 获取指定关系中的父级对象
        /// </summary>
        /// <param name="acls">关系</param>
        /// <returns></returns>
        private SchemaObjectCollection GetParentObjects(SCRelationObjectCollection relations)
        {
            var parentIds = (from p in relations where p.Status == SchemaObjectStatus.Normal select p.ParentID).ToArray();

            if (parentIds.Length > 0)
            {
                InSqlClauseBuilder inSql = new InSqlClauseBuilder("ID");
                inSql.AppendItem(parentIds);

                WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
                where.AppendItem("Status", (int)SchemaObjectStatus.Normal);

                return(PC.Adapters.SchemaObjectAdapter.Instance.Load(new ConnectiveSqlClauseCollection(inSql, where, VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder())));
            }
            else
            {
                return(new SchemaObjectCollection());
            }
        }
        protected override void ValidateObjects()
        {
            WhereSqlClauseBuilder bd = new WhereSqlClauseBuilder();

            bd.AppendItem("Status", (int)SchemaObjectStatus.Normal);

            InSqlClauseBuilder inB = new InSqlClauseBuilder("ObjectID");

            inB.AppendItem(this.SourceKeys);

            InSqlClauseBuilder inC = new InSqlClauseBuilder("ParentSchemaType");

            inC.AppendItem(SchemaInfo.FilterByCategory("Organizations").ToSchemaNames());

            InSqlClauseBuilder inD = new InSqlClauseBuilder("Groups");

            inC.AppendItem(SchemaInfo.FilterByCategory("Groups").ToSchemaNames());

            this.relations = SchemaRelationObjectAdapter.Instance.Load(new ConnectiveSqlClauseCollection(bd, inB, inC, inD, VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder()), DateTime.MinValue);
            this.parents   = DbUtil.LoadObjects(this.relations.ToParentIDArray());

            base.ValidateObjects();
        }
		/// <summary>
		/// 获取指定关系中的父级对象
		/// </summary>
		/// <param name="acls">关系</param>
		/// <returns></returns>
		private SchemaObjectCollection GetParentObjects(SCRelationObjectCollection relations)
		{
			var parentIds = (from p in relations where p.Status == SchemaObjectStatus.Normal select p.ParentID).ToArray();
			if (parentIds.Length > 0)
			{
				InSqlClauseBuilder inSql = new InSqlClauseBuilder("ID");
				inSql.AppendItem(parentIds);

				WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
				where.AppendItem("Status", (int)SchemaObjectStatus.Normal);

				return PC.Adapters.SchemaObjectAdapter.Instance.Load(new ConnectiveSqlClauseCollection(inSql, where, VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder()));
			}
			else
			{
				return new SchemaObjectCollection();
			}
		}
		protected void dataSourceMain_Selected(object sender, ObjectDataSourceStatusEventArgs e)
		{
			if (e.ReturnValue is DataView && Util.SuperVisiorMode == false)
			{
				var view = e.ReturnValue as DataView;

				string[] ids = new string[view.Count];
				for (int i = 0; i < view.Count; i++)
				{
					ids[i] = view[i]["ID"].ToString();
				}

				this.relations = ids.Length > 0 ? DbUtil.LoadCurrentParentRelations(ids, SchemaInfo.FilterByCategory("Organizations").ToSchemaNames()) : new SCRelationObjectCollection();

				this.acls = this.relations.Count > 0 ? SCAclAdapter.Instance.LoadCurrentContainerAndPermissions(Util.CurrentUser.ID, this.relations.ToParentIDArray()) : new SCContainerAndPermissionCollection();
			}
		}
Example #9
0
		public void Load(System.IO.TextReader input)
		{
			int count;

			var xmlDoc = new System.Xml.XmlDocument();
			xmlDoc.Load(input);
			SchemaObjectXmlImporter importer = new SchemaObjectXmlImporter();

			var nodeContext = xmlDoc.SelectSingleNode("/sc/context");
			if (nodeContext != null)
			{
				var attrTime = nodeContext.Attributes["timeContext"];
				if (attrTime != null && attrTime.Specified)
				{
					this.timeContext = System.Xml.XmlConvert.ToDateTime(attrTime.Value, System.Xml.XmlDateTimeSerializationMode.Local);
				}

				var scope = nodeContext.Attributes["scope"];
				if (scope != null && scope.Specified)
				{
					this.Scope = scope.Value;
				}
			}

			var nodeObjects = xmlDoc.SelectNodes("/sc/objects/Object");
			this.objects = null;
			count = nodeObjects.Count;

			if (count > 0)
			{
				this.objects = new SchemaObjectCollection();

				for (int i = 0; i < count; i++)
				{
					var xml = nodeObjects[i].OuterXml;
					var schemaType = nodeObjects[i].Attributes["SchemaType"].Value;
					this.objects.Add(importer.XmlToObject(xml, schemaType));
				}
			}

			nodeObjects = xmlDoc.SelectNodes("/sc/relations/Object");
			this.relations = null;
			count = nodeObjects.Count;

			if (count > 0)
			{
				this.relations = new SCRelationObjectCollection();

				for (int i = 0; i < count; i++)
				{
					var xml = nodeObjects[i].OuterXml;
					var schemaType = nodeObjects[i].Attributes["SchemaType"].Value;
					this.relations.Add((SCRelationObject)importer.XmlToObject(xml, schemaType));
				}
			}

			nodeObjects = xmlDoc.SelectNodes("/sc/membership/Object");
			this.membership = null;
			count = nodeObjects.Count;

			if (count > 0)
			{
				this.membership = new SCMemberRelationCollection();

				for (int i = 0; i < count; i++)
				{
					var xml = nodeObjects[i].OuterXml;
					var schemaType = nodeObjects[i].Attributes["SchemaType"].Value;
					this.membership.Add((SCSimpleRelationBase)importer.XmlToObject(xml, schemaType));
				}
			}

			nodeObjects = xmlDoc.SelectNodes("/sc/conditions/condition");
			this.conditions = null;
			count = nodeObjects.Count;

			if (count > 0)
			{
				this.conditions = new MCS.Library.SOA.DataObjects.Security.Conditions.SCConditionCollection();

				for (int i = 0; i < count; i++)
				{
					var xml = nodeObjects[i];

					var condition = LoadCondition(xml);

					this.conditions.Add(condition);
				}
			}

			nodeObjects = xmlDoc.SelectNodes("/sc/acls/acl");
			this.acls = null;
			count = nodeObjects.Count;

			if (count > 0)
			{
				this.acls = new SCAclContainerCollection();

				for (int i = 0; i < count; i++)
				{
					var xml = nodeObjects[i];

					var acl = LoadAcl(xml);

					this.acls.Add(acl);
				}
			}
		}
		protected override void ValidateObjects()
		{
			WhereSqlClauseBuilder bd = new WhereSqlClauseBuilder();
			bd.AppendItem("Status", (int)SchemaObjectStatus.Normal);

			InSqlClauseBuilder inB = new InSqlClauseBuilder("ObjectID");
			inB.AppendItem(this.SourceKeys);

			InSqlClauseBuilder inC = new InSqlClauseBuilder("ParentSchemaType");
			inC.AppendItem(SchemaInfo.FilterByCategory("Organizations").ToSchemaNames());

			InSqlClauseBuilder inD = new InSqlClauseBuilder("Groups");
			inC.AppendItem(SchemaInfo.FilterByCategory("Groups").ToSchemaNames());

			this.relations = SchemaRelationObjectAdapter.Instance.Load(new ConnectiveSqlClauseCollection(bd, inB, inC, inD, VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder()), DateTime.MinValue);
			this.parents = DbUtil.LoadObjects(this.relations.ToParentIDArray());

			base.ValidateObjects();
		}