Ejemplo n.º 1
0
        private static void SaveEmails(string community, CommunityEmails emails)
        {
            var sb = new StringBuilder();

            sb.AppendLine("<html>");
            sb.AppendLine("  <body>");
            sb.AppendLine("    <div>");
            sb.AppendLine("      <style type='text/css'>");
            sb.AppendLine("           html, body { font-family:tahoma, sans-serif; }	");
            sb.AppendLine("           .alignRight { text-align:right; }");
            sb.AppendLine("           .alignLeft  { text-align:left; }");
            sb.AppendLine("           .bgGray { background-color: #E5E5E5; }");
            sb.AppendLine("      </style>");

            SaveEmails(sb, "Member emails", community, emails.MemberEmails, emails.References);
            SaveEmails(sb, "Member to member notifications", community, emails.MemberToMemberNotifications, emails.References);
            SaveEmails(sb, "Employer to member notifications", community, emails.EmployerToMemberNotifications, emails.References);
            SaveEmails(sb, "Member alerts", community, emails.MemberAlerts, emails.References);
            SaveEmails(sb, "Registered user emails", community, emails.RegisteredUserEmails, emails.References);
            SaveEmails(sb, "Employer emails", community, emails.EmployerEmails, emails.References);
            SaveEmails(sb, "Custodian emails", community, emails.CustodianEmails, emails.References);
            SaveEmails(sb, "Internal emails", community, emails.InternalEmails, emails.References);

            sb.AppendLine("    </div>");
            sb.AppendLine("  </body>");
            sb.AppendLine("</html>");

            Save(community, "Emails.html", sb.ToString(), emails.References);
        }
Ejemplo n.º 2
0
        private static void SaveReferences(string community, CommunityEmails emails)
        {
            foreach (var url in emails.References)
            {
                var request = WebRequest.Create(url);

                using (var response = request.GetResponse())
                {
                    var reader = new BinaryReader(response.GetResponseStream());
                    Save(community, Path.GetFileName(url), reader);
                }
            }
        }
Ejemplo n.º 3
0
        private void Add(Community community, TemplateEmail templateEmail, MockEmail mockEmail)
        {
            CommunityEmails emails;

            _communityEmails.TryGetValue(community == null ? string.Empty : community.Name, out emails);
            if (emails == null)
            {
                emails = new CommunityEmails();
                _communityEmails[community == null ? string.Empty : community.Name] = emails;
            }

            if (templateEmail.GetType().IsSubclassOf(typeof(EmployerToMemberNotification)))
            {
                emails.EmployerToMemberNotifications[templateEmail] = mockEmail;
            }
            else if (templateEmail.GetType().IsSubclassOf(typeof(MemberToMemberNotification)))
            {
                emails.MemberToMemberNotifications[templateEmail] = mockEmail;
            }
            else if (templateEmail.GetType().IsSubclassOf(typeof(MemberAlertEmail)))
            {
                emails.MemberAlerts[templateEmail] = mockEmail;
            }
            else if (templateEmail.GetType().IsSubclassOf(typeof(MemberEmail)))
            {
                emails.MemberEmails[templateEmail] = mockEmail;
            }
            else if (templateEmail.GetType().IsSubclassOf(typeof(EmployerEmail)))
            {
                emails.EmployerEmails[templateEmail] = mockEmail;
            }
            else if (templateEmail.GetType().IsSubclassOf(typeof(CustodianEmail)))
            {
                emails.CustodianEmails[templateEmail] = mockEmail;
            }
            else if (templateEmail.GetType().IsSubclassOf(typeof(UserEmail)))
            {
                emails.RegisteredUserEmails[templateEmail] = mockEmail;
            }
            else if (templateEmail.GetType().IsSubclassOf(typeof(InternalEmail)))
            {
                emails.InternalEmails[templateEmail] = mockEmail;
            }
            else
            {
                throw new ApplicationException("Non-recognised email type '" + templateEmail.GetType() + "'.");
            }
        }