Example #1
0
        // Token: 0x060005CD RID: 1485 RVA: 0x0002BC64 File Offset: 0x00029E64
        private StoreId SubmitSearch(QueryFilter searchCriteriaFilter)
        {
            StoreId        result         = null;
            MailboxSession mailboxSession = base.MailboxDataForTags.MailboxSession;

            if (searchCriteriaFilter != null)
            {
                if (!mailboxSession.Mailbox.IsContentIndexingEnabled)
                {
                    DiscoveryHoldEnforcer.Tracer.TraceError <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0}: CI search failed on the mailbox {1}. CI is not enabled on the mailbox database", this, mailboxSession.ToString());
                    throw new DiscoveryHoldSearchException(Strings.ErrorDiscoveryHoldsCIIndexDisabledOnDatabase(searchCriteriaFilter.ToString(), mailboxSession.ToString()));
                }
                DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0} : Creating search folder for hold queries for mailbox {1}", this, mailboxSession.ToString());
                using (SearchFolder searchFolder = SearchFolder.Create(mailboxSession, this.discoveryHoldsFolderId, DiscoveryHoldEnforcer.SearchDiscoveryHoldsFolderName, CreateMode.OpenIfExists))
                {
                    searchFolder.Save();
                    searchFolder.Load();
                    result = searchFolder.Id;
                    QueryFilter          searchQuery          = new CountFilter(10000U, searchCriteriaFilter);
                    SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(searchQuery, new StoreId[]
                    {
                        this.discoveryHoldsFolderId
                    });
                    searchFolderCriteria.DeepTraversal               = true;
                    searchFolderCriteria.UseCiForComplexQueries      = true;
                    searchFolderCriteria.FailNonContentIndexedSearch = true;
                    int  num  = 0;
                    bool flag = true;
                    while (flag)
                    {
                        DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string, int>((long)this.GetHashCode(), "{0} : Begin search folder execution for mailbox {1}. Attempt#: {2}", this, mailboxSession.ToString(), num);
                        IAsyncResult asyncResult = searchFolder.BeginApplyOneTimeSearch(searchFolderCriteria, null, null);
                        bool         flag2       = asyncResult.AsyncWaitHandle.WaitOne(60000, false);
                        if (flag2)
                        {
                            DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0} : Search folder execution completed for mailbox {1}", this, mailboxSession.ToString());
                            searchFolder.EndApplyOneTimeSearch(asyncResult);
                            SearchFolderCriteria searchCriteria = searchFolder.GetSearchCriteria();
                            if ((searchCriteria.SearchState & SearchState.FailNonContentIndexedSearch) == SearchState.FailNonContentIndexedSearch && (searchCriteria.SearchState & SearchState.Failed) == SearchState.Failed)
                            {
                                DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0} :  Discovery Hold search failed because CI is not running, search query was not served by CI for mailbox {1}", this, mailboxSession.ToString());
                                throw new DiscoveryHoldSearchException(Strings.ErrorDiscoveryHoldsCIIndexNotRunning(searchCriteriaFilter.ToString(), mailboxSession.ToString()));
                            }
                            flag = false;
                        }
                        else
                        {
                            DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string>((long)this.GetHashCode(), "{0} :  Discovery Hold Search folder execution has timed out for mailbox {1}", this, mailboxSession.ToString());
                            if (num >= 3)
                            {
                                DiscoveryHoldEnforcer.Tracer.TraceDebug <DiscoveryHoldEnforcer, string, int>((long)this.GetHashCode(), "{0} :  Discovery Hold Search folder execution has timed out for mailbox {1} and exceeded max retry count {2}. Give up.", this, mailboxSession.ToString(), 3);
                                throw new DiscoveryHoldSearchException(Strings.ErrorDiscoverySearchTimeout(60.ToString(), searchCriteriaFilter.ToString(), mailboxSession.ToString()));
                            }
                            flag = true;
                            num++;
                        }
                    }
                    searchFolder.Save();
                    searchFolder.Load();
                }
            }
            return(result);
        }
        internal override void ContactLinkingOperation(MailboxSession mailboxSession)
        {
            ContactsEnumerator <IStorePropertyBag> contactsEnumerator = ContactsEnumerator <IStorePropertyBag> .CreateContactsOnlyEnumerator(mailboxSession, DefaultFolderType.AllContacts, RemoveOrganizationalContacts.ContactPropertiesToEnumerate, (IStorePropertyBag propertyBag) => propertyBag, new XSOFactory());

            foreach (IStorePropertyBag storePropertyBag in contactsEnumerator)
            {
                VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                base.PerformanceTracker.IncrementContactsRead();
                if (valueOrDefault != null && RemoveOrganizationalContacts.ShouldDeleteContact(storePropertyBag))
                {
                    try
                    {
                        mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            valueOrDefault.ObjectId
                        });
                        base.PerformanceTracker.IncrementContactsUpdated();
                    }
                    catch (ObjectNotFoundException)
                    {
                        this.WriteWarning(base.GetErrorMessageObjectNotFound(valueOrDefault.ObjectId.ToBase64String(), typeof(Item).ToString(), mailboxSession.ToString()));
                    }
                }
            }
        }
        private void UpdateAllItems(MailboxSession mailboxSession, Predicate <Item> filterCriteria, Action <Item> updateAction)
        {
            ContactsEnumerator <IStorePropertyBag> contactsEnumerator = ContactsEnumerator <IStorePropertyBag> .CreateContactsOnlyEnumerator(mailboxSession, DefaultFolderType.AllContacts, ResetContactLinking.ContactPropertiesToEnumerate, (IStorePropertyBag propertyBag) => propertyBag, new XSOFactory());

            foreach (IStorePropertyBag storePropertyBag in contactsEnumerator)
            {
                VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                base.PerformanceTracker.IncrementContactsRead();
                if (valueOrDefault != null)
                {
                    try
                    {
                        using (Item item = Item.Bind(mailboxSession, valueOrDefault.ObjectId, ResetContactLinking.ContactPropertiesToBind))
                        {
                            if (filterCriteria(item))
                            {
                                updateAction(item);
                                base.PerformanceTracker.IncrementContactsUpdated();
                            }
                        }
                    }
                    catch (ObjectNotFoundException)
                    {
                        this.WriteWarning(base.GetErrorMessageObjectNotFound(valueOrDefault.ObjectId.ToBase64String(), typeof(Item).ToString(), mailboxSession.ToString()));
                    }
                }
            }
        }
