Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        protected override void ValidateChanges(Event sourceEntity, ICalendarItemBase targetStoreObject)
        {
            bool flag;

            if (sourceEntity.IsPropertySet(sourceEntity.Schema.IsAllDayProperty))
            {
                flag = sourceEntity.IsAllDay;
                if (flag != targetStoreObject.IsAllDayEvent)
                {
                    sourceEntity.ThrowIfPropertyNotSet(sourceEntity.Schema.StartProperty);
                    sourceEntity.ThrowIfPropertyNotSet(sourceEntity.Schema.EndProperty);
                }
            }
            else
            {
                flag = targetStoreObject.IsAllDayEvent;
            }
            if (flag)
            {
                if (sourceEntity.IsPropertySet(sourceEntity.Schema.StartProperty))
                {
                    EventDataProvider.EnforceMidnightTime(sourceEntity.Start, MidnightEnforcementOption.Throw);
                    ExTimeZone exTimeZone;
                    if (sourceEntity.IsPropertySet(sourceEntity.Schema.EndProperty))
                    {
                        EventDataProvider.EnforceMidnightTime(sourceEntity.End, MidnightEnforcementOption.Throw);
                        exTimeZone = sourceEntity.End.TimeZone;
                    }
                    else
                    {
                        exTimeZone = targetStoreObject.EndTimeZone;
                    }
                    if (sourceEntity.Start.TimeZone != exTimeZone)
                    {
                        throw new InvalidRequestException(CalendaringStrings.ErrorAllDayTimeZoneMismatch);
                    }
                }
                else if (sourceEntity.IsPropertySet(sourceEntity.Schema.EndProperty))
                {
                    EventDataProvider.EnforceMidnightTime(sourceEntity.End, MidnightEnforcementOption.Throw);
                    if (sourceEntity.End.TimeZone != targetStoreObject.StartTimeZone)
                    {
                        throw new InvalidRequestException(CalendaringStrings.ErrorAllDayTimeZoneMismatch);
                    }
                }
            }
            base.ValidateChanges(sourceEntity, targetStoreObject);
        }