// Token: 0x0600055C RID: 1372 RVA: 0x00028D00 File Offset: 0x00026F00 public static bool IsTransientError(string code) { ResponseCodeType code2; return(Enum.TryParse <ResponseCodeType>(code, out code2) && ElcBaseServiceClient <ServiceBindingType, FunctionalInterfaceType> .IsTransientError(code2)); }
// Token: 0x06000584 RID: 1412 RVA: 0x0002AFD8 File Offset: 0x000291D8 private void CallEws(Func <BaseResponseMessageType> delegateEwsCall, Func <ResponseMessageType, int, bool> responseMessageProcessor, Func <Exception, Exception> exceptionHandler, ExchangeVersionType requestServerVersion, string mailboxEmailAddress) { if (this.Connect()) { base.ServiceBinding.RequestServerVersionValue = new RequestServerVersion { Version = requestServerVersion }; base.ServiceCallingContext.SetServiceApiContext(base.ServiceBinding, mailboxEmailAddress); try { base.InternalCallService <BaseResponseMessageType>(delegateEwsCall, delegate(BaseResponseMessageType response) { List <ResponseMessageType> list = new List <ResponseMessageType>(response.ResponseMessages.Items); foreach (ResponseMessageType responseMessageType in from t in response.ResponseMessages.Items orderby(int) t.ResponseClass select t) { int arg = list.IndexOf(responseMessageType); if (responseMessageType.ResponseClass == ResponseClassType.Error) { ElcEwsClient.Tracer.TraceError <ResponseCodeType, string>(0L, "ElcEwsClient.CallEws: Message response error. ResponseCode:{0}; MessageText:'{1}'", responseMessageType.ResponseCode, responseMessageType.MessageText); if (responseMessageType.ResponseCode == ResponseCodeType.ErrorInternalServerTransientError || responseMessageType.ResponseCode == ResponseCodeType.ErrorMailboxStoreUnavailable || responseMessageType.ResponseCode == ResponseCodeType.ErrorServerBusy || responseMessageType.ResponseCode == ResponseCodeType.ErrorTimeoutExpired) { ElcEwsClient.Tracer.TraceError <ResponseCodeType>(0L, "ElcEwsClient.CallEws: Transient exception causing retry. ResponseCode: {0}.", responseMessageType.ResponseCode); throw new RetryException(new ExportException(ExportErrorType.ExchangeWebServiceCallFailed, responseMessageType.MessageText), false); } if (responseMessageProcessor == null) { ElcEwsClient.Tracer.TraceError(0L, "ElcEwsClient.CallEws: Error response message received and responseMessageProcessor is null."); throw new ExportException(ExportErrorType.ExchangeWebServiceCallFailed, responseMessageType.MessageText); } } try { if (responseMessageProcessor != null && !responseMessageProcessor(responseMessageType, arg)) { break; } } catch (RetryException ex) { if (ElcBaseServiceClient <ExchangeServiceBinding, IElcEwsClient> .IsTransientError(responseMessageType.ResponseCode)) { throw; } throw ex.InnerException; } } }, exceptionHandler, () => base.ServiceCallingContext.AuthorizeServiceBinding(base.ServiceBinding), delegate(Uri redirectedUrl) { base.ServiceCallingContext.SetServiceUrlAffinity(base.ServiceBinding, redirectedUrl); base.ServiceCallingContext.SetServiceUrl(base.ServiceBinding, redirectedUrl); }); return; } catch (ExportException) { ElcEwsClient.Tracer.TraceError <ServiceHttpContext>(0L, "ElcEwsClient.CallEws: {0}", base.ServiceBinding.HttpContext); throw; } } throw new ExportException(ExportErrorType.ExchangeWebServiceCallFailed, "Unable to connect to Exchange web service at: " + base.ServiceEndpoint.ToString()); }
// Token: 0x06000560 RID: 1376 RVA: 0x00028EBC File Offset: 0x000270BC protected void InternalCallService <BaseResponseMessageType>(Func <BaseResponseMessageType> delegateServiceCall, Action <BaseResponseMessageType> responseProcessor, Func <Exception, Exception> exceptionHandler, Func <bool> authorizationHandler, Action <Uri> urlRedirectionHandler) { int num = 0; DateTime t = DateTime.UtcNow.Add(this.TotalRetryTimeWindow); Exception threadException; Exception ex; Exception ex2; for (;;) { ex = null; threadException = null; ex2 = null; bool flag = false; bool flag2 = false; bool flag3 = false; if (this.ServiceBinding != null) { ServiceBindingType serviceBinding = this.ServiceBinding; serviceBinding.UserAgent = string.Format("{0}{1}=MRM&{2}={3}&{4}={5}&{6}={7}", new object[] { ElcEwsClientHelper.GetOAuthUserAgent("ElcClient"), "S", "BI", DateTime.UtcNow.Ticks.ToString(), "R", num.ToString(), "RT", DateTime.UtcNow.Ticks.ToString() }); } try { BaseResponseMessageType response = default(BaseResponseMessageType); bool flag4 = false; Thread thread = new Thread(delegate() { try { response = delegateServiceCall(); } catch (Exception threadException) { threadException = threadException; } }); thread.Start(); while (!flag4) { if (this.AbortTokenForTasks.IsCancellationRequested) { throw new ExportException(ExportErrorType.StopRequested); } flag4 = thread.Join(5000); } if (!flag4) { thread.Abort(); } if (threadException != null) { throw threadException; } if (responseProcessor != null) { responseProcessor(response); } } catch (RetryException ex3) { ex = ex3.InnerException; flag = true; if (ex3.ResetRetryCounter) { Tracer.TraceError("ElcBaseServiceClient.InternalCallService: Resetting retry in RetryException.", new object[0]); flag2 = true; } } catch (ExportException ex4) { ex = ex4; if (ex4.ErrorType == ExportErrorType.Unauthorized) { flag3 = true; } } catch (WebException ex5) { ex = ex5; if (ex5.Status == WebExceptionStatus.TrustFailure) { Tracer.TraceError("ElcBaseServiceClient.InternalCallService: Unable to establish trust on exception. No retry.", new object[0]); flag = false; } else if (ex5.Status == WebExceptionStatus.ConnectFailure) { SocketException ex6 = ex5.InnerException as SocketException; flag = (ex6 == null || ex6.SocketErrorCode != SocketError.ConnectionRefused); Tracer.TraceError("ElcBaseServiceClient.InternalCallService: Connect failure. Retry: {0}.", new object[] { flag }); } else if (ex5.Status == WebExceptionStatus.NameResolutionFailure) { Tracer.TraceError("ElcBaseServiceClient.InternalCallService: DNS look up failure. No retry.", new object[0]); flag = false; } else { HttpWebResponse httpWebResponse = ex5.Response as HttpWebResponse; flag = true; if (httpWebResponse != null) { HttpStatusCode statusCode = httpWebResponse.StatusCode; switch (statusCode) { case HttpStatusCode.MovedPermanently: case HttpStatusCode.Found: break; default: if (statusCode != HttpStatusCode.TemporaryRedirect) { if (statusCode == HttpStatusCode.Unauthorized) { Tracer.TraceError("ElcBaseServiceClient.InternalCallService: HTTP 401 unauthorized", new object[0]); flag = false; flag3 = true; ex = new ExportException(ExportErrorType.Unauthorized, ex5); goto IL_352; } goto IL_352; } break; } string text = httpWebResponse.Headers[HttpResponseHeader.Location]; Tracer.TraceInformation("ElcBaseServiceClient.InternalCallService: HTTP redirection to {0}", new object[] { text }); ex = new ExportException(ExportErrorType.UnexpectedWebServiceUrlRedirection, ex5); flag = false; if (Uri.IsWellFormedUriString(text, UriKind.Absolute)) { Uri uri = new Uri(text); if (uri.Scheme == Uri.UriSchemeHttps && urlRedirectionHandler != null) { this.ServiceEndpoint = uri; urlRedirectionHandler(uri); ex = null; flag = true; flag2 = true; Tracer.TraceError("ElcBaseServiceClient.InternalCallService: Resetting retry during HTTP redirection.", new object[0]); } } } } IL_352 :; } catch (SoapException ex7) { if (ex7.Code != null && ex7.Code.Name == "ErrorAccessDenied") { flag = false; flag3 = true; ex = new ExportException(ExportErrorType.Unauthorized, ex7); } else { ex = ex7; flag = false; if (ex7.Code != null && ElcBaseServiceClient <ServiceBindingType, FunctionalInterfaceType> .IsTransientError(ex7.Code.Name)) { flag = true; } } } catch (TimeoutException ex8) { ex = ex8; flag = true; } catch (InvalidOperationException ex9) { ex = ex9; flag = true; } if (ex != null) { if (exceptionHandler != null) { Tracer.TraceError("ElcBaseServiceClient.InternalCallService: Exception handler is handling exception : {0}", new object[] { ex }); ex2 = exceptionHandler(ex); Tracer.TraceError("ElcBaseServiceClient.InternalCallService: Exception after being handled : {0}", new object[] { ex2 }); } else { ex2 = new ExportException(ExportErrorType.ExchangeWebServiceCallFailed, ex); } } if (flag && !flag2) { int num2 = this.GetRetryWaitTime(num); Tracer.TraceError("ElcBaseServiceClient.InternalCallService: Retry after {0} milliseconds on exception : {1}", new object[] { num2, ex }); while (num2 > 0 && t > DateTime.UtcNow) { Thread.Sleep((num2 > 5000) ? 5000 : num2); num2 -= 5000; if (this.AbortTokenForTasks.IsCancellationRequested) { goto Block_8; } } } if (flag3) { Tracer.TraceInformation("ElcBaseServiceClient.InternalCallService: Unauthorized", new object[0]); if (authorizationHandler == null || !authorizationHandler()) { goto IL_4BE; } flag = true; } if (flag2) { num = 0; } else { num++; } if (!flag || !(t > DateTime.UtcNow)) { goto IL_4DF; } } Block_8: throw new ExportException(ExportErrorType.StopRequested); IL_4BE: throw ex; IL_4DF: if (ex2 != null) { Tracer.TraceError("ElcBaseServiceClient.InternalCallService: Exception thrown after all possible actions: {0}", new object[] { ex2 }); throw ex2; } }