public SchemaPropertyExtension Load(string targetSchemaType, string sourceID)
        {
            string sql = "SELECT TOP 1 * FROM SC.SchemaPropertyExtensions WHERE ";
            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendCondition("TargetSchemaType", targetSchemaType);
            builder.AppendCondition("SourceID", sourceID);
            sql += builder.ToSqlString(TSqlBuilder.Instance);

            SchemaPropertyExtension obj = null;

            using (DbContext context = DbContext.GetContext(GetConnectionName()))
            {
                Database db = DatabaseFactory.Create(context);

                using (var dr = db.ExecuteReader(System.Data.CommandType.Text, sql))
                {
                    if (dr.Read())
                    {
                        obj = new SchemaPropertyExtension(dr["TargetSchemaType"].ToString(), dr["SourceID"].ToString(), dr["Description"].ToString());
                        obj.InternalDefinitionXml = dr["Definition"].ToString();
                    }
                }
            }

            return(obj);
        }
Beispiel #2
0
        protected override void OnBuildQueryCondition(QueryCondition qc)
        {
            base.OnBuildQueryCondition(qc);
            qc.SelectFields = "S.*";
            qc.FromClause   = this.FromSqlClause;
            if (string.IsNullOrEmpty(qc.OrderByClause))
            {
                qc.OrderByClause = "S.Name ASC";
            }

            var timeCondition  = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("S.");
            var timeConditionM = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("M.");

            WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
            var allConditions = new ConnectiveSqlClauseCollection(timeCondition, timeConditionM, where);

            where.AppendCondition("M.ContainerID", this.schemaID);

            if (normalOnly)
            {
                where.AppendCondition("S.Status", (int)SchemaObjectStatus.Normal);
                where.AppendCondition("M.Status", (int)SchemaObjectStatus.Normal);
            }

            if (string.IsNullOrEmpty(qc.WhereClause) == false)
            {
                qc.WhereClause += " AND ";
            }
            qc.WhereClause += allConditions.ToSqlString(TSqlBuilder.Instance);
        }
		public AUSchemaRole LoadAUSchemaRoleByCodeName(string schemaID, string codeName, bool normalOnly, DateTime timePoint)
		{
			codeName.NullCheck("codeName");
			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
			where.AppendCondition("R.ContainerID", schemaID);
			if (normalOnly) where.NormalFor("O.Status").NormalFor("R.Status");

			where.AppendCondition("S.CodeName", codeName);

			return LoadAUSchemaRoles(where, normalOnly, timePoint).FirstOrDefault();
		}
		/// <summary>
		/// 根据条件,载入指定对象的所有容器对象
		/// </summary>
		/// <param name="memberID"></param>
		/// <param name="memberSchemaType"></param>
		/// <param name="containerSchemaType"></param>
		/// <param name="normalOnly"></param>
		/// <param name="timePoint"></param>
		/// <returns></returns>
		public SchemaObjectCollection LoadContainers(string memberID, string memberSchemaType, string containerSchemaType, bool normalOnly, DateTime timePoint)
		{
			memberID.NullCheck("memberID");
			containerSchemaType.NullCheck("containerSchemaType");
			memberSchemaType.NullCheck("memberSchemaType");

			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
			where.AppendCondition("M.MemberID", memberID);
			where.AppendCondition("M.MemberSchemaType", memberSchemaType);
			where.AppendCondition("M.ContainerSchemaType", containerSchemaType);

			return LoadContainers(where, normalOnly, timePoint);
		}
