public void SendNotificationEmailsFromPeriod(DateTime dateTimeNow)
        {
            var from         = dateTimeNow.AddMinutes(_settings.MinsBeforeToRemind - _settings.CheckEveryMins);
            var to           = dateTimeNow.AddMinutes(_settings.MinsBeforeToRemind);
            var singleEvents = _singleEventRepository.GetSingleEvents(from, to);
            var eventsSeries = _eventSeriesRepository.GetEventSeries(to);

            var eventsFromSeries = _eventFromSeriesRepository.GetEventFromSeries(from, to);

            foreach (var singleEvent in singleEvents)
            {
                SendEmailNotification(singleEvent.MailAddresses, singleEvent.Title, singleEvent.Start);
            }

            foreach (var eventFromSeries in eventsFromSeries)
            {
                SendEmailNotification(eventFromSeries.MailAddresses, eventFromSeries.Title, eventFromSeries.Start);
            }

            foreach (var eventSeries in eventsSeries)
            {
                var eventSeriesOccurrences = eventSeries.Finish.Occur(eventSeries.RepeatPeriod, eventSeries.Start, from, to);
                foreach (var eventOccurence in eventSeriesOccurrences)
                {
                    SendEmailNotification(eventSeries.MailAddresses, eventSeries.Title, eventOccurence);
                }
            }
        }
Exemplo n.º 2
0
        public IEnumerable <EventMetadata> GetMetadata(DateTime from, DateTime to)
        {
            var result = new List <EventMetadata>();

            result.AddRange(_singleEventRepository.GetSingleEvents(from, to).Select(x => x.ToMetadata(from, to)));
            result.AddRange(_eventSeriesRepository.GetEventSeries(to).Select(x => x.ToMetadata(from, to)));
            result.AddRange(_eventFromSeriesRepository.GetEventFromSeries(from, to)
                            .Select(x => x.ToMetadata(from, to)));

            return(result);
        }