예제 #1
0
        private void SendRemoveUserMail(PermissionItem permission)
        {
            try
            {
                // Send Mail.
                var request = new RemoveUserRequest();
                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;

                _notificationService.NotifyRemoveUser(request);
            }
            catch (Exception)
            {
                // Ignore all exceptions.
            }
        }
예제 #2
0
        public static EmailRequest UpdateFrom(this EmailRequest thisObject, RemoveUserRequest 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)
            {
                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 no longer have permissions on the Layerscape {0} \"{1}\"", isFolder ? "folder" : "community", entityName);

                var replacements = new Dictionary<string, string>
                {
                    { "@@CommunityName@@", HttpUtility.UrlDecode(entityName) }, 
                    { "@@CommunityLink@@", HttpUtility.UrlDecode(request.CommunityLink) },
                    { "@@UserName@@", HttpUtility.UrlDecode(user.GetFullName()) },
                    { "@@CommunityType@@", isFolder ? "folder" : "community" },
                    { "@@UserLink@@", HttpUtility.UrlDecode(request.UserLink) },
                };
                thisObject.MessageBody = FormatMailBodyUsingTemplate("removeuserrequest.html", replacements);
            }
            return thisObject;
        }
예제 #3
0
 /// <summary>
 /// Notify the the user about his removal from an community.
 /// </summary>
 /// <param name="notification">Community details</param>
 public void NotifyRemoveUser(RemoveUserRequest notification)
 {
     SendMail(notification);
 }