Beispiel #5
0
        private void BuildCondition(QueryCondition qc)
        {
            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            if (this.deepOption == 1)
            {
                builder.AppendCondition("C.ContainerID", this.scope.ID);
            }
            else
            {
                if (deepOption == 2)
                {
                    builder.AppendItem("C.ContainerID", this.scope.ID, "<>");
                }
            }
            builder.NormalFor("C.Status").NormalFor("S.Status").NormalFor("SM.Status").NormalFor("AUS.Status");
            var timeBulder1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("C.");
            var timeBulder2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("S.");
            var time3       = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("AUS.");
            var time4       = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("SM.");

            var conditionClause = new ConnectiveSqlClauseCollection(builder, timeBulder1, timeBulder2, time3, time4).ToSqlString(TSqlBuilder.Instance);

            if (string.IsNullOrEmpty(qc.WhereClause) == false)
            {
                qc.WhereClause += " AND (" + conditionClause + ")";
            }
            else
            {
                qc.WhereClause = conditionClause;
            }
        }
		public SchemaObjectCollection LoadAUScope(string auID, string[] scopes, bool normalOnly, DateTime timePoint)
		{
			auID.NullCheck("auID");
			scopes.NullCheck("scopes");

			if (scopes.Length > 0)
			{
				WhereSqlClauseBuilder where = new WhereSqlClauseBuilder().NormalFor("O.Status").NormalFor("S.Status");
				where.AppendCondition("R.ContainerID", auID);
				where.NormalFor("R.Status");

				InSqlClauseBuilder inSql = new InSqlClauseBuilder("S.ScopeSchemaType");
				inSql.AppendItem(scopes);

				if (normalOnly)
				{
					where.NormalFor("O.Status");
				}

				return LoadAUScope(new ConnectiveSqlClauseCollection(where, inSql), timePoint);
			}
			else
			{
				return new SchemaObjectCollection();
			}
		}
        protected override void OnBuildQueryCondition(QueryCondition qc)
        {
            base.OnBuildQueryCondition(qc);
            qc.SelectFields = "*";
            qc.FromClause   = TimePointContext.Current.UseCurrentTime ? "SC.AUAdminScopeItemSnapshot_Current" : "SC.AUAdminScopeItemSnapshot";

            if (string.IsNullOrEmpty(qc.OrderByClause))
            {
                qc.OrderByClause = "AUScopeItemName ASC";
            }

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendCondition("SchemaType", this.scopeType).NormalFor("Status");
            var timeBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder();

            var allCondition = new ConnectiveSqlClauseCollection(builder, timeBuilder).ToSqlString(TSqlBuilder.Instance);

            if (string.IsNullOrEmpty(qc.WhereClause))
            {
                qc.WhereClause = allCondition;
            }
            else
            {
                qc.WhereClause = qc.WhereClause + "AND (" + allCondition + ")";
            }
        }
		protected override void OnBuildQueryCondition(QueryCondition qc)
		{
			base.OnBuildQueryCondition(qc);
			qc.SelectFields = "*";
			qc.FromClause = TimePointContext.Current.UseCurrentTime ? "SC.AUAdminScopeItemSnapshot_Current" : "SC.AUAdminScopeItemSnapshot";

			if (string.IsNullOrEmpty(qc.OrderByClause))
				qc.OrderByClause = "AUScopeItemName ASC";

			WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();
			builder.AppendCondition("SchemaType", this.scopeType).NormalFor("Status");
			var timeBuilder = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder();

			var allCondition = new ConnectiveSqlClauseCollection(builder, timeBuilder).ToSqlString(TSqlBuilder.Instance);

			if (string.IsNullOrEmpty(qc.WhereClause))
			{
				qc.WhereClause = allCondition;
			}
			else
			{
				qc.WhereClause = qc.WhereClause + "AND (" + allCondition + ")";
			}

		}
		/// <summary>
		/// 载入指定AUSchemaID中的角色
		/// </summary>
		/// <param name="schemaID">AUSchema的ID</param>
		/// <param name="normalOnly">如果为true,则仅提取正常的,否则包含已删除的</param>
		/// <param name="timePoint">时间点</param>
		/// <returns></returns>
		public AUSchemaRoleCollection LoadAUSchemaRoles(string schemaID, bool normalOnly, DateTime timePoint)
		{
			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
			where.AppendCondition("R.ContainerID", schemaID);
			if (normalOnly) where.NormalFor("O.Status").NormalFor("R.Status");
			return LoadAUSchemaRoles(where, normalOnly, timePoint);
		}
		public SchemaObjectCollection LoadAUScope(string auID, string scope, bool normalRelation, bool normalObject, DateTime timePoint)
		{
			auID.NullCheck("auID");

			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder().NormalFor("O.Status").NormalFor("S.Status");
			where.AppendCondition("R.ContainerID", auID);
			where.AppendCondition("S.ScopeSchemaType", scope);
			if (normalRelation)
				where.NormalFor("R.Status");

			if (normalObject)
			{
				where.NormalFor("O.Status");
			}

			return LoadAUScope(where, timePoint);
		}
		protected override void OnBuildQueryCondition(QueryCondition qc)
		{
			base.OnBuildQueryCondition(qc);
			qc.SelectFields = "S.*";
			qc.FromClause = this.FromSqlClause;
			if (string.IsNullOrEmpty(qc.OrderByClause))
				qc.OrderByClause = "S.Name ASC";

			var timeCondition = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("S.");
			var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("R.");
			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder().NormalFor("S.Status").NormalFor("R.Status");
			var allConditions = new ConnectiveSqlClauseCollection(timeCondition, timeCondition2, where);
			where.AppendCondition("S.AUSchemaID", this.schemaID);
			where.AppendCondition("R.ParentID", this.parentID);
			if (string.IsNullOrEmpty(qc.WhereClause) == false)
				qc.WhereClause += " AND ";

			qc.WhereClause += allConditions.ToSqlString(TSqlBuilder.Instance);
		}
		public AURole LoadAURole(string schemaRoleID, string unitID, bool normalOnly, DateTime timePoint)
		{
			string sql = @"SELECT O.* FROM SC.SchemaObject O INNER JOIN SC.AURoleSnapshot S
ON O.ID = S.ID AND O.VersionStartTime = S.VersionStartTime AND O.SchemaType = S.SchemaType
INNER JOIN SC.SchemaMembers R ON O.ID = R.MemberID AND O.SchemaType = R.MemberSchemaType
 WHERE";
			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
			where.AppendCondition("S.SchemaRoleID", schemaRoleID);
			where.AppendCondition("R.ContainerID", unitID);
			where.NormalFor("R.Status");

			if (normalOnly) where.NormalFor("O.Status");

			var timeCondition1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "S.");
			var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "O.");

			sql += new ConnectiveSqlClauseCollection(timeCondition1, timeCondition2, where).ToSqlString(TSqlBuilder.Instance);

			return (AURole)LoadSchemaObjects(sql).FirstOrDefault();
		}
		/// <summary>
		/// 根据角色ID载入指定AUSchemaID中的角色
		/// </summary>
		/// <param name="schemaID">AUSchema的ID</param>
		/// <param name="normalOnly">如果为true,则仅提取正常的,否则包含已删除的</param>
		/// <param name="schemaRoleIDs">仅包含角色的ID</param>
		/// <param name="timePoint">时间点</param>
		/// <returns></returns>
		public AUSchemaRoleCollection LoadAUSchemaRoles(string schemaID, string[] schemaRoleIDs, bool normalOnly, DateTime timePoint)
		{
			schemaRoleIDs.NullCheck("schemaRoleIDs");

			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
			where.AppendCondition("R.ContainerID", schemaID);
			if (normalOnly) where.NormalFor("O.Status").NormalFor("R.Status");

			InSqlClauseBuilder inSql = new InSqlClauseBuilder("R.MemberID").AppendItem(schemaRoleIDs);
			return LoadAUSchemaRoles(new ConnectiveSqlClauseCollection(where, inSql), normalOnly, timePoint);
		}
		/// <summary>
		/// 载入所有下级管理单元
		/// </summary>
		/// <param name="schemaID">管理单元的AUSchemaID</param>
		/// <param name="parentID">上级管理单元,如果为null则取schemaID</param>
		/// <param name="normalOnly">是否仅含正常数据</param>
		/// <param name="timePoint">时间点</param>
		/// <returns></returns>
		public SchemaObjectCollection LoadSubUnits(string schemaID, string parentID, bool normalOnly, DateTime timePoint)
		{
			WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
			if (parentID == null)
				parentID = schemaID;
			where.AppendItem("R.ParentID", parentID);
			where.AppendCondition("S.AUSchemaID", schemaID);
			where.AppendItem("R.ChildSchemaType", AUCommon.SchemaAdminUnit);

			if (normalOnly)
				where.NormalFor("R.Status").NormalFor("O.Status");

			return LoadSubUnits(timePoint, where);
		}
		/// <summary>
		/// 根据Schema和代码名称,载入管理架构角色
		/// </summary>
		/// <param name="schemaID"></param>
		/// <param name="codeNames"></param>
		/// <param name="normalOnly"></param>
		/// <param name="timePoint"></param>
		/// <returns></returns>
		public AUSchemaRoleCollection LoadAUSchemaRolesByCodeNames(string schemaID, string[] codeNames, bool normalOnly, DateTime timePoint)
		{
			codeNames.NullCheck("codeNames");
			if (codeNames.Length > 0)
			{
				WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
				where.AppendCondition("R.ContainerID", schemaID);
				if (normalOnly) where.NormalFor("O.Status").NormalFor("R.Status");

				InSqlClauseBuilder inSql = new InSqlClauseBuilder("S.CodeName");
				inSql.AppendItem(codeNames);

				return LoadAUSchemaRoles(new ConnectiveSqlClauseCollection(where, inSql), normalOnly, timePoint);
			}
			else
			{
				return new AUSchemaRoleCollection();
			}
		}
		/// <summary>
		/// 载入所有下级管理单元
		/// </summary>
		/// <param name="schemaID">管理单元的AUSchemaID</param>
		/// <param name="parentID">上级管理单元的ID</param>
		/// <param name="normalOnly">是否仅含正常数据</param>
		/// <param name="timePoint">时间点</param>
		/// <returns></returns>
		public SchemaObjectCollection LoadSubUnits(string schemaID, string[] parentIDs, bool normalOnly, DateTime timePoint)
		{
			parentIDs.NullCheck("parentIDs");

			if (parentIDs.Length > 0)
			{
				WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
				where.AppendCondition("S.AUSchemaID", schemaID);
				where.AppendItem("R.ChildSchemaType", AUCommon.SchemaAdminUnit);

				if (normalOnly)
					where.NormalFor("R.Status").NormalFor("O.Status");

				InSqlClauseBuilder inBuilder = new InSqlClauseBuilder("R.ParentID");

				return LoadSubUnits(timePoint, new ConnectiveSqlClauseCollection(where, inBuilder));
			}
			else
				return new SchemaObjectCollection();
		}
