예제 #1
0
        private MailMessage GenerateReminderForPerson(Person person, List <Project> projects)
        {
            var projectListAsHtmlStrings =
                GenerateProjectListAsHtmlStrings(
                    projects);
            var projectsRequiringAnUpdateUrl =
                SitkaRoute <ProjectUpdateController> .BuildAbsoluteUrlHttpsFromExpression(x =>
                                                                                          x.MyProjectsRequiringAnUpdate());

            var tenantCanonicalHostUrl = FirmaWebConfiguration.GetCanonicalHostForBackgroundJob(TenantID);

            projectsRequiringAnUpdateUrl =
                SitkaRoute <ProjectUpdateController> .ReplaceHostNameForBackgroundJob(projectsRequiringAnUpdateUrl,
                                                                                      tenantCanonicalHostUrl);

            var emailContent = GetEmailContentWithGeneratedSignature(projectsRequiringAnUpdateUrl,
                                                                     person.GetFullNameFirstLast(), String.Join("<br/>", projectListAsHtmlStrings));

            var htmlView = AlternateView.CreateAlternateViewFromString(emailContent, null, "text/html");

            htmlView.LinkedResources.Add(
                new LinkedResource(new MemoryStream(ToolLogo.FileResourceData.Data), "img/jpeg")
            {
                ContentId = "tool-logo"
            });
            var mailMessage = new MailMessage {
                Subject = ReminderEmailSubject, IsBodyHtml = true
            };

            mailMessage.AlternateViews.Add(htmlView);

            return(mailMessage);
        }
예제 #2
0
        private IEnumerable <string> GenerateProjectListAsHtmlStrings(
            IReadOnlyCollection <Project> projects)
        {
            var projectsRemaining        = projects;
            var tenantCanonicalHostName  = FirmaWebConfiguration.GetCanonicalHostForBackgroundJob(TenantID);
            var projectListAsHtmlStrings = projectsRemaining.OrderBy(project => project.GetDisplayName()).Select(project =>
            {
                var projectUrl =
                    SitkaRoute <ProjectController> .BuildAbsoluteUrlHttpsFromExpression(controller =>
                                                                                        controller.Detail(project));
                projectUrl = SitkaRoute <ProjectController> .ReplaceHostNameForBackgroundJob(projectUrl, tenantCanonicalHostName);
                return($@"<div style=""font-size:smaller""><a href=""{projectUrl}"">{project.ProjectName}</a></div>");
            }).ToList();

            return(projectListAsHtmlStrings);
        }