Exemplo 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;
        }
Exemplo n.º 2
0
        private static SortBy[] CreateSortOrderForSeriesSearch(Microsoft.Exchange.Data.PropertyDefinition identityProperty, SortBy additionalSortBy)
        {
            List <SortBy> list = new List <SortBy>(2)
            {
                new SortBy(identityProperty, SortOrder.Ascending)
            };

            if (additionalSortBy != null)
            {
                list.Add(additionalSortBy);
            }
            return(list.ToArray());
        }
Exemplo n.º 3
0
 private static bool IsSeriesIdMatching(string seriesId, IStorePropertyBag rowPropertyBag, Microsoft.Exchange.Data.PropertyDefinition identityProperty)
 {
     return(string.Equals(rowPropertyBag.GetValueOrDefault <string>(identityProperty, null), seriesId, StringComparison.OrdinalIgnoreCase));
 }
Exemplo n.º 4
0
        private static ComparisonFilter CreateComparisonFilterForSeriesSearch(Event entity, Microsoft.Exchange.Data.PropertyDefinition identityProperty)
        {
            ComparisonFilter result;

            if (identityProperty.Equals(CalendarItemBaseSchema.SeriesId))
            {
                result = new ComparisonFilter(ComparisonOperator.Equal, CalendarItemBaseSchema.SeriesId, entity.SeriesId);
            }
            else
            {
                if (!identityProperty.Equals(CalendarItemBaseSchema.EventClientId))
                {
                    throw new ArgumentOutOfRangeException("identityProperty");
                }
                result = new ComparisonFilter(ComparisonOperator.Equal, CalendarItemBaseSchema.EventClientId, entity.ClientId);
            }
            return(result);
        }
Exemplo n.º 5
0
 public bool ForEachSeriesItem(Event theEvent, Func <Event, bool> instanceAction, Func <IStorePropertyBag, Event> convertToEvent, Action <Event> seriesAction = null, SortBy sortOrder = null, Microsoft.Exchange.Data.PropertyDefinition identityProperty = null, params Microsoft.Exchange.Data.PropertyDefinition[] additionalPropertiesToQuery)
 {
     if (theEvent.Type != EventType.SeriesMaster)
     {
         throw new InvalidOperationException("You can only call this method for a series master");
     }
     foreach (Event @event in this.GetSeriesEventsData(theEvent, identityProperty, convertToEvent, sortOrder, additionalPropertiesToQuery))
     {
         if (@event.Type == EventType.SeriesMaster)
         {
             if (seriesAction != null)
             {
                 seriesAction(@event);
             }
         }
         else if (instanceAction != null && !instanceAction(@event))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 6
0
        internal bool TryGetPropertyFromPropertyIndices(IDictionary <Microsoft.Exchange.Data.PropertyDefinition, int> propertyIndices, IList values, Microsoft.Exchange.Data.PropertyDefinition property, out object value)
        {
            int    index;
            object obj;

            if (propertyIndices.TryGetValue(property, out index) && (obj = values[index]) != null && obj.GetType() == property.Type)
            {
                value = obj;
                return(true);
            }
            value = null;
            return(false);
        }
Exemplo n.º 7
0
 public override SinglePropertyFilter CloneWithAnotherProperty(PropertyDefinition property)
 {
     base.CheckClonable(property);
     return(new TextFilter(property, this.text, base.MatchOptions, base.MatchFlags));
 }
Exemplo n.º 8
0
 public TextFilter(PropertyDefinition property, string text, MatchOptions matchOptions, MatchFlags matchFlags) : base(property, matchOptions, matchFlags)
 {
     this.text = text;
 }
Exemplo n.º 9
0
 public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag)
 {
     return(this.Delegate(value, propertyDefinition, propertyBag, this));
 }
        public override PropertyConstraintViolationError Validate(object value, PropertyDefinition propertyDefinition, IPropertyBag propertyBag)
        {
            string text = (string)value;

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }
            if (text.Length > this.maxLength)
            {
                return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBeyondRange(this.maxLength.ToString()), propertyDefinition, value, this));
            }
            int num = 0;

            if (!int.TryParse(text, out num))
            {
                char[] separator = new char[]
                {
                    this.pairDelimiter
                };
                char[] separator2 = new char[]
                {
                    this.extensionValueDelimiter
                };
                string[] array  = text.Split(separator);
                string[] array2 = array;
                int      i      = 0;
                while (i < array2.Length)
                {
                    string   text2  = array2[i];
                    string[] array3 = text2.Split(separator2);
                    PropertyConstraintViolationError result;
                    if (array3.Length != 2)
                    {
                        result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this);
                    }
                    else if (array3[0].Length == 0)
                    {
                        result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this);
                    }
                    else
                    {
                        int num2 = 0;
                        if (!int.TryParse(array3[1], out num2))
                        {
                            result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationMalformedExtensionValuePair(text2), propertyDefinition, value, this);
                        }
                        else
                        {
                            if (num2 >= this.minValue && num2 <= this.maxValue)
                            {
                                i++;
                                continue;
                            }
                            result = new PropertyConstraintViolationError(DataStrings.ConstraintViolationValueOutOfRange(this.minValue.ToString(), this.maxValue.ToString(), num2.ToString()), propertyDefinition, value, this);
                        }
                    }
                    return(result);
                }
                return(null);
            }
            if (num < this.minValue)
            {
                return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBelowRange(this.minValue.ToString()), propertyDefinition, value, this));
            }
            if (num > this.maxValue)
            {
                return(new PropertyConstraintViolationError(DataStrings.ConstraintViolationObjectIsBeyondRange(this.maxValue.ToString()), propertyDefinition, value, this));
            }
            return(null);
        }
Exemplo n.º 11
0
 public MultivaluedInstanceComparisonFilter(ComparisonOperator comparisonOperator, PropertyDefinition property, object propertyValue) : base(comparisonOperator, property, propertyValue)
 {
 }
Exemplo n.º 12
0
 public ExistsFilter(PropertyDefinition property) : base(property)
 {
 }
Exemplo n.º 13
0
 public override SinglePropertyFilter CloneWithAnotherProperty(PropertyDefinition property)
 {
     base.CheckClonable(property);
     return(new ExistsFilter(property));
 }