Exemple #1
0
        /// <summary>
        /// 为某人指定秘书
        /// </summary>
        /// <param name="user"></param>
        /// <param name="secretary"></param>
        /// <returns></returns>
        public SCSecretaryRelation AddSecretaryToUser(SCUser secretary, SCUser user)
        {
            SCSecretaryRelativeExecutor executor = new SCSecretaryRelativeExecutor(SCOperationType.AddSecretaryToUser, user, secretary)
            {
                NeedStatusCheck = true, NeedContainerStatusCheck = this.NeedValidationAndStatusCheck
            };

            if (this._NeedCheckPermissions)
            {
                var hereParents  = secretary.CurrentParentRelations;
                var thereParents = user.CurrentParentRelations;
                var hereIds      = (from p in hereParents where p.Status == SchemaObjectStatus.Normal select p.ParentID).ToArray();
                var thereIds     = (from p in thereParents where p.Status == SchemaObjectStatus.Normal select p.ParentID).ToArray();

                CheckPermissions(SCOperationType.AddSecretaryToUser, SchemaDefine.GetSchema("Organizations"), "UpdateChildren", hereIds);
                CheckPermissions(SCOperationType.AddSecretaryToUser, SchemaDefine.GetSchema("Organizations"), "UpdateChildren", thereIds);
            }

            SCSecretaryRelation result = null;

            ExecuteWithActions(SCOperationType.AddSecretaryToUser, () => SCActionContext.Current.DoActions(() => result = (SCSecretaryRelation)executor.Execute()));

            return(result);
        }
		/// <summary>
		/// 为某人指定秘书
		/// </summary>
		/// <param name="user"></param>
		/// <param name="secretary"></param>
		/// <returns></returns>
		public SCSecretaryRelation AddSecretaryToUser(SCUser secretary, SCUser user)
		{
			SCSecretaryRelativeExecutor executor = new SCSecretaryRelativeExecutor(SCOperationType.AddSecretaryToUser, user, secretary) { NeedStatusCheck = true, NeedContainerStatusCheck = this.NeedValidationAndStatusCheck };

			if (this._NeedCheckPermissions)
			{
				var hereParents = secretary.CurrentParentRelations;
				var thereParents = user.CurrentParentRelations;
				var hereIds = (from p in hereParents where p.Status == SchemaObjectStatus.Normal select p.ParentID).ToArray();
				var thereIds = (from p in thereParents where p.Status == SchemaObjectStatus.Normal select p.ParentID).ToArray();

				CheckPermissions(SCOperationType.AddSecretaryToUser, SchemaDefine.GetSchema("Organizations"), "UpdateChildren", hereIds);
				CheckPermissions(SCOperationType.AddSecretaryToUser, SchemaDefine.GetSchema("Organizations"), "UpdateChildren", thereIds);
			}

			SCSecretaryRelation result = null;

			ExecuteWithActions(SCOperationType.AddSecretaryToUser, () => SCActionContext.Current.DoActions(() => result = (SCSecretaryRelation)executor.Execute()));

			return result;
		}