// Token: 0x0600064A RID: 1610 RVA: 0x00017670 File Offset: 0x00015870
        public string FormatException(Exception exception)
        {
            AuditLogServiceException ex = exception as AuditLogServiceException;

            if (ex != null)
            {
                return(string.Format("{0}[{1}]", AuditingOpticsLogger.DefaultExceptionFormatter.FormatException(exception), ex.Code));
            }
            if (exception is AuthenticationException || exception is WebException)
            {
                return(string.Format("{0}[{1}]", AuditingOpticsLogger.DefaultExceptionFormatter.FormatException(exception), exception.Message));
            }
            return(AuditingOpticsLogger.DefaultExceptionFormatter.FormatException(exception));
        }
Пример #2
0
        private void CallEwsWithRetries(LID lid, Func <BaseResponseMessageType> delegateEwsCall, Func <ResponseMessageType, int, bool> responseMessageProcessor, Func <ResponseMessageType, int, bool> responseErrorProcessor)
        {
            ExDateTime t    = ExDateTime.UtcNow.Add((this.CallTimeout < EwsAuditClient.TotalRetryTimeWindow) ? EwsAuditClient.TotalRetryTimeWindow : this.CallTimeout);
            bool       flag = false;
            Exception  ex   = null;
            int        num  = -1;

            do
            {
                if (flag)
                {
                    this.WaitBeforeRetry(num);
                }
                ex   = null;
                flag = false;
                num++;
                try
                {
                    DiagnosticContext.TraceDword((LID)57532U, (uint)num);
                    BaseResponseMessageType baseResponseMessageType;
                    using (DiagnosticContext.TraceLatency(lid))
                    {
                        baseResponseMessageType = delegateEwsCall();
                    }
                    int i = 0;
                    while (i < baseResponseMessageType.ResponseMessages.Items.Length)
                    {
                        ResponseMessageType responseMessageType = baseResponseMessageType.ResponseMessages.Items[i];
                        if (responseMessageProcessor != null && responseMessageProcessor(responseMessageType, i))
                        {
                            DiagnosticContext.TraceLocation((LID)32956U);
                            if (this.IsTraceEnabled(TraceType.DebugTrace))
                            {
                                this.Tracer.TraceDebug(0L, "Successfully executed EWS call");
                                break;
                            }
                            break;
                        }
                        else
                        {
                            if (responseMessageType.ResponseClass == ResponseClassType.Error)
                            {
                                DiagnosticContext.TraceDwordAndString((LID)33100U, (uint)responseMessageType.ResponseCode, responseMessageType.ResponseCode.ToString());
                                if (responseMessageType.ResponseCode == ResponseCodeType.ErrorCrossSiteRequest)
                                {
                                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                                    {
                                        this.Tracer.TraceDebug(0L, "Crosssite request error , recreate exchange binding and reset the url caches");
                                    }
                                    flag = true;
                                    this.RefreshUrl(true);
                                    break;
                                }
                                if (!EwsAuditClient.TransientServiceErrors.Contains(responseMessageType.ResponseCode))
                                {
                                    if (responseErrorProcessor == null || !responseErrorProcessor(responseMessageType, i))
                                    {
                                        if (this.IsTraceEnabled(TraceType.ErrorTrace))
                                        {
                                            this.Tracer.TraceError <string, string, string>(0L, "Permanent error encountered:  {0}, {1}, {2}", responseMessageType.ResponseClass.ToString(), responseMessageType.ResponseCode.ToString(), responseMessageType.MessageText.ToString());
                                        }
                                        DiagnosticContext.TraceLocation((LID)65212U);
                                        throw new AuditLogServiceException(responseMessageType.ResponseClass.ToString(), responseMessageType.ResponseCode.ToString(), responseMessageType.MessageText.ToString());
                                    }
                                    DiagnosticContext.TraceLocation((LID)48828U);
                                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                                    {
                                        this.Tracer.TraceDebug(0L, "Error encountered, but was handled by error callback:  {0}, {1}, {2}, response index={3}", new object[]
                                        {
                                            responseMessageType.ResponseClass.ToString(),
                                            responseMessageType.ResponseCode.ToString(),
                                            responseMessageType.MessageText.ToString(),
                                            i
                                        });
                                    }
                                }
                                else
                                {
                                    DiagnosticContext.TraceLocation((LID)40636U);
                                    flag = true;
                                    ex   = new AuditLogServiceException(responseMessageType.ResponseClass.ToString(), responseMessageType.ResponseCode.ToString(), responseMessageType.MessageText.ToString());
                                    if (this.IsTraceEnabled(TraceType.DebugTrace))
                                    {
                                        this.Tracer.TraceDebug(0L, "Transient error encountered, will attempt to retry, Exception: " + ex);
                                    }
                                }
                            }
                            i++;
                        }
                    }
                }
                catch (CommunicationException ex2)
                {
                    DiagnosticContext.TraceLocation((LID)57020U);
                    ex   = ex2;
                    flag = true;
                }
                catch (TimeoutException ex3)
                {
                    DiagnosticContext.TraceLocation((LID)44732U);
                    ex   = ex3;
                    flag = false;
                }
                catch (SoapException ex4)
                {
                    DiagnosticContext.TraceLocation((LID)61116U);
                    ex   = ex4;
                    flag = false;
                }
                catch (WebException ex5)
                {
                    DiagnosticContext.TraceLocation((LID)36540U);
                    ex   = ex5;
                    flag = false;
                }
                catch (IOException ex6)
                {
                    DiagnosticContext.TraceLocation((LID)52924U);
                    ex   = ex6;
                    flag = false;
                }
                catch (InvalidOperationException ex7)
                {
                    DiagnosticContext.TraceLocation((LID)46780U);
                    ex   = ex7;
                    flag = false;
                }
                catch (LocalizedException ex8)
                {
                    DiagnosticContext.TraceLocation((LID)63164U);
                    ex   = ex8;
                    flag = false;
                }
            }while (flag && t > ExDateTime.UtcNow);
            if (ex != null)
            {
                if (this.IsTraceEnabled(TraceType.ErrorTrace))
                {
                    this.Tracer.TraceError <int, Exception>(0L, "Failed to make EWS call to audit log, Total attempts made {0}, Exception: {1} ", num, ex);
                }
                DiagnosticContext.TraceLocation((LID)38588U);
                throw this.GetSpecificException(ex);
            }
        }