Beispiel #17
0
        public List <AURoleDisplayItem> LoadAURoleDisplayItems(string unitID, bool normalOnly, DateTime timePoint)
        {
            string sql = @"SELECT SR.Name, SR.CodeName, SR.DisplayName, S.ID, S.SchemaRoleID, S.Status FROM SC.AURoleSnapshot S
INNER JOIN SC.SchemaMembers R ON S.ID = R.MemberID AND S.SchemaType = R.MemberSchemaType
INNER JOIN SC.AUSchemaRoleSnapshot SR ON SR.ID = S.SchemaRoleID
 WHERE";

            WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
            where.AppendCondition("R.ContainerID", unitID).AppendCondition("R.ContainerSchemaType", AUCommon.SchemaAdminUnit);
            if (normalOnly)
            {
                where.NormalFor("R.Status").NormalFor("S.Status").NormalFor("SR.Status");
            }

            var timeCondition1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "S.");
            var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "SR.");
            var timeCondition3 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "R.");

            sql += new ConnectiveSqlClauseCollection(timeCondition1, timeCondition2, timeCondition3, where).ToSqlString(TSqlBuilder.Instance);

            List <AURoleDisplayItem> result = new List <AURoleDisplayItem>();

            AUCommon.DoDbAction(() =>
            {
                using (DbContext context = DbContext.GetContext(this.GetConnectionName()))
                {
                    using (IDataReader dr = DbHelper.RunSqlReturnDR(sql, this.GetConnectionName()))
                    {
                        while (dr.Read())
                        {
                            AURoleDisplayItem item = new AURoleDisplayItem();
                            ORMapping.DataReaderToObject <AURoleDisplayItem>(dr, item);
                            result.Add(item);
                        }
                    }
                }
            });

            return(result);
        }
