Ejemplo n.º 1
0
        private void AreResultsConsistentWithReferenceItem()
        {
            if (this.pagingInfo == null || this.pagingInfo.SortValue == null || this.resultRows.Length == 0)
            {
                return;
            }
            Guid          mailboxGuid   = this.resultRows[0].MailboxGuid;
            ReferenceItem referenceItem = (this.pagingInfo.Direction == PageDirection.Previous) ? this.resultRows[this.resultRows.Length - 1].SortValue : this.resultRows[0].SortValue;
            int           num           = referenceItem.CompareTo(this.pagingInfo.SortValue);

            if (num > 0 && (this.pagingInfo.Direction == PageDirection.Next || this.pagingInfo.AscendingSort) && (this.pagingInfo.Direction == PageDirection.Previous || !this.pagingInfo.AscendingSort))
            {
                this.PublishToLogAndThrowArgumentException(referenceItem, mailboxGuid);
            }
            if (num < 0 && (this.pagingInfo.Direction == PageDirection.Previous || this.pagingInfo.AscendingSort) && (this.pagingInfo.Direction == PageDirection.Next || !this.pagingInfo.AscendingSort))
            {
                this.PublishToLogAndThrowArgumentException(referenceItem, mailboxGuid);
            }
        }
Ejemplo n.º 2
0
        private void PublishToLogAndThrowArgumentException(ReferenceItem sortValue, Guid mailboxGuid)
        {
            string text = Strings.InconsistentSortedResults(mailboxGuid.ToString(), this.pagingInfo.SortValue.ToString(), sortValue.ToString());

            EventNotificationItem.Publish(ExchangeComponent.EdiscoveryProtocol.Name, "MailboxSearch.InconsistentItemReferenceErrorMonitor", null, text, ResultSeverityLevel.Error, false);
            throw new ArgumentException(text)
                  {
                      Data =
                      {
                          {
                              "SortOrder",
                              this.pagingInfo.AscendingSort ? "Ascending" : "Descending"
                          },
                          {
                              "PageDirection",
                              (this.pagingInfo.Direction == PageDirection.Next) ? "Next" : "Previous"
                          }
                      }
                  };
        }
Ejemplo n.º 3
0
        public int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }
            ReferenceItem referenceItem = obj as ReferenceItem;

            if (referenceItem == null)
            {
                throw new ArgumentException("Object is not a ReferenceItem");
            }
            if (!this.SortBy.ColumnDefinition.Equals(referenceItem.SortBy.ColumnDefinition))
            {
                throw new ArgumentException("Cannot compare two reference items with different sort columns");
            }
            if (this.SortBy.SortOrder != referenceItem.SortBy.SortOrder)
            {
                throw new ArgumentException("Cannot compare two reference items with different sort order");
            }
            if (this.SortColumnValue == null && referenceItem.SortColumnValue != null)
            {
                return(-1);
            }
            if (this.SortColumnValue != null && referenceItem.SortColumnValue == null)
            {
                return(1);
            }
            if (this.SortColumnValue.Equals(referenceItem.SortColumnValue))
            {
                return(this.SecondarySortValue.CompareTo(referenceItem.SecondarySortValue));
            }
            IComparable comparable = this.SortColumnValue as IComparable;
            IComparable obj2       = referenceItem.SortColumnValue as IComparable;

            return(comparable.CompareTo(obj2));
        }
Ejemplo n.º 4
0
 public PagingInfo(List <PropertyDefinition> data, SortBy sort, int pageSize, PageDirection direction, ReferenceItem referenceItem, ExTimeZone timeZone, bool excludeDuplicatesItems, PreviewItemBaseShape baseShape, List <ExtendedPropertyInfo> additionalProperties)
 {
     Util.ThrowOnNull(data, "data");
     Util.ThrowOnNull(sort, "sort");
     if (pageSize == 0)
     {
         throw new ArgumentException("Page size cannot be 0");
     }
     if (referenceItem == null && direction == PageDirection.Previous)
     {
         throw new ArgumentException("PagingInfo: Have to provide sort column value to view previous page");
     }
     if (!PagingInfo.ValidateDataColumns(data))
     {
         throw new ArgumentException("PagingInfo: Invalid data columns");
     }
     this.originalDataColumns = data;
     this.dataColumns         = new List <PropertyDefinition>(data);
     this.sort                  = sort;
     this.referenceItem         = referenceItem;
     this.direction             = direction;
     this.pageSize              = pageSize;
     this.timeZone              = timeZone;
     this.excludeDuplicateItems = excludeDuplicatesItems;
     this.baseShape             = baseShape;
     this.additionalProperties  = additionalProperties;
     if (!this.originalDataColumns.Contains(sort.ColumnDefinition))
     {
         this.dataColumns.Add(sort.ColumnDefinition);
     }
     foreach (PropertyDefinition item in PagingInfo.RequiredDataPropertiesFromStore)
     {
         if (!this.originalDataColumns.Contains(item))
         {
             this.dataColumns.Add(item);
         }
     }
     if (this.additionalProperties != null)
     {
         foreach (ExtendedPropertyInfo extendedPropertyInfo in this.additionalProperties)
         {
             if (extendedPropertyInfo.XsoPropertyDefinition != null && !this.dataColumns.Contains(extendedPropertyInfo.XsoPropertyDefinition))
             {
                 this.dataColumns.Add(extendedPropertyInfo.XsoPropertyDefinition);
             }
         }
     }
     this.sorts = new SortBy[]
     {
         sort,
         new SortBy(ItemSchema.DocumentId, SortOrder.Ascending)
     };
 }
