Beispiel #1
0
        /// <summary>
        /// 修改Acl成员项的状态
        /// </summary>
        /// <param name="members"></param>
        /// <param name="status"></param>
        public void UpdateStatus(SCAclContainerOrMemberCollectionBase members, SchemaObjectStatus status)
        {
            members.NullCheck("members");

            ORMappingItemCollection mappings = this.GetMappingInfo();

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                foreach (SCAclItem aclItem in members)
                {
                    aclItem.Status = status;

                    string sql = VersionCommonObjectUpdateStatusSqlBuilder <SCAclItem> .Instance.ToUpdateSql(aclItem, mappings);

                    DateTime dt = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName());

                    //SCSnapshotBasicAdapter.Instance.UpdateCurrentSnapshot(mappings.TableName,
                    //    mappings.TableName + "_Current",
                    //    ORMapping.GetWhereSqlClauseBuilderByPrimaryKey(aclItem, mappings));

                    SCActionContext.Current.TimePoint.IsMinValue(() => SCActionContext.Current.TimePoint = dt);
                }

                scope.Complete();
            }
        }
Beispiel #2
0
        public SCAclMemberCollection LoadByContainerID(string containerID, SchemaObjectStatus status, DateTime timePoint)
        {
            containerID.CheckStringIsNullOrEmpty("containerID");

            WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

            builder.AppendItem("ContainerID", containerID);
            builder.AppendItem("Status", (int)status);

            return(this.LoadMembers(builder, timePoint));
        }
        /// <summary>
        /// 根据Name和status进行查询
        /// </summary>
        /// <param name="schemaType"></param>
        /// <param name="name"></param>
        /// <param name="status"></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SchemaObjectCollection LoadByName(string schemaType, string name, SchemaObjectStatus status, DateTime timePoint)
        {
            string.IsNullOrEmpty(schemaType).TrueThrow("schemaType不得为空");
            string.IsNullOrEmpty(name).TrueThrow("name");

            return(LoadByName(c =>
            {
                WhereSqlClauseBuilder condition = new WhereSqlClauseBuilder();
                condition.AppendItem("O.SchemaType", schemaType);
                condition.AppendItem("O.Status", (int)status);
                c.Add(condition);
            }, timePoint, name));
        }
        /// <summary>
        /// 根据codename和status进行查询
        /// </summary>
        /// <param name="schemaType"></param>
        /// <param name="codeName"></param>
        /// <param name="status"></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SchemaObjectBase LoadByCodeName(string schemaType, string codeName, SchemaObjectStatus status, DateTime timePoint)
        {
            string.IsNullOrEmpty(schemaType).TrueThrow("schemaType不得为空");
            string.IsNullOrEmpty(codeName).TrueThrow("codeName不得为空");

            return(LoadByCodeName(c =>
            {
                WhereSqlClauseBuilder condition = new WhereSqlClauseBuilder();
                condition.AppendItem("O.SchemaType", schemaType);
                condition.AppendItem("O.Status", (int)status);
                c.Add(condition);
            }, timePoint, codeName).FirstOrDefault());
        }
Beispiel #5
0
        public SchemaObjectBase DeleteUser(SCUser user, SCOrganization parent, bool deletedByContainer)
        {
            SchemaObjectStatus targetStatus = deletedByContainer ? SchemaObjectStatus.DeletedByContainer : SchemaObjectStatus.Deleted;
            SCOperationType    op           = SCOperationType.None;

            SCExecutorBase executor = null;

            if (parent == null)
            {
                op = SCOperationType.DeleteUser;

                if (this._NeedCheckPermissions)
                {
                    CheckPermissions(op, SchemaDefine.GetSchema("Organizations"), "DeleteChildren", user.OwnerID);
                }

                user.Status = targetStatus;

                executor = new SCObjectExecutor(op, user)
                {
                    NeedDeleteRelations = true, NeedValidation = false, NeedDeleteMemberRelations = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck
                };
            }
            else
            {
                op = SCOperationType.RemoveUserFromOrganization;

                if (this._NeedCheckPermissions)
                {
                    CheckPermissions(op, parent.Schema, "DeleteChildren", parent.ID);
                }

                executor = new SCOrganizationRelativeExecutor(op, parent, user)
                {
                    OverrideExistedRelation = true, NeedValidation = false, NeedStatusCheck = this.NeedValidationAndStatusCheck, NeedParentStatusCheck = this.NeedValidationAndStatusCheck
                };

                if (((SCOrganizationRelativeExecutor)executor).Relation != null)
                {
                    ((SCOrganizationRelativeExecutor)executor).Relation.Status = targetStatus;
                }
            }

            SchemaObjectBase result = null;

            ExecuteWithActions(op, () => SCActionContext.Current.DoActions(() => result = (SchemaObjectBase)executor.Execute()));

            return(result);
        }
		private string GetStateDescription(SchemaObjectStatus status)
		{
			switch (status)
			{
				case SchemaObjectStatus.Deleted:
					return "已删除";
				case SchemaObjectStatus.DeletedByContainer:
					return "被容器删除";
				case SchemaObjectStatus.Normal:
					return "正常";
				case SchemaObjectStatus.Unspecified:
					return "未指定";
				default:
					return "(未知)";
			}
		}
        private string GetStateDescription(SchemaObjectStatus status)
        {
            switch (status)
            {
            case SchemaObjectStatus.Deleted:
                return("已删除");

            case SchemaObjectStatus.DeletedByContainer:
                return("被容器删除");

            case SchemaObjectStatus.Normal:
                return("正常");

            case SchemaObjectStatus.Unspecified:
                return("未指定");

            default:
                return("(未知)");
            }
        }
