protected void ExecuteAndHandleError(string description, ManageDelegationClient.WebMethodDelegate webMethod) { LocalizedException ex = null; try { this.ExecuteAndRetry(description, webMethod); } catch (SoapException exception) { ex = this.GetLiveDomainServicesAccessExceptionToThrow(exception); } catch (WebException exception2) { ex = ManageDelegationClient.GetCommunicationException(exception2); } catch (IOException exception3) { ex = ManageDelegationClient.GetCommunicationException(exception3); } catch (SocketException exception4) { ex = ManageDelegationClient.GetCommunicationException(exception4); } catch (InvalidOperationException exception5) { ex = ManageDelegationClient.GetCommunicationException(exception5); } if (ex != null) { this.WriteVerbose(Strings.LiveDomainServicesRequestFailed(ManageDelegationClient.GetExceptionDetails(ex))); throw ex; } }
private void ExecuteAndRetry(string description, ManageDelegationClient.WebMethodDelegate webMethod) { DateTime t = DateTime.UtcNow + ManageDelegationClient.ErrorRetryLimit; string validDirectUrl = this.ServiceEndpoint; this.Client.AllowAutoRedirect = false; WebProxy webProxy = LiveConfiguration.GetWebProxy(this.WriteVerbose); if (webProxy != null) { this.Client.Proxy = webProxy; } int num = 0; for (;;) { this.Client.Url = validDirectUrl; try { this.WriteVerbose(Strings.CallingDomainServicesEndPoint(description, validDirectUrl)); webMethod(); } catch (WebException ex) { if (DateTime.UtcNow > t) { throw; } HttpWebResponse httpWebResponse = ex.Response as HttpWebResponse; if (httpWebResponse == null) { throw; } HttpStatusCode statusCode = httpWebResponse.StatusCode; if (statusCode != HttpStatusCode.Found) { if (statusCode != HttpStatusCode.Forbidden) { throw; } Thread.Sleep(ManageDelegationClient.ErrorRetryInterval); } else { num++; if (num > 3) { throw; } validDirectUrl = this.GetValidDirectUrl(httpWebResponse); if (validDirectUrl == null) { throw; } } continue; } break; } }