Git Repository Public Repository

CPE_learningsite

URLs

Copy to Clipboard

This repository has no backups
This repository's network speed is throttled to 100KB/sec

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*
Developer: Tyler Allen
Date Created: 08/24/2016
---------------------------------------------------
*/

using System;
using System.Configuration;
using System.Net.Mail;
using CPE.App.NotifyConsole.Extensions;
using CPE.App.NotifyConsole.Models.Enums;

namespace CPE.App.NotifyConsole.Helpers {
    public class EmailCertificateHelper {
        /// <summary>
        ///     Email the certificate results to the participant
        /// </summary>
        /// <param name="to">Email recipient</param>
        /// <param name="scoId">Primary key of the meeting room</param>
        /// <param name="purchaseDate">The date the meeting access was purchased</param>
        /// <param name="purchaseTicket">The ticket recieved when the meeting room was purchased</param>
        /// <returns></returns>
        public static EmailCertificateResults SendWebcastCert(string to, int scoId, DateTime purchaseDate, string purchaseTicket) {
            var subject = ConfigurationManager.AppSettings["WebcastCertEmailSubject"].Log(message: "Subject");
            var certUrl = EmailRenderHelper.RenderCertificateLink(scoId, purchaseDate, purchaseTicket)
                                           .Log(message: "RenderCertificateLink");
            var body = EmailRenderHelper.RenderWebcastEmail(certUrl)
                                        .Log(message: "Body");
            return sendEmail(to, subject, body)
                .Log();
        }

        /// <summary>
        ///     Send a failure notice to the participant
        /// </summary>
        /// <param name="to">Email recipient</param>
        /// <returns></returns>
        public static EmailCertificateResults SendFailNotice(string to) {
            var subject = ConfigurationManager.AppSettings["WebcastFailEmailSubject"].Log(message: "Subject");
            var body = EmailRenderHelper.RenderFailEmail()
                                        .Log(message: "Body");
            return sendEmail(to, subject, body)
                .Log();
        }

        /// <summary>
        ///     Send email
        /// </summary>
        /// <param name="to">Recipient</param>
        /// <param name="subject">Subject</param>
        /// <param name="body">Body</param>
        /// <returns></returns>
        private static EmailCertificateResults sendEmail(string to, string subject, string body) {
            try {
                var mail = new MailMessage(ConfigurationManager.AppSettings["WebcastEmailSender"], to) {
                    Subject = subject,
                    Body = body,
                    IsBodyHtml = true
                };
                var client = new SmtpClient {
                    Port = 25,
                    DeliveryMethod = SmtpDeliveryMethod.Network,
                    UseDefaultCredentials = false,
                    Host = ConfigurationManager.AppSettings["EmailServer"]
                };
                client.Send(mail);
            } catch (Exception exception) {
                exception.Log(LoggingLevels.Fatal);
                return EmailCertificateResults.Fail;
            }

            return EmailCertificateResults.Success;
        }
    }
}

Commits for CPE_learningsiteCPE/CPE.App/CPE.App.NotifyConsole/Helpers/AdobeCertificateHelper.cs

Diff revisions: vs.
Revision Author Commited Message
4cd176 ... v.shishlov Fri 27 Aug, 2021 14:33:17 +0000

initial commit