private static void LogMessage(MatchingDB db, EmailQueueMessage qMessage,string status)
 {
     EmailLog eLog = new EmailLog(qMessage,status);
     Project pr; Student st;
     try
     {
         switch (qMessage.ContactType)
         {
             case "Project":
                 pr = db.Projects.Where(p => p.Id == qMessage.ContactId).First();
                 pr.Emailed = (status == EmailStatus.Success.ToString());
                 if (pr.EmailLogs == null)
                     pr.EmailLogs = new List<EmailLog>();
                 pr.EmailLogs.Add(eLog);
                 break;
             case "Student":
                 st = db.Students.Where(s => s.Id == qMessage.ContactId).First();
                 st.Emailed = (status == EmailStatus.Success.ToString());
                 if (st.EmailLogs == null)
                     st.EmailLogs = new List<EmailLog>();
                 st.EmailLogs.Add(eLog);
                 break;
             default:
                 break;
         }
         db.SaveChanges();
     }
     catch (Exception ex)
     {
         log.Error("An unexpected exception occured while creating a log record for the notification e-mail sent from the queue. The id for the " + qMessage.ContactType + " is: " + qMessage.ContactId + ". You can disregard this message if the " + qMessage.ContactType + " is deleted.", ex.InnerException ?? ex);
     }
 }
 /// <summary>
 /// Drops the message in the email queueing table for Quartz job to pick it up. This is the main method to send templated -emails to project contacts and students.
 /// </summary>
 /// <param name="to">Recipient</param>
 /// <param name="subject">Subject of the email</param>
 /// <param name="body">Body of the email</param>
 public static void QueueMessage(EmailQueueMessage message)
 {
     using (var db = new MatchingDB())
     {
         db.EmailQueueMessages.Add(message);
         db.SaveChanges();
     }
 }
Esempio n. 3
0
 public EmailLog(EmailQueueMessage qMessage, String status)
 {
     Date = DateTime.Now;
     Guid = qMessage.Guid;
     Status = status;
     Subject = qMessage.Subject;
     Message = qMessage.Body;
 }
 public void SendAccessUrl(IList<Contact> contacts)
 {
     foreach (var c in contacts)
     {
         var emailType = c.ContactType == ContactType.Project ? EmailType.ProjectAccess : EmailType.StudentAccess;
         var eqm = new EmailQueueMessage(c, emailType);
         EmailQueueService.QueueMessage(eqm);
     }
 }
 private void SendConfirmationMessage(Project p)
 {
     Contact c = new Contact(p);
     EmailQueueMessage eqm = new EmailQueueMessage(c, EmailType.ProjectSubmit, GetRankingConfirmationText(p), c.Email + "," + _confMesgReceipents);
     EmailQueueService.QueueMessage(eqm);
 }