Exemplo n.º 1
0
        /// <summary>
        /// 根据容器ID,成员ID和时间点载入对象
        /// </summary>
        /// <param name="containerID">容器ID</param>
        /// <param name="memberID">成员ID</param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SCSimpleRelationBase Load(string containerID, string memberID, DateTime timePoint)
        {
            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendItem("ContainerID", containerID);
            builder.AppendItem("MemberID", memberID);

            SCMemberRelationCollection relations = Load(builder, timePoint);

            return(relations.FirstOrDefault());
        }
Exemplo n.º 2
0
        /// <summary>
        /// 根据条件和时间点载入对象
        /// </summary>
        /// <param name="builder">包含条件的<see cref="IConnectiveSqlClause"/></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SCMemberRelationCollection Load(IConnectiveSqlClause builder, DateTime timePoint)
        {
            var timeBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint);

            ConnectiveSqlClauseCollection connectiveBuilder = new ConnectiveSqlClauseCollection(builder, timeBuilder);

            SCMemberRelationCollection result = null;

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

                result.LoadFromDataView(view);
            });

            return(result);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取指定关系中的成员对象
        /// </summary>
        /// <param name="acls">关系</param>
        /// <returns></returns>
        private SchemaObjectCollection GetMemberObjects(SCMemberRelationCollection relations)
        {
            var memberId = (from p in relations where p.Status == SchemaObjectStatus.Normal select p.ID).ToArray();

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

                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());
            }
        }
		/// <summary>
		/// 获取指定关系中的成员对象
		/// </summary>
		/// <param name="acls">关系</param>
		/// <returns></returns>
		private SchemaObjectCollection GetMemberObjects(SCMemberRelationCollection relations)
		{
			var memberId = (from p in relations where p.Status == SchemaObjectStatus.Normal select p.ID).ToArray();
			if (memberId.Length > 0)
			{
				InSqlClauseBuilder inSql = new InSqlClauseBuilder("ID");
				inSql.AppendItem(memberId);

				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();
			}
		}
Exemplo n.º 5
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);
				}
			}
		}