Inheritance: Record
示例#1
0
 private string _getTabRef(Email email)
 {
     if (email == null)
     {
         return(null);
     }
     return("/Email/Edit/" + Convert.ToString(email.ID));
 }
示例#2
0
 private string _getTabLabel(Email email)
 {
     if (email == null)
     {
         return(null);
     }
     return(email.subject);
 }
示例#3
0
        public ActionResult Create()
        {
            var e  = new Email();
            var ev = map.Map <Email, EmailView>(e);

            ev.status             = def.byID(e.statusID);
            ev.templates          = def.getEmailTemplates();
            ev.def                = def;
            ViewBag.EmailStatuses = def.getSelectList(LCategory.emailstatus);
            return(PartialView("Create", ev));
        }
示例#4
0
 public void Integration_Email_EF_Test_concurrency_exception()
 {
     // Arrange
     var db1 = new MacheteContext();
     var e1 = new Email()
     {
         emailFrom = "*****@*****.**",
         emailTo = "*****@*****.**",
         subject = "testing",
         body = "testing",
         statusID = Email.iReadyToSend,
         datecreated = DateTime.Now,
         dateupdated = DateTime.Now
     };
     db1.Emails.Add(e1);
     db1.SaveChanges();   // initial save, context 1
     var db2 = new MacheteContext();
     var e2 = db2.Emails.Find(e1.ID);
     e2.statusID = Email.iSending;
     db2.SaveChanges();  // context 2 saves on top of context 1
     e1.statusID = Email.iPending;
     // Act
     db1.SaveChanges(); // context 1 tries to save again, throws exception
 }
示例#5
0
 private string _getTabLabel(Email email)
 {
     return(email?.subject);
 }
示例#6
0
 private string _getTabRef(Email email)
 {
     if (email == null) return null;
     return "/Email/Edit/" + Convert.ToString(email.ID);
 }
示例#7
0
 private string _getTabLabel(Email email)
 {
     if (email == null) return null;
     return email.subject;
 }
示例#8
0
        /// <summary>
        /// create SmtpClient, create mail message, and send message. Catches exceptions and puts them in QueueManager.ExceptionStack.
        /// </summary>
        /// <param name="e"></param>
        /// <param name="cfg"></param>
        /// <returns></returns>
        public bool SendEmail(Email e, EmailServerConfig cfg)
        {
            try
            {
                e.emailFrom = cfg.OutgoingAccount;
                var client = new SmtpClient(cfg.HostName, cfg.Port)
                {
                    Credentials = new NetworkCredential(cfg.OutgoingAccount, cfg.OutgoingPassword),
                    EnableSsl = cfg.EnableSSL
                };
                var msg = new MailMessage(e.emailFrom, e.emailTo);
                if (e.attachment != null)
                {
                    var a = Attachment.CreateAttachmentFromString(e.attachment, e.attachmentContentType);
                    a.Name = "Order.html";
                    msg.Attachments.Add(a);
                }
                msg.Subject = e.subject;
                msg.Body = e.body;
                client.Send(msg);

                e.statusID = Email.iSent; // record sent
                sentStack.Push(e);
            }
            catch (Exception ex)
            {
                //  don't log the repeating message
                if (exceptionStack.Count() == 0 ||
                    exceptionStack.Peek().Message != ex.Message)
                {
                    exceptionStack.Push(ex);
                }
                e.statusID = Email.iTransmitError;
            }
            finally
            {
                e.lastAttempt = DateTime.Now;
                e.transmitAttempts += 1;
            }
            return true;
        }