Exemplo n.º 1
0
        public SchemaObjectBase DeleteGroup(SCGroup group, SCOrganization parent, bool deletedByContainer)
        {
            group.Status = deletedByContainer ? SchemaObjectStatus.DeletedByContainer : SchemaObjectStatus.Deleted;

            SCExecutorBase executor = new SCObjectExecutor(SCOperationType.DeleteGroup, group)
            {
                NeedDeleteRelations = true, NeedValidation = false, NeedDeleteMemberRelations = true, NeedDeleteConditions = true, NeedStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (parent == null)
            {
                parent = (SCOrganization)SchemaRelationObjectAdapter.Instance.LoadByObjectID(new string[] { group.ID }).Find(m => m.Status == SchemaObjectStatus.Normal).Parent;
            }

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

            SchemaObjectBase result = null;

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

            return(result);
        }
Exemplo n.º 2
0
        public SchemaObjectBase AddUser(SCUser user, SCOrganization parent)
        {
            SCObjectExecutor executor = null;

            if (parent == null)
            {
                if (this._NeedCheckPermissions)
                {
                    CheckSupervisorPermissions(SCOperationType.AddUser);
                }

                executor = new SCObjectExecutor(SCOperationType.AddUser, user)
                {
                    NeedValidation = this.NeedValidationAndStatusCheck
                };
            }
            else
            {
                if (this._NeedCheckPermissions)
                {
                    CheckPermissions(SCOperationType.AddUser, parent.Schema, "AddChildren", parent.ID);
                }

                executor = new SCOrganizationRelativeExecutor(SCOperationType.AddUser, parent, user)
                {
                    SaveTargetData = true, NeedValidation = this.NeedValidationAndStatusCheck, NeedParentStatusCheck = this.NeedValidationAndStatusCheck
                };
            }

            SchemaObjectBase result = null;

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

            return(result);
        }
Exemplo n.º 3
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);
        }
Exemplo n.º 4
0
        public SchemaObjectBase UpdatePermission(SCPermission permission)
        {
            SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdatePermission, permission)
            {
                NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                CheckApplicationMemberPermissions(SCOperationType.UpdatePermission, "UpdatePermissions", permission);
            }

            SchemaObjectBase result = null;

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

            return(result);
        }
Exemplo n.º 5
0
        public SchemaObjectBase AddApplication(SCApplication application)
        {
            if (this._NeedCheckPermissions)
            {
                CheckSupervisorPermissions(SCOperationType.AddApplication);
            }

            SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.AddApplication, application)
            {
                NeedValidation = this.NeedValidationAndStatusCheck
            };

            SchemaObjectBase result = null;

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

            return(result);
        }
Exemplo n.º 6
0
        public SchemaObjectBase UpdateGroup(SCGroup group)
        {
            SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdateGroup, group)
            {
                NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                CheckOrganizationChildrenPermissions(SCOperationType.UpdateGroup, "UpdateChildren", group);
            }

            SchemaObjectBase result = null;

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

            return(result);
        }
Exemplo n.º 7
0
        public SchemaObjectBase UpdateUser(SCUser user)
        {
            SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdateUser, user)
            {
                NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                var defOrgRelation = (user.CurrentParentRelations.Find(m => m.Default)) ?? new SCRelationObject(SCOrganization.GetRoot(), user);
                CheckPermissions(SCOperationType.UpdateUser, user.Schema, "UpdateChildren", defOrgRelation.ParentID);
            }

            SchemaObjectBase result = null;

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

            return(result);
        }
Exemplo n.º 8
0
        public SchemaObjectBase DeletePermission(SCPermission permission)
        {
            SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.DeletePermission, permission)
            {
                NeedValidation = false, NeedDeleteMemberRelations = true, NeedDeleteRelations = true, NeedStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                CheckApplicationMemberPermissions(SCOperationType.DeletePermission, "DeletePermissions", permission);
            }

            permission.Status = SchemaObjectStatus.Deleted;

            SchemaObjectBase result = null;

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

            return(result);
        }
Exemplo n.º 9
0
        public SCOrganization UpdateOrganization(SCOrganization org)
        {
            SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdateOrganization, org)
            {
                NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck
            };
            SchemaObjectBase parent = org.CurrentParents.FirstOrDefault();

            if (parent != null)
            {
                CheckPermissions(SCOperationType.UpdateOrganization, parent.Schema, "UpdateChildren", parent.ID);
            }
            else
            {
                CheckSupervisorPermissions(SCOperationType.UpdateOrganization);
            }

            SCOrganization result = null;

            ExecuteWithActions(SCOperationType.UpdateOrganization, () => SCActionContext.Current.DoActions(() => result = (SCOrganization)executor.Execute()));

            return(result);
        }
