Ejemplo n.º 1
0
        /// <summary>
        /// Gets the event info collection.
        /// </summary>
        /// <param name="dtStart">The dt start.</param>
        /// <param name="dtEnd">The dt end.</param>
        /// <returns></returns>
        public EventInfoCollections GetEventInfoCollection(DateTime dtStart,
                                                           DateTime dtEnd)
        {
            EventInfoCollections retVal = new EventInfoCollections();

            if (_calendarId == -1)
            {
                throw new NullReferenceException("calendarId");
            }

            //querying non virtual events
            if (dtStart == DateTime.MinValue && dtEnd == DateTime.MaxValue)
            {
                return(retVal);
            }

            CalendarEvent[] calEvents = CalendarEvent.List(new FilterElement("PrimaryCalendarId",
                                                                             FilterElementType.Equal, _calendarId));

            foreach (CalendarEvent calEvent in calEvents)
            {
                CalendarEventRecurrence[] eventRecurrs = CalendarEventRecurrence.List(new FilterElement("EventId",
                                                                                                        FilterElementType.Equal, calEvent.PrimaryKeyId.Value));

                List <DateTime> eventRecurrResult = new List <DateTime>();

                foreach (CalendarEventRecurrence eventRecurr in eventRecurrs)
                {
                    List <DateTime> recurrList = GetRecurrence(eventRecurr.Rrule,
                                                               eventRecurr.Exrule,
                                                               eventRecurr.Exdate,
                                                               calEvent.DtStart, dtEnd);

                    //skip recurrence equals beginning owner calendar event
                    recurrList.Remove(calEvent.DtStart);

                    eventRecurrResult = (JoinList(eventRecurrResult, recurrList, false));
                }

                //Begin create virtual events
                foreach (DateTime eventDate in eventRecurrResult)
                {
                    retVal.Add(MakeEventInfo(eventDate, calEvent));
                }
            }

            return(retVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the event info collection.
        /// </summary>
        /// <param name="dtStart">The dt start.</param>
        /// <param name="dtEnd">The dt end.</param>
        /// <returns></returns>
        public EventInfoCollections GetEventInfoCollection(DateTime dtStart, DateTime dtEnd)
        {
            EventInfoCollections retVal = new EventInfoCollections();

            if (_calendar == null)
            {
                throw new NullReferenceException("calendar");
            }

            CalendarEvent[] calEvents = CalendarEvent.List(new FilterElement("PrimaryCalendarId",
                                                                             FilterElementType.Equal, _calendar.PrimaryKeyId.Value));
            foreach (CalendarEvent calEvent in calEvents)
            {
                if ((calEvent.DtStart >= dtStart) && (calEvent.DtEnd <= dtEnd))
                {
                    CalendarEventInfo eventInfo = new CalendarEventInfo(this, calEvent);
                    eventInfo.SetEventId(EventProviderHelper.MakeEventId(GetEventType(),
                                                                         (ulong)(int)calEvent.PrimaryKeyId.Value));
                    retVal.Add(eventInfo);
                }
            }

            return(retVal);
        }