// Token: 0x060008BD RID: 2237 RVA: 0x00040564 File Offset: 0x0003E764
 private void UpdateSearchPerformanceData()
 {
     if (this.omnhParent != null && this.searchNotificationType != SearchNotificationType.None)
     {
         SearchPerformanceData searchPerformanceData = this.omnhParent.SearchPerformanceData;
         if (searchPerformanceData != null)
         {
             searchPerformanceData.NotificationPickedUpByPendingGet(this.searchNotificationType);
             this.searchNotificationType = SearchNotificationType.None;
         }
     }
 }
Пример #2
0
 // Token: 0x06001372 RID: 4978 RVA: 0x00077FC4 File Offset: 0x000761C4
 internal void WriteLog(OwaContext owaContext)
 {
     if (this.RefreshStart >= 0L)
     {
         SearchPerformanceData.WriteIndividualLog(owaContext, this.key + "s", this.RefreshStart);
         this.RefreshStart = -1L;
     }
     if (this.RefreshEnd >= 0L)
     {
         SearchPerformanceData.WriteIndividualLog(owaContext, this.key + "e", this.RefreshEnd);
         this.RefreshEnd = -1L;
     }
 }
Пример #3
0
 // Token: 0x0600136C RID: 4972 RVA: 0x00077EE8 File Offset: 0x000760E8
 internal void WriteLog(OwaContext owaContext)
 {
     if (this.Latency >= 0L)
     {
         SearchPerformanceData.WriteIndividualLog(owaContext, this.key, this.Latency);
         this.Latency = -1L;
     }
     if (this.ItemCount >= 0)
     {
         SearchPerformanceData.WriteIndividualLog(owaContext, this.key + "ic", this.ItemCount);
         this.ItemCount = -1;
     }
     if (this.PendingGetPickup >= 0L)
     {
         SearchPerformanceData.WriteIndividualLog(owaContext, this.key + "pg", this.PendingGetPickup);
         this.PendingGetPickup = -1L;
     }
 }
