コード例 #1
0
        private void SendChangedUserRoleMail(PermissionItem permission)
        {
            try
            {
                // Send Mail.
                var request = new UserPermissionChangedRequest();
                request.CommunityID = permission.CommunityID;
                request.CommunityName = permission.CommunityName;
                request.CommunityLink = string.Format(CultureInfo.InvariantCulture, "{0}Community/Index/{1}", HttpContext.Request.Url.GetServerLink(), permission.CommunityID);
                request.UserID = permission.UserID;
                request.UserLink = string.Format(CultureInfo.InvariantCulture, "{0}Profile/Index/{1}", HttpContext.Request.Url.GetServerLink(), permission.UserID);
                request.UserName = permission.Name;
                request.Role = permission.Role;
                request.ModeratorID = CurrentUserId;
                request.ModeratorLink = string.Format(CultureInfo.InvariantCulture, "{0}Profile/Index/{1}", HttpContext.Request.Url.GetServerLink(), request.ModeratorID);

                _notificationService.NotifyUserPermissionChangedStatus(request);
            }
            catch (Exception)
            {
                // Ignore all exceptions.
            }
        }
コード例 #2
0
        public static EmailRequest UpdateFrom(this EmailRequest thisObject, UserPermissionChangedRequest request)
        {
            if (thisObject == null)
            {
                thisObject = new EmailRequest();
            }

            string entityName = string.Empty;
            bool isFolder = false;

            ICommunityRepository communityRepository = DependencyResolver.Current.GetService(typeof(ICommunityRepository)) as ICommunityRepository;
            Community community = communityRepository.GetItem(c => c.CommunityID == request.CommunityID);
            if (community != null)
            {
                entityName = community.Name;
                isFolder = community.CommunityTypeID == (int)CommunityTypes.Folder;
            }

            IUserRepository userRepository = DependencyResolver.Current.GetService(typeof(IUserRepository)) as IUserRepository;
            User user = userRepository.GetItem(u => u.UserID == request.UserID);
            if (user.IsSubscribed)
            {
                User moderator = userRepository.GetItem(u => u.UserID == request.ModeratorID);
                thisObject.Recipients.Add(new MailAddress(user.Email.FixEmailAddress(), user.FirstName + " " + user.LastName));

                thisObject.IsHtml = true;

                // Update the body and the subject.
                thisObject.Subject = string.Format(CultureInfo.CurrentUICulture, "You are now a {0} on the Layerscape {1} \"{2}\"", request.Role.ToString(), isFolder ? "folder" : "community", entityName);

                var replacements = new Dictionary<string, string>
                {
                    { "@@CommunityName@@", HttpUtility.UrlDecode(entityName) }, 
                    { "@@CommunityLink@@", HttpUtility.UrlDecode(request.CommunityLink) },
                    { "@@UserName@@", HttpUtility.UrlDecode(user.GetFullName()) },
                    { "@@UserLink@@", HttpUtility.UrlDecode(request.UserLink) },
                    { "@@Role@@", HttpUtility.UrlDecode(request.Role.ToString()) },
                    { "@@CommunityType@@", isFolder ? "folder" : "community" },
                    { "@@ModeratorName@@", HttpUtility.UrlDecode(moderator.GetFullName()) },
                    { "@@ModeratorLink@@", HttpUtility.UrlDecode(request.ModeratorLink) }
                };
                thisObject.MessageBody = FormatMailBodyUsingTemplate("permissionchangerequest.html", replacements);
            }

            return thisObject;
        }
コード例 #3
0
 /// <summary>
 /// Notify the about his change in the permissions.
 /// </summary>
 /// <param name="notification">Permission details</param>
 public void NotifyUserPermissionChangedStatus(UserPermissionChangedRequest notification)
 {
     SendMail(notification);
 }