Exemplo n.º 10
0
		public SchemaObjectBase AddApplication(SCApplication application)
		{
			if (this._NeedCheckPermissions)
				CheckSupervisorPermissions(SCOperationType.AddApplication);

			SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.AddApplication, application) { NeedValidation = this.NeedValidationAndStatusCheck };

			SchemaObjectBase result = null;

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

			return result;
		}
Exemplo n.º 11
0
		public SchemaObjectBase DeleteGroup(SCGroup group, SCOrganization parent, bool deletedByContainer)
		{
			group.Status = deletedByContainer ? SchemaObjectStatus.DeletedByContainer : SchemaObjectStatus.Deleted;

			SCExecutorBase executor = new SCObjectExecutor(SCOperationType.DeleteGroup, group) { NeedDeleteRelations = true, NeedValidation = false, NeedDeleteMemberRelations = true, NeedDeleteConditions = true, NeedStatusCheck = this.NeedValidationAndStatusCheck };

			if (parent == null)
				parent = (SCOrganization)SchemaRelationObjectAdapter.Instance.LoadByObjectID(new string[] { group.ID }).Find(m => m.Status == SchemaObjectStatus.Normal).Parent;

			if (this._NeedCheckPermissions)
				CheckPermissions(SCOperationType.DeleteGroup, parent.Schema, "DeleteChildren", parent.ID);

			SchemaObjectBase result = null;

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

			return result;
		}
Exemplo n.º 12
0
		public SchemaObjectBase UpdateGroup(SCGroup group)
		{
			SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdateGroup, group) { NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
				CheckOrganizationChildrenPermissions(SCOperationType.UpdateGroup, "UpdateChildren", group);

			SchemaObjectBase result = null;

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

			return result;
		}
Exemplo n.º 13
0
		public SCOrganization UpdateOrganization(SCOrganization org)
		{
			SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdateOrganization, org) { NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck };
			SchemaObjectBase parent = org.CurrentParents.FirstOrDefault();

			if (parent != null)
				CheckPermissions(SCOperationType.UpdateOrganization, parent.Schema, "UpdateChildren", parent.ID);
			else
				CheckSupervisorPermissions(SCOperationType.UpdateOrganization);

			SCOrganization result = null;

			ExecuteWithActions(SCOperationType.UpdateOrganization, () => SCActionContext.Current.DoActions(() => result = (SCOrganization)executor.Execute()));

			return result;
		}
Exemplo n.º 14
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;
		}
Exemplo n.º 15
0
		public SchemaObjectBase UpdateUser(SCUser user)
		{
			SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdateUser, user) { NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
			{
				var defOrgRelation = (user.CurrentParentRelations.Find(m => m.Default)) ?? new SCRelationObject(SCOrganization.GetRoot(), user);
				CheckPermissions(SCOperationType.UpdateUser, user.Schema, "UpdateChildren", defOrgRelation.ParentID);
			}

			SchemaObjectBase result = null;

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

			return result;
		}
Exemplo n.º 16
0
		public SchemaObjectBase UpdatePermission(SCPermission permission)
		{
			SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.UpdatePermission, permission) { NeedValidation = this.NeedValidationAndStatusCheck, NeedStatusCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
				CheckApplicationMemberPermissions(SCOperationType.UpdatePermission, "UpdatePermissions", permission);

			SchemaObjectBase result = null;

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

			return result;
		}
Exemplo n.º 17
0
		public SchemaObjectBase DeletePermission(SCPermission permission)
		{
			SCObjectExecutor executor = new SCObjectExecutor(SCOperationType.DeletePermission, permission) { NeedValidation = false, NeedDeleteMemberRelations = true, NeedDeleteRelations = true, NeedStatusCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
				CheckApplicationMemberPermissions(SCOperationType.DeletePermission, "DeletePermissions", permission);

			permission.Status = SchemaObjectStatus.Deleted;

			SchemaObjectBase result = null;

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

			return result;
		}
Exemplo n.º 18
0
		public SchemaObjectBase AddUser(SCUser user, SCOrganization parent)
		{
			SCObjectExecutor executor = null;

			if (parent == null)
			{
				if (this._NeedCheckPermissions)
					CheckSupervisorPermissions(SCOperationType.AddUser);

				executor = new SCObjectExecutor(SCOperationType.AddUser, user) { NeedValidation = this.NeedValidationAndStatusCheck };
			}
			else
			{
				if (this._NeedCheckPermissions)
					CheckPermissions(SCOperationType.AddUser, parent.Schema, "AddChildren", parent.ID);

				executor = new SCOrganizationRelativeExecutor(SCOperationType.AddUser, parent, user) { SaveTargetData = true, NeedValidation = this.NeedValidationAndStatusCheck, NeedParentStatusCheck = this.NeedValidationAndStatusCheck };
			}

			SchemaObjectBase result = null;

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

			return result;
		}