internal IAsyncResult BeginGetMailTipsInBatches(RecipientInfo[] recipientsInfo, RecipientInfo senderInfo, bool doesNeedConfig, AsyncCallback asyncCallback, object asyncCallbackData)
        {
            this.primarySmtpAddress = this.userContext.ExchangePrincipal.MailboxInfo.PrimarySmtpAddress.ToString();
            ClientSecurityContext clientSecurityContext = this.userContext.LogonIdentity.ClientSecurityContext.Clone();
            string         weekdayDateTimeFormat        = this.userContext.UserOptions.GetWeekdayDateTimeFormat(true);
            MailTipsState  mailTipsState  = new MailTipsState(recipientsInfo, senderInfo, doesNeedConfig, this.userContext.ExchangePrincipal.LegacyDn, this.primarySmtpAddress, clientSecurityContext, this.userContext.TimeZone, this.userContext.UserCulture, this.userContext.ExchangePrincipal.MailboxInfo.OrganizationId, this.userContext.MailboxIdentity.GetOWAMiniRecipient().QueryBaseDN, this.userContext.UserOptions.HideMailTipsByDefault, this.userContext.PendingRequestManager, Query <IEnumerable <MailTips> > .GetCurrentHttpRequestServerName(), weekdayDateTimeFormat);
            OwaAsyncResult owaAsyncResult = new OwaAsyncResult(asyncCallback, asyncCallbackData);

            Interlocked.Increment(ref this.concurrentRequestCount);
            if (3 >= this.concurrentRequestCount)
            {
                ExTraceGlobals.CoreCallTracer.TraceError <int, string>((long)this.GetHashCode(), "MailTipsNotificationHandler.BeginGetMailTipsInBatches, serving concurrent request {0} for {1}", this.concurrentRequestCount, this.primarySmtpAddress);
                ThreadPool.QueueUserWorkItem(new WaitCallback(this.GetMailTipsWorker), mailTipsState);
                return(owaAsyncResult);
            }
            IAsyncResult result;

            try
            {
                ExTraceGlobals.CoreCallTracer.TraceError <int>((long)this.GetHashCode(), "MailTipsNotificationHandler.BeginGetMailTipsInBatches, maximum concurrent request limit {0} has been reached", 3);
                MailTipsNotificationHandler.PopulateException(mailTipsState, new OwaMaxConcurrentRequestsExceededException("Maximum MailTips concurrent requests exceeded"), this.GetHashCode());
                this.mailTipsNotifier.AddToPayload(mailTipsState);
                this.mailTipsNotifier.PickupData();
                result = owaAsyncResult;
            }
            finally
            {
                Interlocked.Decrement(ref this.concurrentRequestCount);
            }
            return(result);
        }
Example #2
0
        // Token: 0x060011A9 RID: 4521 RVA: 0x0006A924 File Offset: 0x00068B24
        private void UseNotificationPipeCallback(IAsyncResult async)
        {
            OwaAsyncResult owaAsyncResult = (OwaAsyncResult)async;

            try
            {
                this.pendingManager.EndSendNotification(owaAsyncResult);
            }
            catch (Exception exception)
            {
                lock (this.asyncResult)
                {
                    if (!this.asyncResult.IsCompleted)
                    {
                        this.asyncResult.Exception = exception;
                    }
                }
            }
            try
            {
                lock (this.asyncResult)
                {
                    if (!this.asyncResult.IsCompleted)
                    {
                        this.asyncResult.CompleteRequest(owaAsyncResult.CompletedSynchronously);
                    }
                }
            }
            finally
            {
                this.pendingManager.RecordFinishPendingRequest();
            }
        }
        internal void EndGetMailTipsInBatches(IAsyncResult asyncResult)
        {
            OwaAsyncResult owaAsyncResult = (OwaAsyncResult)asyncResult;

            if (owaAsyncResult.Exception != null)
            {
                ExTraceGlobals.CoreCallTracer.TraceError <Exception>((long)this.GetHashCode(), "MailTipsNotificationHandler.EndGetMailTipsInBatches, exception {0}", owaAsyncResult.Exception);
            }
        }
        // Token: 0x06001224 RID: 4644 RVA: 0x0006E5F8 File Offset: 0x0006C7F8
        internal int EndCopy(IAsyncResult result)
        {
            OwaAsyncResult owaAsyncResult = (OwaAsyncResult)result;

            if (owaAsyncResult.Exception != null)
            {
                throw owaAsyncResult.Exception;
            }
            return(this.totalBytesCopied);
        }
