コード例 #1
0
        public static void InviteUserToWorkflow(AssetWorkflowUser assetWorkflowUser, string inviteeEmail, string message)
        {
            // Ensure message is specified
            if (StringUtils.IsBlank(message))
            {
                throw new ValidationException("Message is required (this will be sent to the user being invited to comment)");
            }

            // Ensure email address is specified
            if (StringUtils.IsBlank(inviteeEmail))
            {
                throw new ValidationException("Email address is required");
            }

            // Get the user by email address
            User invitedUser = User.GetByEmail(inviteeEmail);

            // Ensure email address belongs to a registered user
            if (invitedUser.IsNull)
            {
                throw new ValidationException("Email does not belong to a registered user");
            }

            // Ensure invited user has upload privileges
            if (invitedUser.UserRoleId < Convert.ToInt32(UserRole.UploadUser))
            {
                throw new ValidationException("Email does not belong to a user with upload privileges");
            }

            // Create the commenter record
            AssetWorkflowCommenter awfc = AssetWorkflowCommenter.New();

            awfc.AssetWorkflowId             = assetWorkflowUser.AssetWorkflowId;
            awfc.InvitingAssetWorkflowUserId = assetWorkflowUser.AssetWorkflowUserId.GetValueOrDefault();
            awfc.InvitingUserId      = assetWorkflowUser.UserId;
            awfc.InvitingUserMessage = message;
            awfc.UserId     = invitedUser.UserId.GetValueOrDefault();
            awfc.CreateDate = DateTime.Now;
            awfc.LastUpdate = DateTime.Now;
            AssetWorkflowCommenter.Update(awfc);

            // Refresh from DB
            // awfc = AssetWorkflowCommenter.Get(awfc.AssetWorkflowCommenterId);

            // Now we need to notify them
            if (AssetWorkflowCommenterInvited != null)
            {
                AssetWorkflowCommenterInvited(null, new AssetWorkflowCommenterEventArgs(awfc));
            }
        }
コード例 #2
0
        public static void SaveAssetWorkflowCommenter(AssetWorkflowCommenter awfc)
        {
            if (awfc.AssetWorkflow.IsComplete)
            {
                throw new ValidationException("Asset workflow is complete and comments have been disabled");
            }

            if (StringUtils.IsBlank(awfc.Comments))
            {
                throw new ValidationException("Comments are required");
            }

            // Save the commenter
            AssetWorkflowCommenter.Update(awfc);

            // Now notify the user who invited this commenter
            if (AssetWorkflowCommenterUpdated != null)
            {
                AssetWorkflowCommenterUpdated(null, new AssetWorkflowCommenterEventArgs(awfc));
            }
        }