Example #1
0
        protected ICalendarFolder BindToConsumerCalendarFolder(StoreObjectId folderId)
        {
            ICalendarFolder calendarFolder = this.XsoFactory.BindToCalendarFolder(this.MailboxSession, folderId);

            calendarFolder.Load(CalendarFolderSchema.ConsumerCalendarProperties);
            return(calendarFolder);
        }
Example #2
0
        public virtual ConsumerCalendarSubscription TryGetSubscription(StoreObjectId folderId)
        {
            ConsumerCalendarSubscription result;

            using (ICalendarFolder calendarFolder = this.BindToConsumerCalendarFolder(folderId))
            {
                long consumerCalendarOwnerId = calendarFolder.ConsumerCalendarOwnerId;
                if (consumerCalendarOwnerId == 0L)
                {
                    this.OnLogError("ConsumerCalendarOwnerId is set to zero.");
                    result = null;
                }
                else
                {
                    Guid consumerCalendarGuid = calendarFolder.ConsumerCalendarGuid;
                    if (consumerCalendarGuid == Guid.Empty)
                    {
                        this.OnLogError("ConsumerCalendarGuid is empty.");
                        result = null;
                    }
                    else
                    {
                        result = new ConsumerCalendarSubscription(consumerCalendarOwnerId, consumerCalendarGuid);
                    }
                }
            }
            return(result);
        }
        private IEnumerable <Event> GetSeriesEventsData(Event theEvent, Microsoft.Exchange.Data.PropertyDefinition identityProperty, Func <IStorePropertyBag, Event> convertToEvent, SortBy sortOrder, params Microsoft.Exchange.Data.PropertyDefinition[] additionalPropertiesToQuery)
        {
            if (identityProperty == null)
            {
                identityProperty = CalendarItemBaseSchema.SeriesId;
            }
            ComparisonFilter condition             = EventDataProvider.CreateComparisonFilterForSeriesSearch(theEvent, identityProperty);
            string           identityBeingSearched = condition.PropertyValue.ToString();

            SortBy[] internalSortOrder = EventDataProvider.CreateSortOrderForSeriesSearch(condition.Property, sortOrder);
            ICollection <Microsoft.Exchange.Data.PropertyDefinition> propertiesToQuery = new List <Microsoft.Exchange.Data.PropertyDefinition>(EventDataProvider.InstanceRequiredPropertiesToQuery);

            propertiesToQuery.Add(identityProperty);
            if (additionalPropertiesToQuery != null)
            {
                propertiesToQuery = propertiesToQuery.Union(additionalPropertiesToQuery);
            }
            using (ICalendarFolder calendarFolder = base.XsoFactory.BindToCalendarFolder(base.Session, base.ContainerFolderId))
            {
                using (IQueryResult queryResult = calendarFolder.IItemQuery(ItemQueryType.None, null, internalSortOrder, propertiesToQuery))
                {
                    queryResult.SeekToCondition(SeekReference.OriginBeginning, condition);
                    for (;;)
                    {
                        IStorePropertyBag[] rows = queryResult.GetPropertyBags(50);
                        EventDataProvider.InstanceQueryTrace.TraceDebug <int, string>((long)theEvent.GetHashCode(), "EventExtension::GetDataForSeries retrieved {0} instances for series {1}.", rows.Length, identityBeingSearched);
                        foreach (IStorePropertyBag rowPropertyBag in rows)
                        {
                            string itemClass = rowPropertyBag.GetValueOrDefault <string>(StoreObjectSchema.ItemClass, null);
                            if (ObjectClass.IsCalendarItem(itemClass) || ObjectClass.IsCalendarItemSeries(itemClass))
                            {
                                if (!EventDataProvider.IsSeriesIdMatching(identityBeingSearched, rowPropertyBag, condition.Property))
                                {
                                    goto IL_211;
                                }
                                yield return(convertToEvent(rowPropertyBag));
                            }
                            else
                            {
                                EventDataProvider.InstanceQueryTrace.TraceDebug <string>((long)theEvent.GetHashCode(), "EventExtension::GetDataForSeries will skip item with class {0}.", itemClass);
                            }
                        }
                        if (rows.Length <= 0)
                        {
                            goto Block_10;
                        }
                    }
IL_211:
                    EventDataProvider.InstanceQueryTrace.TraceDebug <string>((long)theEvent.GetHashCode(), "EventExtension::GetDataForSeries found all the items related to series {0} and will return.", identityBeingSearched);
                    yield break;
                    Block_10 :;
                }
            }
            yield break;
        }
        public virtual IEnumerable <Event> GetCalendarView(ExDateTime startTime, ExDateTime endTime, bool includeSeriesMasters, params Microsoft.Exchange.Data.PropertyDefinition[] propertiesToLoad)
        {
            IEnumerable <Event> result;

            using (ICalendarFolder calendarFolder = base.XsoFactory.BindToCalendarFolder(base.Session, base.ContainerFolderId))
            {
                Dictionary <Microsoft.Exchange.Data.PropertyDefinition, int> propertyIndices = this.GetPropertyIndices(propertiesToLoad);
                object[][]          syncView   = calendarFolder.GetSyncView(startTime, endTime, CalendarViewBatchingStrategy.CreateNoneBatchingInstance(), propertiesToLoad, true);
                IEnumerable <Event> enumerable = this.ReadQueryResults(syncView, propertyIndices);
                result = (includeSeriesMasters ? enumerable : this.FilterOutType(enumerable, EventType.SeriesMaster));
            }
            return(result);
        }