Example #5
0
        internal void EndSendNotification(IAsyncResult async)
        {
            OwaAsyncResult owaAsyncResult = (OwaAsyncResult)async;

            if (!this.lockTracker.IsLockOwner())
            {
                throw new OwaInvalidOperationException("A thread that is not the owner of the lock can't call WriteNotification!", owaAsyncResult.Exception, this);
            }
            this.disposePendingRequest = false;
            this.response.WriteIsRequestAlive(false);
            if (owaAsyncResult.Exception != null)
            {
                throw new OwaNotificationPipeException("An exception happened while handling the pending connection asynchronously", owaAsyncResult.Exception);
            }
        }
Example #6
0
        public void EndUseNotificationPipe(IAsyncResult async)
        {
            if (this.isDisposing)
            {
                return;
            }
            OwaAsyncResult owaAsyncResult = (OwaAsyncResult)async;

            if (HttpContext.Current != null && OwaContext.Current != base.OwaContext)
            {
                base.OwaContext.IgnoreUnlockForcefully = true;
            }
            try
            {
                if (owaAsyncResult.Exception != null)
                {
                    bool             isBasicAuthentication        = Utilities.IsBasicAuthentication(base.OwaContext.HttpContext.Request);
                    ErrorInformation exceptionHandlingInformation = Utilities.GetExceptionHandlingInformation(owaAsyncResult.Exception, base.OwaContext.MailboxIdentity, Utilities.IsWebPartRequest(base.OwaContext), string.Empty, string.Empty, isBasicAuthentication);
                    Exception        ex = (owaAsyncResult.Exception.InnerException == null) ? owaAsyncResult.Exception : owaAsyncResult.Exception.InnerException;
                    ExTraceGlobals.NotificationsCallTracer.TraceDebug((long)this.GetHashCode(), "An exception was thrown during the processing of the async request");
                    StringBuilder stringBuilder = new StringBuilder();
                    using (StringWriter stringWriter = new StringWriter(stringBuilder, CultureInfo.InvariantCulture))
                    {
                        OwaEventHttpHandler.RenderErrorDiv(base.OwaContext, stringWriter, exceptionHandlingInformation.Message, exceptionHandlingInformation.MessageDetails, exceptionHandlingInformation.OwaEventHandlerErrorCode, exceptionHandlingInformation.HideDebugInformation ? null : ex);
                    }
                    if (this.response != null)
                    {
                        this.response.WriteError(Utilities.JavascriptEncode(stringBuilder.ToString()));
                        base.OwaContext.ErrorSent = true;
                    }
                }
                if (this.response != null)
                {
                    this.response.WriteLastChunk();
                }
            }
            catch (OwaNotificationPipeWriteException)
            {
            }
            finally
            {
                if (owaAsyncResult.Exception != null)
                {
                    Utilities.HandleException(base.OwaContext, owaAsyncResult.Exception);
                }
            }
        }
Example #7
0
 // Token: 0x060011EA RID: 4586 RVA: 0x0006C388 File Offset: 0x0006A588
 private void CommonEndProxyRequest(IAsyncResult asyncResult)
 {
     ExTraceGlobals.ProxyCallTracer.TraceDebug((long)this.GetHashCode(), "ProxyEventHandler.EndProxyRequest");
     try
     {
         OwaAsyncResult owaAsyncResult = (OwaAsyncResult)asyncResult;
         if (owaAsyncResult.Exception != null)
         {
             ExTraceGlobals.ProxyTracer.TraceDebug((long)this.GetHashCode(), "An exception was thrown during the processing of the async request");
             Utilities.HandleException(base.OwaContext, owaAsyncResult.Exception);
         }
     }
     finally
     {
         this.Dispose();
     }
 }
        // Token: 0x0600120C RID: 4620 RVA: 0x0006DA20 File Offset: 0x0006BC20
        internal HttpWebResponse EndSend(IAsyncResult asyncResult)
        {
            ExTraceGlobals.ProxyCallTracer.TraceDebug((long)this.GetHashCode(), "ProxyProtocolRequest.EndSend");
            HttpWebResponse result;

            try
            {
                OwaAsyncResult owaAsyncResult = (OwaAsyncResult)asyncResult;
                if (owaAsyncResult.Exception != null)
                {
                    throw new OwaAsyncOperationException("ProxyProtocolRequest async operation failed", owaAsyncResult.Exception);
                }
                HttpWebResponse httpWebResponse = this.proxyResponse;
                this.proxyResponse = null;
                result             = httpWebResponse;
            }
            finally
            {
                this.Dispose();
            }
            return(result);
        }