Beispiel #18
0
        protected override void OnBuildQueryCondition(QueryCondition qc)
        {
            base.OnBuildQueryCondition(qc);
            qc.SelectFields = "S.*";
            qc.FromClause   = this.FromSqlClause;
            if (string.IsNullOrEmpty(qc.OrderByClause))
            {
                qc.OrderByClause = "S.Name ASC";
            }

            var timeCondition = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("S.");

            WhereSqlClauseBuilder where = new WhereSqlClauseBuilder();
            var allConditions = new ConnectiveSqlClauseCollection(timeCondition, where);

            where.AppendCondition("S.CategoryID", this.categoryID);
            if (string.IsNullOrEmpty(qc.WhereClause) == false)
            {
                qc.WhereClause += " AND ";
            }
            qc.WhereClause += allConditions.ToSqlString(TSqlBuilder.Instance);
        }
Beispiel #19
0
 protected virtual void BuildWhere(WhereSqlClauseBuilder where)
 {
     where.AppendCondition("S.Status", (int)SchemaObjectStatus.Normal);
     where.AppendCondition("M.Status", (int)SchemaObjectStatus.Normal);
 }
		protected virtual void BuildWhere(WhereSqlClauseBuilder where)
		{
			where.AppendCondition("S.Status", (int)SchemaObjectStatus.Normal);
			where.AppendCondition("M.Status", (int)SchemaObjectStatus.Normal);
		}
		private void BuildCondition(QueryCondition qc)
		{
			WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();
			if (this.deepOption == 1)
			{
				builder.AppendCondition("C.ContainerID", this.scope.ID);
			}
			else
			{
				if (deepOption == 2)
				{
					builder.AppendItem("C.ContainerID", this.scope.ID, "<>");
				}
			}
			builder.NormalFor("C.Status").NormalFor("S.Status").NormalFor("SM.Status").NormalFor("AUS.Status");
			var timeBulder1 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("C.");
			var timeBulder2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("S.");
			var time3 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("AUS.");
			var time4 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder("SM.");

			var conditionClause = new ConnectiveSqlClauseCollection(builder, timeBulder1, timeBulder2, time3, time4).ToSqlString(TSqlBuilder.Instance);

			if (string.IsNullOrEmpty(qc.WhereClause) == false)
				qc.WhereClause += " AND (" + conditionClause + ")";
			else
				qc.WhereClause = conditionClause;
		}