Example #1
0
        public MailingSendingViewModel(Translator translator, Sending sending)
        {
            Name    = sending.Address.Value.Contact.Value.ShortHand;
            Address = sending.Address.Value.Address.Value;

            var sentDate =
                sending.SentDate.Value.HasValue ?
                sending.SentDate.Value.Value.ToLocalTime().ToString("dd.MM.yyyy HH:mm") :
                string.Empty;

            switch (sending.Status.Value)
            {
            case SendingStatus.Created:
                Status = translator.Get("Mailing.Sending.Field.Status.Sending", "Sending value in the sending status field the scheduled mailing page", "Sending").EscapeHtml();
                break;

            case SendingStatus.Sent:
                Status = translator.Get("Mailing.Sending.Field.Status.Sent", "Sent value in the sending status field the scheduled mailing page", "Sent at {0}", sentDate).EscapeHtml();
                break;

            case SendingStatus.Failed:
                Status = translator.Get("Mailing.Sending.Field.Status.Failed", "Failed value in the sending status field the scheduled mailing page", "Failed at {0} width message '{1}'", sentDate, sending.FailureMessage.Value ?? string.Empty).EscapeHtml();
                break;

            default:
                throw new NotSupportedException();
            }
        }
Example #2
0
        private void RunSend(IDatabase database, Mailing mailing)
        {
            int count = 0;

            foreach (var address in Targets(database, mailing))
            {
                var sending = new Sending(Guid.NewGuid());
                sending.Mailing.Value = mailing;
                sending.Address.Value = address;
                sending.Status.Value  = SendingStatus.Created;
                database.Save(sending);
                count++;
            }

            mailing.Status.Value = MailingStatus.Sending;
            database.Save(mailing);
            Global.Log.Notice("Mailing {0} is now sending {1} mails", mailing.Title, count);
        }