예제 #1
0
        /// <summary>
        /// Called when a scheduled job executes
        /// </summary>
        /// <returns>A status message to be stored in the database log and visible from admin mode</returns>
        public override string Execute()
        {
            OnStatusChanged(String.Format("Sending scheduled emails..."));

            List <EventPageBase>       allEventPages = AttendScheduledEmailEngine.GetEventPageBases();
            List <ScheduledEmailBlock> emailsToSend  = AttendScheduledEmailEngine.GetScheduledEmailsToSend(allEventPages);



            int numberOfMailsSent   = 0;
            int numberOfMailsToSend = emailsToSend.Count;

            foreach (ScheduledEmailBlock scheduledEmailBlock in emailsToSend)
            {
                List <IParticipant> participantsToSendEmailTo = AttendScheduledEmailEngine.GetParticipantsForScheduledEmail(scheduledEmailBlock);
                foreach (IParticipant participant in participantsToSendEmailTo)
                {
                    AttendScheduledEmailEngine.SendScheduledEmail(scheduledEmailBlock, participant);
                    numberOfMailsSent++;
                    OnStatusChanged(String.Format("Sent " + numberOfMailsSent + " messages."));

                    if (_stopSignaled)
                    {
                        return("Stop of job was called");
                    }
                }
                AttendScheduledEmailEngine.MarkAsSent(scheduledEmailBlock);
            }
            return("Job completed. Sent " + numberOfMailsSent + " messages through " + numberOfMailsToSend + " templates.");
        }
예제 #2
0
        public bool SendStatusMail(IParticipant participant)
        {
            AttendStatus  status       = AttendStatus.Undefined;
            EventPageBase CurrentEvent = EPiServer.DataFactory.Instance.Get <EventPageBase>(participant.EventPage);

            Enum.TryParse <AttendStatus>(participant.AttendStatus, out status);
            foreach (ScheduledEmailBlock scheduledEmailBlock in AttendScheduledEmailEngine.GetScheduledEmails(CurrentEvent.ContentLink, SendOptions.Action, status))
            {
                AttendScheduledEmailEngine.SendScheduledEmail(scheduledEmailBlock, participant);
            }
            return(true);
        }