Ejemplo n.º 5
0
 public PagingInfo(List <PropertyDefinition> data, SortBy sort, int pageSize, PageDirection direction, ReferenceItem referenceItem, ExTimeZone timeZone, bool excludeDuplicatesItems) : this(data, sort, pageSize, direction, referenceItem, timeZone, excludeDuplicatesItems, PreviewItemBaseShape.Default, null)
 {
 }
Ejemplo n.º 6
0
 public PagingInfo(List <PropertyDefinition> data, SortBy sort, int pageSize, PageDirection direction, ReferenceItem referenceItem, ExTimeZone timeZone) : this(data, sort, pageSize, direction, referenceItem, timeZone, false)
 {
 }
Ejemplo n.º 7
0
        public override bool Equals(object obj)
        {
            ReferenceItem referenceItem = obj as ReferenceItem;

            return(referenceItem != null && this.SortBy.ColumnDefinition.Equals(referenceItem.SortBy.ColumnDefinition) && this.SortBy.SortOrder == referenceItem.SortBy.SortOrder && this.SortColumnValue.Equals(referenceItem.SortColumnValue) && this.SecondarySortValue == referenceItem.SecondarySortValue);
        }
Ejemplo n.º 8
0
 public PreviewItem(Dictionary <PropertyDefinition, object> properties, Guid mailboxGuid, Uri owaLink, ReferenceItem sortValue, UniqueItemHash itemHash, List <PropertyDefinition> additionalProperties) : base(properties)
 {
     Util.ThrowOnNull(sortValue, "sortValue");
     if (mailboxGuid == Guid.Empty)
     {
         throw new ArgumentException("Invalid mailbox guid");
     }
     this.owaLink     = owaLink;
     this.sortValue   = sortValue;
     this.mailboxGuid = mailboxGuid;
     this.itemHash    = itemHash;
     this.additionalPropertyValues = Util.GetSelectedAdditionalPropertyValues(properties, additionalProperties);
 }
Ejemplo n.º 9
0
 public PreviewItem(Dictionary <PropertyDefinition, object> properties, Guid mailboxGuid, Uri owaLink, ReferenceItem sortValue, UniqueItemHash itemHash) : this(properties, mailboxGuid, owaLink, sortValue, itemHash, null)
 {
 }
Ejemplo n.º 10
0
        private static PreviewItem[] InternalCreateSearchPreviewItems(MailboxInfo mailboxInfo, object[][] rows, PagingInfo pagingInfo, StoreSession mailboxSession, List <KeyValuePair <int, long> > messageIdPairs, bool usingSearchFolders)
        {
            if (!usingSearchFolders)
            {
                Util.ThrowOnNull(messageIdPairs, "messageIdPairs");
            }
            if (rows.Length == 0 || rows[0].Length != pagingInfo.DataColumns.Count)
            {
                throw new ArgumentException("Invalid result rows");
            }
            List <PreviewItem> list = new List <PreviewItem>(rows.Length);
            StoreId            sentItemsFolderId = null;

            if (!mailboxSession.IsPublicFolderSession)
            {
                sentItemsFolderId = mailboxSession.GetDefaultFolderId(DefaultFolderType.SentItems);
            }
            Uri owaMailboxItemLink = LinkUtils.GetOwaMailboxItemLink(delegate
            {
            }, mailboxInfo, true);

            for (int i = 0; i < rows.Length; i++)
            {
                object[] array = rows[i];
                Dictionary <PropertyDefinition, object> properties = new Dictionary <PropertyDefinition, object>(4);
                int num = 0;
                foreach (PropertyDefinition key in pagingInfo.DataColumns)
                {
                    properties.Add(key, array[num]);
                    num++;
                }
                ReferenceItem sortValue = null;
                if (!usingSearchFolders)
                {
                    sortValue = new ReferenceItem(pagingInfo.SortBy, properties[pagingInfo.SortColumn], messageIdPairs.Find((KeyValuePair <int, long> x) => x.Key == (int)properties[ItemSchema.DocumentId]).Value);
                }
                else
                {
                    sortValue = new ReferenceItem(pagingInfo.SortBy, properties[pagingInfo.SortColumn], (long)mailboxSession.MailboxGuid.GetHashCode() << 32 | (long)((ulong)((int)properties[ItemSchema.DocumentId])));
                }
                List <PropertyDefinition> list2 = null;
                if (pagingInfo.AdditionalProperties != null && pagingInfo.AdditionalProperties.Count > 0)
                {
                    list2 = new List <PropertyDefinition>(pagingInfo.AdditionalProperties.Count);
                    foreach (ExtendedPropertyInfo extendedPropertyInfo in pagingInfo.AdditionalProperties)
                    {
                        list2.Add(extendedPropertyInfo.XsoPropertyDefinition);
                    }
                }
                PreviewItem item = new PreviewItem(properties, mailboxInfo.MailboxGuid, owaMailboxItemLink, sortValue, Util.CalculateUniqueItemHash(mailboxSession, array, pagingInfo, sentItemsFolderId), list2)
                {
                    MailboxInfo = mailboxInfo
                };
                list.Add(item);
            }
            PreviewItem[] array2 = list.ToArray();
            if (pagingInfo.ExcludeDuplicates)
            {
                array2 = Util.ExcludeDuplicateItems(array2);
            }
            return(array2);
        }