Example #9
0
        private void ElapsedConnectionAliveTimeout(object state)
        {
            bool                     requestRestart = false;
            OwaAsyncResult           owaAsyncResult = this.asyncResult;
            EventHandler <EventArgs> keepAlive      = this.KeepAlive;

            if (keepAlive != null)
            {
                keepAlive(this, new EventArgs());
            }
            if (DateTime.UtcNow.Ticks - this.startPendingRequestTime > PendingRequestManager.MaxPendingRequestOpenTimeIn100NanoSec)
            {
                this.disposePendingRequest = true;
                requestRestart             = true;
            }
            try
            {
                if (this.lockTracker.TryAcquireLockOnlyIfSucceed())
                {
                    try
                    {
                        if (this.lastWriteTime == 0L)
                        {
                            this.lastWriteTime = DateTime.UtcNow.Ticks;
                        }
                        bool flag = false;
                        try
                        {
                            this.notifiersStateLock.LockReaderElastic(5000);
                            flag = true;
                            IPendingRequestNotifier[] array = this.notifierDataAvaiableState.Keys.ToArray <IPendingRequestNotifier>();
                            this.notifiersStateLock.ReleaseReaderLock();
                            flag = false;
                            if (array != null)
                            {
                                for (int i = 0; i < array.Length; i++)
                                {
                                    array[i].ConnectionAliveTimer();
                                }
                            }
                        }
                        finally
                        {
                            if (flag)
                            {
                                this.notifiersStateLock.ReleaseReaderLock();
                            }
                        }
                        if (DateTime.UtcNow.Ticks - this.lastWriteTime >= 100000000L)
                        {
                            if (this.disposePendingRequest)
                            {
                                this.CloseCurrentPendingRequest(false, requestRestart);
                                this.lockTracker.TryReleaseLock(owaAsyncResult.IsCompleted);
                                return;
                            }
                            this.response.WriteEmptyNotification();
                            this.lastWriteTime = DateTime.UtcNow.Ticks;
                        }
                    }
                    catch (Exception e)
                    {
                        this.HandleException(e, false);
                        this.lockTracker.TryReleaseLock(owaAsyncResult.IsCompleted);
                        return;
                    }
                    if (!this.lockTracker.TryReleaseLock(owaAsyncResult.IsCompleted))
                    {
                        try
                        {
                            this.WriteNotification(false);
                        }
                        catch (Exception e2)
                        {
                            this.HandleException(e2, false);
                        }
                    }
                }
            }
            finally
            {
                if (!this.ChunkedHttpResponse.IsClientConnected)
                {
                    if (this.lastDisconnectedTime == 0L)
                    {
                        this.lastDisconnectedTime = DateTime.UtcNow.Ticks;
                        goto IL_23D;
                    }
                    if (DateTime.UtcNow.Ticks - this.lastDisconnectedTime <= 700000000L || this.userContext.IsUserRequestLockHeld)
                    {
                        goto IL_23D;
                    }
                    this.lastDisconnectedTime = 0L;
                    try
                    {
                        EventArgs e3 = new EventArgs();
                        EventHandler <EventArgs> clientDisconnected = this.ClientDisconnected;
                        if (clientDisconnected != null)
                        {
                            clientDisconnected(this, e3);
                        }
                        goto IL_23D;
                    }
                    catch (Exception ex)
                    {
                        ExTraceGlobals.NotificationsCallTracer.TraceDebug <string>((long)this.GetHashCode(), "Exception during ClientDisconnected event: {0}", ex.ToString());
                        goto IL_23D;
                    }
                }
                this.lastDisconnectedTime = 0L;
                IL_23D :;
            }
        }