private void UpdateFailureEmails(MimeDSNRecipient r, ISession session)
        {
            IList<AccountEmail> emails = session.CreateCriteria(typeof(AccountEmail))
                .Add(Expression.Eq("Address", r.FinalRecipientEmailAddress))
                .List<AccountEmail>();

            if (emails == null)
                return;

            foreach (AccountEmail email in emails)
            {
                if (IsStopping)
                    break;

                if (email.Failed)
                    continue;

                EventLogManager.WriteEntry(string.Format("Marked {0} [{1}] (id:{2}) with failure [{3}].",
                    email.Account.Name, email.Address, email.Id, r.DiagnosticCode));

                // check whether there're pending invitations for this e-mail
                foreach (AccountEmailConfirmation confirmation in Collection<AccountEmailConfirmation>.GetSafeCollection(email.AccountEmailConfirmations))
                {
                    session.Delete(confirmation);
                }

                email.Failed = true;
                email.LastError = r.DiagnosticCode;
                email.Modified = DateTime.UtcNow;
                session.Save(email);
                session.Flush();
            }
        }
Beispiel #2
0
        /// TODO: write body
        public override void LoadBody(string strData)
        {
            base.LoadBody(strData);

            _recipients = new List <MimeDSNRecipient>();

            int current = strData.IndexOf("\r\n\r\n") + 4;
            int partend;

            do
            {
                partend = strData.IndexOf("\r\n\r\n", current);
                int len = (partend == -1) ? strData.Length - current : partend - current;
                if (len == 0)
                {
                    break;
                }
                MimeDSNRecipient recipient = new MimeDSNRecipient();
                recipient.LoadHead(strData.Substring(current, len));
                _recipients.Add(recipient);
                current = partend + 4;
            } while (partend != -1);
        }
        private void UpdateFailureInvitations(MimeDSNRecipient r, ISession session)
        {
            IList<AccountInvitation> invitations = session.CreateCriteria(typeof(AccountInvitation))
                .Add(Expression.Eq("Email", r.FinalRecipientEmailAddress))
                .List<AccountInvitation>();

            if (invitations == null)
                return;

            foreach (AccountInvitation invitation in invitations)
            {
                if (invitation.Failed)
                    continue;

                EventLogManager.WriteEntry(string.Format("Marked \"{0}\" [invited by {1}] (id:{2}) with failure [{3}].",
                    invitation.Email, invitation.Account.Name, invitation.Id, r.DiagnosticCode));

                invitation.Failed = true;
                invitation.LastError = r.DiagnosticCode;
                invitation.Modified = DateTime.UtcNow;
                session.Save(invitation);
                session.Flush();
            }
        }
Beispiel #4
0
        /// TODO: write body
        public override void LoadBody(string strData)
        {
            base.LoadBody(strData);

            _recipients = new List<MimeDSNRecipient>();

            int current = strData.IndexOf("\r\n\r\n") + 4;
            int partend;
            do
            {
                partend = strData.IndexOf("\r\n\r\n", current);
                int len = (partend == -1) ? strData.Length - current : partend - current;
                if (len == 0) break;
                MimeDSNRecipient recipient = new MimeDSNRecipient();
                recipient.LoadHead(strData.Substring(current, len));
                _recipients.Add(recipient);
                current = partend + 4;
            } while (partend != -1);
        }
 private void UpdateFailure(MimeDSNRecipient r)
 {
     ISession session = SnCore.Data.Hibernate.Session.Factory.OpenSession();
     try
     {
         EventLogManager.WriteEntry(string.Format("Searching for {0}.", r.FinalRecipientEmailAddress));
         UpdateFailureEmails(r, session);
         UpdateFailureInvitations(r, session);
     }
     finally
     {
         session.Close();
     }
 }