Пример #4
0
        // Token: 0x06000942 RID: 2370 RVA: 0x000424EC File Offset: 0x000406EC
        public Folder Execute(UserContext userContext, Folder folder, SearchScope searchScope, string searchString, bool newSearch, bool asyncSearch)
        {
            if (userContext == null)
            {
                throw new ArgumentNullException("userContext");
            }
            if (folder == null)
            {
                throw new ArgumentNullException("folder");
            }
            MailboxSession   mailboxSession   = (MailboxSession)folder.Session;
            QueryFilter      queryFilter      = SearchFilterGenerator.Execute(searchString, mailboxSession.Mailbox.IsContentIndexingEnabled, userContext.UserCulture, new PolicyTagMailboxProvider(userContext.MailboxSession), folder, searchScope, this.advancedQueryFilter);
            string           text             = (queryFilter == null) ? string.Empty : queryFilter.ToString();
            OwaStoreObjectId owaStoreObjectId = OwaStoreObjectId.CreateFromStoreObject(folder);
            SearchFolder     searchFolder     = null;
            bool             flag             = false;
            Folder           result;

            try
            {
                if (userContext.SearchFolderId != null)
                {
                    if (!newSearch && userContext.LastSearchFolderId.Equals(owaStoreObjectId) && userContext.LastSearchQueryFilter.CompareTo(text) == 0 && userContext.LastSearchScope == searchScope)
                    {
                        try
                        {
                            searchFolder = SearchFolder.Bind(userContext.SearchFolderId.GetSession(userContext), userContext.SearchFolderId.StoreObjectId, FolderSearch.PrefetchProperties);
                        }
                        catch (ObjectNotFoundException)
                        {
                        }
                        if (searchFolder != null)
                        {
                            if (asyncSearch)
                            {
                                SearchPerformanceData searchPerformanceData = userContext.MapiNotificationManager.GetSearchPerformanceData(mailboxSession);
                                if (searchPerformanceData != null)
                                {
                                    searchPerformanceData.RefreshStart();
                                }
                                OwaContext.Current.SearchPerformanceData = searchPerformanceData;
                            }
                            flag = true;
                            return(searchFolder);
                        }
                    }
                    if (userContext.IsPushNotificationsEnabled)
                    {
                        userContext.MapiNotificationManager.CancelSearchNotifications(mailboxSession);
                        userContext.MapiNotificationManager.AddSearchFolderDeleteList(mailboxSession, userContext.SearchFolderId.StoreObjectId);
                    }
                    else
                    {
                        mailboxSession.Delete(DeleteItemFlags.HardDelete, new StoreId[]
                        {
                            userContext.SearchFolderId.StoreObjectId
                        });
                    }
                    userContext.SearchFolderId = null;
                }
                using (Folder folder2 = Folder.Bind(mailboxSession, userContext.GetSearchFoldersId(mailboxSession).StoreObjectId))
                {
                    searchFolder = SearchFolder.Create(mailboxSession, folder2.Id.ObjectId, "OWA Search " + userContext.Key.UserContextId + " " + DateTime.UtcNow.ToString("o"), CreateMode.CreateNew);
                }
                searchFolder.Save();
                searchFolder.Load(FolderSearch.PrefetchProperties);
                userContext.SearchFolderId        = OwaStoreObjectId.CreateFromStoreObject(searchFolder);
                userContext.LastSearchFolderId    = owaStoreObjectId;
                userContext.LastSearchQueryFilter = text;
                userContext.LastSearchScope       = searchScope;
                if (queryFilter == null)
                {
                    flag   = true;
                    result = searchFolder;
                }
                else
                {
                    bool      flag2 = FolderSearch.FailNonContentIndexedSearch(folder, queryFilter);
                    bool      flag3;
                    StoreId[] folderScope;
                    if (searchScope == SearchScope.SelectedFolder || !mailboxSession.Mailbox.IsContentIndexingEnabled)
                    {
                        flag3       = false;
                        folderScope = new StoreId[]
                        {
                            folder.Id.ObjectId
                        };
                    }
                    else if (searchScope == SearchScope.SelectedAndSubfolders)
                    {
                        flag3       = true;
                        folderScope = new StoreId[]
                        {
                            folder.Id.ObjectId
                        };
                    }
                    else
                    {
                        if (searchScope != SearchScope.AllFoldersAndItems && searchScope != SearchScope.AllItemsInModule)
                        {
                            throw new ArgumentOutOfRangeException();
                        }
                        flag3       = true;
                        folderScope = new StoreId[]
                        {
                            userContext.GetRootFolderId(mailboxSession)
                        };
                    }
                    if (searchScope != SearchScope.SelectedFolder)
                    {
                        if (!folder.Id.ObjectId.Equals(userContext.JunkEmailFolderId))
                        {
                            QueryFilter queryFilter2 = new ComparisonFilter(ComparisonOperator.NotEqual, StoreObjectSchema.ParentItemId, userContext.JunkEmailFolderId);
                            queryFilter = new AndFilter(new QueryFilter[]
                            {
                                queryFilter,
                                queryFilter2
                            });
                        }
                        StoreObjectId storeObjectId = userContext.GetDeletedItemsFolderId((MailboxSession)folder.Session).StoreObjectId;
                        if (!folder.Id.ObjectId.Equals(storeObjectId))
                        {
                            QueryFilter queryFilter3 = new ComparisonFilter(ComparisonOperator.NotEqual, StoreObjectSchema.ParentItemId, storeObjectId);
                            queryFilter = new AndFilter(new QueryFilter[]
                            {
                                queryFilter,
                                queryFilter3
                            });
                        }
                    }
                    ExTraceGlobals.MailDataTracer.TraceDebug((long)this.GetHashCode(), "Search\nFilter: {0}\nDeep Traversal: {1}\nFolder: {2}\nContent Indexing Enabled: {3}", new object[]
                    {
                        queryFilter,
                        flag3,
                        folder.Id,
                        mailboxSession.Mailbox.IsContentIndexingEnabled ? "Yes" : "No"
                    });
                    SearchFolderCriteria searchFolderCriteria = new SearchFolderCriteria(queryFilter, folderScope);
                    searchFolderCriteria.DeepTraversal               = flag3;
                    searchFolderCriteria.MaximumResultsCount         = new int?(1000);
                    searchFolderCriteria.FailNonContentIndexedSearch = flag2;
                    SearchPerformanceData searchPerformanceData;
                    if (!userContext.IsPushNotificationsEnabled || !asyncSearch)
                    {
                        searchPerformanceData = new SearchPerformanceData();
                        searchPerformanceData.StartSearch(searchString);
                        IAsyncResult asyncResult = searchFolder.BeginApplyOneTimeSearch(searchFolderCriteria, null, null);
                        Stopwatch    stopwatch   = Utilities.StartWatch();
                        bool         flag4       = asyncResult.AsyncWaitHandle.WaitOne(30000, false);
                        searchPerformanceData.Complete(!flag4, true);
                        if (flag4)
                        {
                            searchFolder.EndApplyOneTimeSearch(asyncResult);
                        }
                        else
                        {
                            ExTraceGlobals.MailTracer.TraceDebug((long)this.GetHashCode(), "FolderSearch.Execute. Search timed out.");
                            if (Globals.ArePerfCountersEnabled)
                            {
                                OwaSingleCounters.SearchesTimedOut.Increment();
                            }
                        }
                        Utilities.StopWatch(stopwatch, "FolderSearch.Execute (Wait for search to complete)");
                        if (Globals.ArePerfCountersEnabled)
                        {
                            PerformanceCounterManager.UpdateSearchTimePerformanceCounter(stopwatch.ElapsedMilliseconds);
                            OwaSingleCounters.TotalSearches.Increment();
                        }
                        searchFolder.Save();
                        searchFolder.Load(FolderSearch.PrefetchProperties);
                    }
                    else
                    {
                        userContext.MapiNotificationManager.InitSearchNotifications(mailboxSession, userContext.SearchFolderId.StoreObjectId, searchFolder, searchFolderCriteria, searchString);
                        searchPerformanceData = userContext.MapiNotificationManager.GetSearchPerformanceData(mailboxSession);
                    }
                    if (!flag2)
                    {
                        searchPerformanceData.SlowSearchEnabled();
                    }
                    OwaContext.Current.SearchPerformanceData = searchPerformanceData;
                    flag   = true;
                    result = searchFolder;
                }
            }
            finally
            {
                if (!flag && searchFolder != null)
                {
                    searchFolder.Dispose();
                }
            }
            return(result);
        }
