/// <summary> /// Draws the content. /// </summary> private void DrawContent( ) { RetryHandler.Retry(() => { if (Clipboard.ContainsText( )) { string text = Clipboard.GetText( ); if (!string.IsNullOrEmpty(text)) { Guid guid; if (Guid.TryParse(text, out guid) && !Misc.Settings.Default.MonitorGuid) { return; } long id; if (long.TryParse(text, out id) && !Misc.Settings.Default.MonitorLong) { return; } if (!Misc.Settings.Default.MonitorAlias && !Misc.Settings.Default.MonitorPerfLog) { return; } var msg = IsPerfLog(text) ? new PerfGraphMessage(text).ToString() : new EntityBrowserMessage(text).ToString(); Settings.Channel.SendMessage(msg); } } }, exceptionHandler: e => Settings.EventLog.WriteException(e)); }
/// <summary> /// Copies the identifier click. /// </summary> /// <param name="account">The application.</param> private void CopyIdClick(Account account) { RetryHandler.Retry(() => { Clipboard.SetData(DataFormats.Text, account.Id.ToString( )); PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Id copied to clipboard...", 2000).ToString( )); }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e)); }
/// <summary> /// Copies the value click. /// </summary> /// <param name="app">The application.</param> private void CopyValueClick(TenantApp app) { RetryHandler.Retry(() => { Clipboard.SetData(DataFormats.Text, app.ApplicationId.ToString("B")); PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Value copied to clipboard...", 2000).ToString( )); }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e)); }
/// <summary> /// Copies the value click. /// </summary> /// <param name="field">The field.</param> private void CopyValueClick(IFieldInfo field) { RetryHandler.Retry(() => { Clipboard.SetData(DataFormats.Text, field.Data.ToString( )); PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Value copied to clipboard...", 2000).ToString( )); }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e)); }
/// <summary> /// Copies the reverse relationship click. /// </summary> /// <param name="obj">The object.</param> private void CopyReverseRelationshipClick(ReverseRelationship obj) { RetryHandler.Retry(() => { Clipboard.SetData(DataFormats.Text, string.Format("Type Id: {0}\nTenant Id: {1}\nFrom Id: {2}\nTo Id: {3}", obj.TypeId, obj.TenantId, obj.FromId, SelectedEntityId)); PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Relationship data copied to clipboard...", 2000).ToString( )); }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e)); }
/// <summary> /// Copies the click. /// </summary> /// <param name="field">The field.</param> private void CopyClick(IFieldInfo field) { RetryHandler.Retry(() => { Clipboard.SetData(DataFormats.Text, string.Format("Entity Id: {0}\nTenant Id: {1}\nField Id: {2}\nValue: {3}", field.EntityId, field.TenantId, field.FieldId, field.Data)); PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Data copied to clipboard...", 2000).ToString( )); }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e)); }
public void Retry_ActionThrowsHttpException_ShouldRetryArgumentReturnsFalse_ThrowsHttpException() { Action action = () => { RetryHandler.Retry <HttpException>(() => { throw new HttpException((int)HttpStatusCode.NotFound, HttpStatusCode.NotFound.ToString()); }, MaxAttempts, MilisecondsDelay, (ex) => ex.GetHttpCode() == (int)HttpStatusCode.ServiceUnavailable); }; action.ShouldThrow <HttpException>().Which.GetHttpCode().Should().Be((int)HttpStatusCode.NotFound); }
/// <summary> /// Copies the click. /// </summary> /// <param name="app">The application.</param> private void CopyClick(AppLibraryApp app) { const string format = @"Application: {0} Application Entity Id: {1} Package Id: {2} Package Entity Id: {3} Version: {4} Application Id: {5} Publisher: {6} Publisher Url: {7} Release Date: {8}"; RetryHandler.Retry(() => { Clipboard.SetData(DataFormats.Text, string.Format(format, app.Application, app.ApplicationEntityId, app.PackageId.ToString("B"), app.PackageEntityId, app.Version, app.ApplicationId.ToString("B"), app.Publisher, app.PublisherUrl, app.ReleaseDate)); PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Data copied to clipboard...", 2000).ToString( )); }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e)); }
/// <summary> /// Copies the click. /// </summary> /// <param name="item">The history item.</param> private void CopyClick(PlatformHistoryItem item) { const string format = @"Timestamp: {0} Tenant Id: {1} Tenant Name: {2} Package Id: {3} Package Name: {4} Operation: {5} Machine: {6} User: {7} Process: {8} Arguments: {9} Exception: {10}"; RetryHandler.Retry(() => { Clipboard.SetData(DataFormats.Text, string.Format(format, item.Timestamp, item.TenantId, item.TenantName, item.PackageId.ToString("B"), item.PackageName, item.Operation, item.Machine, item.User, item.Process, item.Arguments, item.Exception)); PluginSettings.Channel.SendMessage(new StatusTextMessage(@"Data copied to clipboard...", 2000).ToString( )); }, exceptionHandler: e => PluginSettings.EventLog.WriteException(e)); }
static void Main() { // cant use await here coz Main methos cannot be async so used Wait() method instead RetryHandler.RetryForAsync <WebException>(async() => { string content = await DownloadContentAsync(); Console.Write(content); }, 60000, 500, httpRequestException => httpRequestException.Status == WebExceptionStatus.Timeout || httpRequestException.Status == WebExceptionStatus.ConnectFailure).Wait(); // cant use await here coz Main methos cannot be async so used Wait() method instead RetryHandler.RetryAsync <WebException>(async() => { string content = await DownloadContentAsync(); Console.Write(content); }, 5, 500, httpRequestException => httpRequestException.Status == WebExceptionStatus.Timeout || httpRequestException.Status == WebExceptionStatus.ConnectFailure).Wait(); RetryHandler.Retry <WebException>(() => { string content = DownloadContent(); Console.Write(content); }, 6, 500, httpRequestException => httpRequestException.Status == WebExceptionStatus.Timeout || httpRequestException.Status == WebExceptionStatus.ConnectFailure, Logger); RetryHandler.RetryFor <WebException>(() => { string content = DownloadContent(); Console.Write(content); }, TimeSpan.FromSeconds(75), TimeSpan.FromSeconds(2), httpRequestException => httpRequestException.Status == WebExceptionStatus.Timeout || httpRequestException.Status == WebExceptionStatus.ConnectFailure, Logger); Console.Read(); }
public void Retry_ActionAlwaysThrowsHttpException_MaxAttemptExceedsAllowedMaxAttemptArgument_ThrowsHttpException() { Action action = () => { RetryHandler.Retry <HttpException>(() => { throw new HttpException(); }, MaxAttempts, MilisecondsDelay); }; action.ShouldThrow <HttpException>(); }
public void Retry_ExpectedToCatchHttpListenerException_ActionThrowsHttpException_ThrowsHttpException() { Action action = () => { RetryHandler.Retry <HttpListenerException>(() => { throw new HttpException(); }, MaxAttempts, MilisecondsDelay); }; action.ShouldThrow <HttpException>(); }
public void Retry_ActionDoesntThrowAnyException_ThrowsArgumentOutOfRangeException() { Action action = () => { RetryHandler.Retry <HttpException>(() => { }, MaxAttempts, MilisecondsDelay); }; action.ShouldNotThrow <HttpException>(); }
public void Retry_ActionArgumentIsNull_ThrowsArgumentOutOfRangeException() { Action action = () => { RetryHandler.Retry <Exception>(null, MaxAttempts, MilisecondsDelay); }; action.ShouldThrow <ArgumentNullException>(); }
public void Retry_MaxAttemptsArgumentEqualsZero_ThrowsArgumentOutOfRangeException() { Action action = () => { RetryHandler.Retry <Exception>(() => { }, 0, MilisecondsDelay); }; action.ShouldThrow <ArgumentOutOfRangeException>(); }