Beispiel #8
0
        /// <summary>
        /// 更新模式对象的状态到数据库
        /// </summary>
        /// <param name="obj">对其进行更新的<typeparamref name="T"/>对象。</param>
        /// <param name="status">表示状态的<see cref="SchemaObjectStatus"/>值之一。</param>
        public void UpdateStatus(T obj, SchemaObjectStatus status)
        {
            obj.Status = status;

            string sql = VersionSchemaObjectUpdateStatusSqlBuilder.Instance.ToUpdateSql(obj, this.GetMappingInfo());

            SchemaObjectUpdateActionCollection actions = GetActions("UpdateStatus");

            actions.Prepare(obj);

            using (TransactionScope scope = TransactionScopeFactory.Create())
            {
                DateTime dt = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName());

                SCActionContext.Current.TimePoint.IsMinValue(() => SCActionContext.Current.TimePoint = dt);

                actions.Persist(obj);

                scope.Complete();
            }
        }
		/// <summary>
		/// 修改Acl成员项的状态
		/// </summary>
		/// <param name="members"></param>
		/// <param name="status"></param>
		public void UpdateStatus(SCAclContainerOrMemberCollectionBase members, SchemaObjectStatus status)
		{
			members.NullCheck("members");

			ORMappingItemCollection mappings = this.GetMappingInfo();

			using (TransactionScope scope = TransactionScopeFactory.Create())
			{
				foreach (SCAclItem aclItem in members)
				{
					aclItem.Status = status;

					string sql = VersionCommonObjectUpdateStatusSqlBuilder<SCAclItem>.Instance.ToUpdateSql(aclItem, mappings);

					DateTime dt = (DateTime)DbHelper.RunSqlReturnScalar(sql, this.GetConnectionName());

					//SCSnapshotBasicAdapter.Instance.UpdateCurrentSnapshot(mappings.TableName,
					//    mappings.TableName + "_Current",
					//    ORMapping.GetWhereSqlClauseBuilderByPrimaryKey(aclItem, mappings));

					SCActionContext.Current.TimePoint.IsMinValue(() => SCActionContext.Current.TimePoint = dt);
				}

				scope.Complete();
			}
		}
Beispiel #10
0
		public SCAclMemberCollection LoadByContainerID(string containerID, SchemaObjectStatus status, DateTime timePoint)
		{
			containerID.CheckStringIsNullOrEmpty("containerID");

			WhereSqlClauseBuilder builder = new WhereSqlClauseBuilder();

			builder.AppendItem("ContainerID", containerID);
			builder.AppendItem("Status", (int)status);

			return this.LoadMembers(builder, timePoint);
		}
Beispiel #11
0
		internal static WhereSqlClauseBuilder StatusFor(this WhereSqlClauseBuilder instance, string fieldName, SchemaObjectStatus status)
		{
			instance.AppendItem(fieldName, (int)status);
			return instance;
		}
Beispiel #12
0
        /// <summary>
        /// 更新数据的状态,更新之后清除缓存
        /// </summary>
        /// <param name="data"></param>
        /// <param name="status"></param>
        public new void UpdateStatus(DESchemaObjectBase data, SchemaObjectStatus status)
        {
            base.UpdateStatus(data, status);

            UpdateDESchemaObjectByIDCache(data.ID);
        }
Beispiel #13
0
        /// <summary>
        /// 加载指定的成员
        /// </summary>
        /// <param name="containerSchemaType"></param>
        /// <param name="containerID"></param>
        /// <param name="status"></param>
        /// <param name="timePoint"></param>
        /// <returns></returns>
        public SchemaObjectCollection LoadMembers(string containerSchemaType, string containerID, SchemaObjectStatus status, DateTime timePoint)
        {
            containerSchemaType.CheckStringIsNullOrEmpty("schemaType");
            containerID.CheckStringIsNullOrEmpty("containerID");

            WhereSqlClauseBuilder condition = new WhereSqlClauseBuilder();

            condition.AppendItem("O.Status", (int)status);
            condition.AppendItem("M.ContainerSchemaType", containerSchemaType).AppendItem("M.Status", (int)status);
            condition.AppendItem("M.ContainerID", containerID);

            var timeCondition  = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "O.");
            var timeCondition2 = VersionStrategyQuerySqlBuilder.Instance.TimePointToBuilder(timePoint, "M.");

            ConnectiveSqlClauseCollection conditions = new ConnectiveSqlClauseCollection(condition, timeCondition, timeCondition2);

            string sql = string.Format("SELECT O.* FROM SC.SchemaObject O INNER JOIN SC.SchemaMembers M ON O.ID = M.MemberID WHERE {0}",
                                       conditions.ToSqlString(TSqlBuilder.Instance));

            DataTable table = DbHelper.RunSqlReturnDS(sql, this.GetConnectionName()).Tables[0];

            SchemaObjectCollection result = new SchemaObjectCollection();

            result.LoadFromDataView(table.DefaultView);

            return(result);
        }