Exemple #1
0
        private MessageSearcher CreateMessageSearcher(SearchTestResult result)
        {
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            Exception       ex      = null;
            MessageSearcher result2 = null;

            try
            {
                this.monitor.AddMonitoringEvent(result, Strings.TestSearchGetMapiStore(result.Mailbox));
                MapiStore mapiStore = MapiStore.OpenMailbox(result.Server, result.UserLegacyExchangeDN, result.MailboxGuid, result.DatabaseGuid, null, null, null, ConnectFlag.UseAdminPrivilege | ConnectFlag.UseSeparateConnection, OpenStoreFlag.UseAdminPrivilege | OpenStoreFlag.TakeOwnership | OpenStoreFlag.MailboxGuid, CultureInfo.InvariantCulture, null, "Client=Management;Action=Test-Search", null);
                if (mapiStore != null)
                {
                    result2 = new MessageSearcher(mapiStore, result, this.monitor, this.threadExit);
                }
                else
                {
                    result.SetErrorTestResult(EventId.MapiStoreError, Strings.TestSearchMapiStoreError(result.Mailbox, result.Database));
                }
            }
            catch (ADTransientException ex2)
            {
                ex = ex2;
            }
            catch (ADExternalException ex3)
            {
                ex = ex3;
            }
            catch (MapiExceptionNotFound mapiExceptionNotFound)
            {
                ex = mapiExceptionNotFound;
            }
            catch (MapiPermanentException ex4)
            {
                ex = ex4;
            }
            catch (MapiRetryableException ex5)
            {
                ex = ex5;
            }
            finally
            {
                if (ex is ADTransientException || ex is ADExternalException)
                {
                    result.SetErrorTestResult(EventId.ADError, Strings.TestSearchADError(ex.Message));
                }
                if (ex is MapiExceptionNotFound || ex is MapiPermanentException || ex is MapiRetryableException)
                {
                    this.HandleExceptionInTestThread(result.DatabaseGuid, EventId.MapiError, result, ex);
                }
            }
            return(result2);
        }
Exemple #2
0
 private void CreateAndSearchMessages()
 {
     lock (this.resultsLock)
     {
         foreach (SearchTestResult result in this.searchTestResults)
         {
             using (MessageSearcher messageSearcher = this.CreateMessageSearcher(result))
             {
                 if (messageSearcher != null)
                 {
                     this.SearchForMessage(messageSearcher, result);
                 }
             }
         }
     }
 }
Exemple #3
0
        private void SearchForMessage(MessageSearcher messageSearcher, SearchTestResult result)
        {
            if (messageSearcher == null)
            {
                throw new ArgumentNullException("messageSearcher");
            }
            if (result == null)
            {
                throw new ArgumentNullException("result");
            }
            TimeSpan  timeout = new TimeSpan(0, 0, 1);
            DateTime  utcNow  = DateTime.UtcNow;
            Exception ex      = null;

            try
            {
                this.threadExit.CheckStop();
                messageSearcher.InitializeSearch();
                bool flag      = false;
                int  tickCount = Environment.TickCount;
                while (!flag)
                {
                    this.threadExit.CheckStop();
                    try
                    {
                        flag = messageSearcher.DoSearch();
                        int tickCount2 = Environment.TickCount;
                        if (flag)
                        {
                            result.SetTestResult(true, new TimeSpan((long)((tickCount2 - tickCount) * 10000)).TotalSeconds);
                        }
                    }
                    catch (MapiRetryableException exception)
                    {
                        this.monitor.PushMessage(SearchCommon.DiagnoseException(result.Server, result.DatabaseGuid, exception));
                    }
                    this.threadExit.CheckStop();
                    if (!flag)
                    {
                        Thread.Sleep(timeout);
                    }
                }
            }
            catch (MapiExceptionNotFound mapiExceptionNotFound)
            {
                ex = mapiExceptionNotFound;
            }
            catch (MapiRetryableException ex2)
            {
                ex = ex2;
            }
            catch (MapiPermanentException ex3)
            {
                ex = ex3;
            }
            catch (TestSearchOperationAbortedException)
            {
                TestSearch.TestSearchTracer.TraceDebug((long)this.GetHashCode(), "Thread terminated on TestSearchOperationAbortedException");
                this.monitor.PushMessage(Strings.TestSearchTestThreadTimeOut);
                result.SetErrorTestResultWithTestThreadTimeOut();
            }
            finally
            {
                if (ex != null)
                {
                    this.HandleExceptionInTestThread(result.DatabaseGuid, EventId.MapiError, result, ex);
                }
            }
        }