Пример #5
0
        // Token: 0x06001362 RID: 4962 RVA: 0x00077CAC File Offset: 0x00075EAC
        internal void WriteLog()
        {
            OwaContext owaContext = OwaContext.Current;

            if (owaContext == null)
            {
                throw new InvalidOperationException("OwaContext.Current is null. SearchPerformanceData.WriteLog should be called in the context of a request.");
            }
            SearchPerformanceData.WriteIndividualLog(owaContext, "srchid", this.searchId);
            if (Globals.CollectSearchStrings && this.searchString != null)
            {
                SearchPerformanceData.WriteIndividualLog(owaContext, "srchstr", this.searchString);
                this.searchString = null;
            }
            if (this.refreshLatency != null)
            {
                this.refreshLatency.WriteLog(owaContext);
            }
            if (this.firstPageLatency != null)
            {
                this.firstPageLatency.WriteLog(owaContext);
            }
            if (this.completeLatency != null)
            {
                this.completeLatency.WriteLog(owaContext);
            }
            if (this.completeLatency.Latency >= 0L)
            {
                if (this.isTimeout)
                {
                    SearchPerformanceData.WriteIndividualLog(owaContext, "srchto", 1);
                    this.isTimeout = false;
                }
                if (this.isSync)
                {
                    SearchPerformanceData.WriteIndividualLog(owaContext, "srchsync", 1);
                    this.isSync = false;
                }
            }
            if (this.searchFailed)
            {
                SearchPerformanceData.WriteIndividualLog(owaContext, "srchfl", "1");
            }
            if (this.slowSearchEnabled)
            {
                SearchPerformanceData.WriteIndividualLog(owaContext, "srchslowenabled", "1");
            }
            if (this.writeSearchFolderData)
            {
                SearchState searchState      = SearchState.None;
                int         num              = -1;
                bool        flag             = false;
                bool        searchFolderData = SearchPerformanceData.GetSearchFolderData(owaContext.UserContext, out num, out searchState, out flag);
                if (searchFolderData)
                {
                    SearchPerformanceData.WriteIndividualLog(owaContext, "srchsess", flag);
                }
                if (searchState != SearchState.None)
                {
                    SearchPerformanceData.WriteIndividualLog(owaContext, "srchstate", string.Format(NumberFormatInfo.InvariantInfo, "0x{0:X8}", new object[]
                    {
                        (int)searchState
                    }));
                }
                if (num != -1)
                {
                    SearchPerformanceData.WriteIndividualLog(owaContext, "srchcount", num);
                }
                this.writeSearchFolderData = false;
            }
        }