예제 #1
0
        private void SendProcessingStatusMail(PermissionItem permission)
        {
            try
            {
                // Send Mail for moderators.
                var moderatorPermissionStatusRequest = new ModeratorPermissionStatusRequest();
                moderatorPermissionStatusRequest.CommunityID = permission.CommunityID;
                moderatorPermissionStatusRequest.CommunityName = permission.CommunityName;
                moderatorPermissionStatusRequest.RequestorID = permission.UserID;
                moderatorPermissionStatusRequest.RequestorName = permission.Name;
                moderatorPermissionStatusRequest.ApprovedRole = permission.Role;
                moderatorPermissionStatusRequest.IsApproved = permission.Approved == true;
                moderatorPermissionStatusRequest.RequestorLink = string.Format(CultureInfo.InvariantCulture, "{0}Profile/Index/{1}", HttpContext.Request.Url.GetServerLink(), permission.UserID);
                moderatorPermissionStatusRequest.CommunityLink = string.Format(CultureInfo.InvariantCulture, "{0}Community/Index/{1}", HttpContext.Request.Url.GetServerLink(), permission.CommunityID);

                _notificationService.NotifyModeratorPermissionStatus(moderatorPermissionStatusRequest);

                // Send Mail for moderators.
                var request = new UserPermissionStatusRequest();
                request.CommunityID = permission.CommunityID;
                request.CommunityName = permission.CommunityName;
                request.RequestorID = permission.UserID;
                request.RequestorName = permission.Name;
                request.IsApproved = permission.Approved == true;
                request.RequestorLink = string.Format(CultureInfo.InvariantCulture, "{0}Profile/Index/{1}", HttpContext.Request.Url.GetServerLink(), permission.UserID);
                request.CommunityLink = string.Format(CultureInfo.InvariantCulture, "{0}Community/Index/{1}", HttpContext.Request.Url.GetServerLink(), permission.CommunityID);

                _notificationService.NotifyUserRequestPermissionStatus(request);
            }
            catch (Exception)
            {
                // Ignore all exceptions.
            }
        }
예제 #2
0
        public static EmailRequest UpdateFrom(this EmailRequest thisObject, UserPermissionStatusRequest 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.RequestorID);
            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, "Your request to join the Layerscape {0} \"{1}\" has been {2}", isFolder ? "folder" : "community", entityName, request.IsApproved ? "Approved" : "Denied");

                var replacements = new Dictionary<string, string>
                {
                    { "@@CommunityName@@", HttpUtility.UrlDecode(entityName) }, 
                    { "@@CommunityLink@@", HttpUtility.UrlDecode(request.CommunityLink) },
                    { "@@RequestorName@@", HttpUtility.UrlDecode(user.GetFullName()) },
                    { "@@RequestorID@@", HttpUtility.UrlDecode(request.RequestorID.ToString()) },
                    { "@@RequestorLink@@", HttpUtility.UrlDecode(request.RequestorLink) },
                    { "@@PermissionStatus@@", HttpUtility.UrlDecode(request.IsApproved ? "Approved" : "Denied") },
                    { "@@CommunityType@@", isFolder ? "folder" : "community" },
                    { "@@Greetings@@", HttpUtility.UrlDecode(request.IsApproved ? "Congratulations! Your" : "We regret to inform you that your") },
                };
                thisObject.MessageBody = FormatMailBodyUsingTemplate("requestorapprovedrequest.html", replacements);
            }

            return thisObject;
        }
예제 #3
0
 /// <summary>
 /// Notify the user about his permission approval/denial.
 /// </summary>
 /// <param name="notification">Permission details</param>
 public void NotifyUserRequestPermissionStatus(UserPermissionStatusRequest notification)
 {
     SendMail(notification);
 }