internal static void Execute(IMailboxContext userContext, string eventId, Action <MailboxSession, IRecipientSession, RequestDetailsLogger> action)
 {
     SimulatedWebRequestContext.Execute(userContext, eventId, delegate(RequestDetailsLogger logger)
     {
         ExchangePrincipal exchangePrincipal = userContext.ExchangePrincipal;
         if (exchangePrincipal == null)
         {
             return;
         }
         IRecipientSession arg = InstantMessageUtilities.CreateADRecipientSession(ConsistencyMode.IgnoreInvalid, exchangePrincipal, userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN);
         try
         {
             userContext.LockAndReconnectMailboxSession(3000);
             MailboxSession mailboxSession = userContext.MailboxSession;
             action(mailboxSession, arg, logger);
         }
         catch (OwaLockTimeoutException exception)
         {
             SimulatedWebRequestContext.ProcessException(logger, eventId, exception);
         }
         finally
         {
             if (userContext.MailboxSessionLockedByCurrentThread())
             {
                 userContext.UnlockAndDisconnectMailboxSession();
             }
         }
     });
 }
 private static void FillItemDataInPayload(IMailboxContext userContext, OwaSearchContext searchContext, SearchNotificationPayload payload)
 {
     try
     {
         userContext.LockAndReconnectMailboxSession(3000);
         int serverSearchResultsRowCount = 0;
         if (searchContext.SearchContextType == SearchContextType.ItemSearch)
         {
             payload.MessageItems = SearchFolderItemDataRetriever.GetItemDataFromSearchFolder(searchContext, userContext.MailboxSession, out serverSearchResultsRowCount);
         }
         else if (searchContext.SearchContextType == SearchContextType.ConversationSearch)
         {
             payload.Conversations = SearchFolderConversationRetriever.GetConversationDataFromSearchFolder(searchContext, userContext.MailboxSession, out serverSearchResultsRowCount);
         }
         payload.ServerSearchResultsRowCount = serverSearchResultsRowCount;
     }
     catch (OwaLockTimeoutException ex)
     {
         ExTraceGlobals.CoreCallTracer.TraceError <string>(0L, "User context lock timed out in FillItemDataInPayload. Exception: {0}", ex.Message);
     }
     finally
     {
         if (userContext.MailboxSessionLockedByCurrentThread())
         {
             userContext.UnlockAndDisconnectMailboxSession();
         }
     }
 }
        internal static void DisposeXSOObjects(object o, IMailboxContext userContext)
        {
            bool flag = false;

            try
            {
                if (!userContext.MailboxSessionLockedByCurrentThread())
                {
                    ExTraceGlobals.UserContextTracer.TraceDebug(0, 0L, "MapiNotificationHandlerBase.DisposeXSOObjects(): Mailbox session not locked. Attempting to grab the lock.");
                    userContext.LockAndReconnectMailboxSession(3000);
                    flag = true;
                }
                IDisposable xsoObject = o as IDisposable;
                if (o != null)
                {
                    try
                    {
                        OwaDiagnostics.SendWatsonReportsForGrayExceptions(delegate()
                        {
                            try
                            {
                                xsoObject.Dispose();
                            }
                            catch (StoragePermanentException ex2)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase. Unable to dispose object.  exception {0}", ex2.Message);
                            }
                            catch (StorageTransientException ex3)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase. Unable to dispose object.  exception {0}", ex3.Message);
                            }
                            catch (MapiExceptionObjectDisposed mapiExceptionObjectDisposed)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.Unable to dispose object.  exception {0}", mapiExceptionObjectDisposed.Message);
                            }
                            catch (ThreadAbortException ex4)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase Unable to dispose object.  exception {0}", ex4.Message);
                            }
                            catch (ResourceUnhealthyException ex5)
                            {
                                ExTraceGlobals.UserContextTracer.TraceError <string>(0L, "MapiNotificationHandlerBase Unable to dispose object.  exception {0}", ex5.Message);
                            }
                        });
                    }
                    catch (GrayException ex)
                    {
                        ExTraceGlobals.NotificationsCallTracer.TraceError <string>(0L, "MapiNotificationHandlerBase.DisposeXSOObjects Unable to dispose object.  exception {0}", ex.Message);
                    }
                }
            }
            finally
            {
                if (flag)
                {
                    ExTraceGlobals.UserContextTracer.TraceDebug(0, 0L, "MapiNotificationHandlerBase.DisposeXSOObjects(): Attempting to release the lock taken.");
                    userContext.UnlockAndDisconnectMailboxSession();
                }
            }
        }
Пример #4
0
 // Token: 0x06001BD9 RID: 7129 RVA: 0x0006BF04 File Offset: 0x0006A104
 private void CreateSubscriptionForWellKnownFolder(IMailboxContext userContext, SubscriptionData subscription, DefaultFolderType folderType)
 {
     try
     {
         userContext.LockAndReconnectMailboxSession(3000);
         StoreObjectId defaultFolderId = userContext.MailboxSession.GetDefaultFolderId(folderType);
         subscription.Parameters.FolderId = StoreId.StoreIdToEwsId(userContext.MailboxSession.MailboxGuid, defaultFolderId);
     }
     finally
     {
         if (userContext.MailboxSessionLockedByCurrentThread())
         {
             userContext.UnlockAndDisconnectMailboxSession();
         }
     }
     base.InternalCreateASubscription(userContext, subscription, true);
 }