Example #4
0
        internal override void ContactLinkingOperation(MailboxSession mailboxSession)
        {
            ContactsEnumerator <IStorePropertyBag> contactsEnumerator = ContactsEnumerator <IStorePropertyBag> .CreateContactsAndPdlsEnumerator(mailboxSession, DefaultFolderType.AllContacts, RepairContactProperties.ContactPropertiesToEnumerate, (IStorePropertyBag propertyBag) => propertyBag, new XSOFactory());

            foreach (IStorePropertyBag storePropertyBag in contactsEnumerator)
            {
                VersionedId valueOrDefault = storePropertyBag.GetValueOrDefault <VersionedId>(ItemSchema.Id, null);
                base.PerformanceTracker.IncrementContactsRead();
                try
                {
                    using (Item item = Item.Bind(mailboxSession, valueOrDefault.ObjectId, RepairContactProperties.ContactPropertiesToBind))
                    {
                        item.OpenAsReadWrite();
                        if (this.FixDisplayName.IsPresent)
                        {
                            RepairContactProperties.TriggerContactDisplayNamePropertyRule(item);
                        }
                        if (this.FixConversationIndexTracking.IsPresent)
                        {
                            RepairContactProperties.TurnOnConversationIndexTracking(item);
                        }
                        if (item.IsDirty)
                        {
                            item.Save(SaveMode.NoConflictResolution);
                            base.PerformanceTracker.IncrementContactsUpdated();
                            if (base.IsVerboseOn)
                            {
                                base.WriteVerbose(RepairContactProperties.FormatContactForVerboseOutput(this.Identity, item));
                            }
                        }
                    }
                }
                catch (ObjectNotFoundException)
                {
                    this.WriteWarning(base.GetErrorMessageObjectNotFound(valueOrDefault.ObjectId.ToBase64String(), typeof(Item).ToString(), mailboxSession.ToString()));
                }
            }
        }