/// <inheritdoc/> protected override ExitCode ExecuteHelper() { if (RemoveOnly) { IntegrationManager.RemoveAccessPointCategories(IntegrationManager.AppList[InterfaceUri], _removeCategories.ToArray()); return(ExitCode.OK); } else { CheckInstallBase(); var appEntry = GetAppEntry(IntegrationManager, ref InterfaceUri); var feed = FeedManager[InterfaceUri]; if (NoSpecifiedIntegrations) { var state = new IntegrationState(IntegrationManager, appEntry, feed); Retry: Handler.ShowIntegrateApp(state); try { state.ApplyChanges(); } #region Error handling catch (ConflictException ex) { if (Handler.Ask( Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry, defaultAnswer: false, alternateMessage: ex.Message)) { goto Retry; } } catch (InvalidDataException ex) { if (Handler.Ask( Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry, defaultAnswer: false, alternateMessage: ex.Message)) { goto Retry; } } #endregion return(ExitCode.OK); } else { if (_removeCategories.Any()) { IntegrationManager.RemoveAccessPointCategories(appEntry, _removeCategories.ToArray()); } if (_addCategories.Any()) { IntegrationManager.AddAccessPointCategories(appEntry, feed, _addCategories.ToArray()); } return(ExitCode.OK); } } }
/// <inheritdoc/> protected override ExitCode ExecuteHelper(ICategoryIntegrationManager integrationManager, FeedUri interfaceUri) { #region Sanity checks if (interfaceUri == null) { throw new ArgumentNullException(nameof(interfaceUri)); } if (integrationManager == null) { throw new ArgumentNullException(nameof(integrationManager)); } #endregion if (RemoveOnly()) { RemoveOnly(integrationManager, interfaceUri); return(ExitCode.OK); } CheckInstallBase(); var appEntry = GetAppEntry(integrationManager, ref interfaceUri); var feed = FeedManager[interfaceUri]; if (NoSpecifiedIntegrations()) { var state = new IntegrationState(integrationManager, appEntry, feed); Retry: Handler.ShowIntegrateApp(state); try { state.ApplyChanges(); } #region Error handling catch (ConflictException ex) { if (Handler.Ask( Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry, defaultAnswer: false, alternateMessage: ex.Message)) { goto Retry; } } catch (InvalidDataException ex) { if (Handler.Ask( Resources.IntegrateAppInvalid + Environment.NewLine + ex.Message + Environment.NewLine + Environment.NewLine + Resources.IntegrateAppRetry, defaultAnswer: false, alternateMessage: ex.Message)) { goto Retry; } } #endregion return(ExitCode.OK); } RemoveAndAdd(integrationManager, feed, appEntry); return(ExitCode.OK); }
/// <inheritdoc/> public void ShowIntegrateApp(IntegrationState state) { #region Sanity checks if (state == null) { throw new ArgumentNullException(nameof(state)); } #endregion var result = _wrapper.Post(form => { var integrationForm = new IntegrateAppForm(state); // The progress form and integration form take turns in being visible form.Hide(); return(integrationForm.ShowDialog()); }); if (result == DialogResult.OK) { _wrapper.Post(form => form.Show()); } else { throw new OperationCanceledException(); } }
/// <summary> /// OnAsyncMethodEnd callback /// </summary> /// <typeparam name="TTarget">Type of the target</typeparam> /// <typeparam name="TResponse">Type of the response, in an async scenario will be T of Task of T</typeparam> /// <param name="instance">Instance value, aka `this` of the instrumented method.</param> /// <param name="responseMessage">HttpResponse message instance</param> /// <param name="exception">Exception instance in case the original code threw an exception.</param> /// <param name="state">Calltarget state value</param> /// <returns>A response value, in an async scenario will be T of Task of T</returns> public static TResponse OnAsyncMethodEnd <TTarget, TResponse>(TTarget instance, TResponse responseMessage, Exception exception, CallTargetState state) where TResponse : IHttpResponseMessage { IntegrationState integrationState = (IntegrationState)state.State; if (integrationState.Scope is null) { return(responseMessage); } try { integrationState.Scope.Span.SetHttpStatusCode(responseMessage.StatusCode, isServer: false); if (exception != null) { integrationState.Scope.Span.SetException(exception); } } finally { integrationState.Scope.Dispose(); } return(responseMessage); }
/// <inheritdoc/> public void ShowIntegrateApp(IntegrationState state) { #region Sanity checks if (state == null) { throw new ArgumentNullException("state"); } #endregion var result = _wrapper.Post(form => { var integrationForm = new IntegrateAppForm(state); form.Visible = false; form.HideTrayIcon(); return(integrationForm.ShowDialog()); }); if (result == DialogResult.OK) { _wrapper.Post(form => form.Show()); } else { throw new OperationCanceledException(); } }
/// <summary> /// Creates an instance of the form. /// </summary> /// <param name="state">A View-Model for modifying the current desktop integration state.</param> public IntegrateAppForm(IntegrationState state) { InitializeComponent(); Shown += UpdateCommandLine; _state = state ?? throw new ArgumentNullException(nameof(state)); }
/// <inheritdoc/> public void ShowIntegrateApp(IntegrationState state) { #region Sanity checks if (state == null) { throw new ArgumentNullException(nameof(state)); } #endregion // TODO: Implement }
void DetectState() { _State = IntegrationState.Unknown; _StateComment = null; switch (_VBoxDD) { case FileSource.Missing: if (_VBoxDD0 == FileSource.VirtualBox) { _State = IntegrationState.Unknown; _StateComment = "You have deleted VBoxDD.dll, but VBoxDD0.dll seems OK."; } else { _State = IntegrationState.VBoxReinstallRequired; _StateComment = "Missing VBoxDD.dll"; } break; case FileSource.VirtualBox: _State = IntegrationState.NotInstalled; _StateComment = null; break; case FileSource.VirtualKD: switch (_VBoxDD0) { case FileSource.Missing: _State = IntegrationState.VBoxReinstallRequired; _StateComment = "Missing VBoxDD0.dll"; break; case FileSource.Unknown: case FileSource.VirtualKD: _State = IntegrationState.VBoxReinstallRequired; _StateComment = "Unrecognized VBoxDD0.dll"; break; case FileSource.VirtualBox: _State = IntegrationState.Successful; _StateComment = null; break; } break; case FileSource.Unknown: _State = IntegrationState.Unknown; _StateComment = "Unrecognized VBoxDD.dll"; break; } }
/// <summary> /// Creates an instance of the form. /// </summary> /// <param name="state">A View-Model for modifying the current desktop integration state.</param> public IntegrateAppForm(IntegrationState state) { #region Sanity checks if (state == null) { throw new ArgumentNullException(nameof(state)); } #endregion InitializeComponent(); _state = state; }
/// <summary> /// OnMethodEnd callback /// </summary> /// <typeparam name="TTarget">Type of the target</typeparam> /// <typeparam name="TReturn">Type of the return value</typeparam> /// <param name="instance">Instance value, aka `this` of the instrumented method.</param> /// <param name="returnValue">Task of HttpResponse message instance</param> /// <param name="exception">Exception instance in case the original code threw an exception.</param> /// <param name="state">Calltarget state value</param> /// <returns>A response value, in an async scenario will be T of Task of T</returns> public static CallTargetReturn <TReturn> OnMethodEnd <TTarget, TReturn>(TTarget instance, TReturn returnValue, Exception exception, CallTargetState state) { IntegrationState integrationState = (IntegrationState)state.State; if (integrationState.Scope != null) { // Before returning the control flow we need to restore the parent Scope setted by ScopeFactory.CreateOutboundHttpScope // This doesn't affect to OnAsyncMethodEnd async continuation, an ExecutionContext is captured // by the inner await. IScopeManager scopeManager = ((IDatadogTracer)Tracer.Instance).ScopeManager; if (scopeManager.Active == integrationState.Scope) { scopeManager.Close(integrationState.Scope); } } return(new CallTargetReturn <TReturn>(returnValue)); }
public AnalyticsProjectSettings(string path, SettingsScope scopes, IEnumerable <string> keywords = null) : base(path, scopes, k_ServiceName, keywords) { m_StateMachine = new SimpleStateMachine <ServiceEvent>(); m_StateMachine.AddEvent(ServiceEvent.Disabled); m_StateMachine.AddEvent(ServiceEvent.Integrating); m_StateMachine.AddEvent(ServiceEvent.Enabled); m_DisabledState = new DisabledState(m_StateMachine, this); m_IntegrationState = new IntegrationState(m_StateMachine, this); m_EnabledState = new EnabledState(m_StateMachine, this); m_StateMachine.AddState(m_DisabledState); m_StateMachine.AddState(m_IntegrationState); m_StateMachine.AddState(m_EnabledState); m_ValidationPoller = new AnalyticsValidationPoller(); }
/// <inheritdoc/> public void ShowIntegrateApp(IntegrationState state) { // No UI, so nothing to do }
/// <inheritdoc/> public void ShowIntegrateApp(IntegrationState state) { throw new NeedGuiException(Resources.IntegrateAppUseGui); }
void DetectState() { _State = IntegrationState.Unknown; _StateComment = null; switch(_VBoxDD) { case FileSource.Missing: if (_VBoxDD0 == FileSource.VirtualBox) { _State = IntegrationState.Unknown; _StateComment = "You have deleted VBoxDD.dll, but VBoxDD0.dll seems OK."; } else { _State = IntegrationState.VBoxReinstallRequired; _StateComment = "Missing VBoxDD.dll"; } break; case FileSource.VirtualBox: _State = IntegrationState.NotInstalled; _StateComment = null; break; case FileSource.VirtualKD: switch(_VBoxDD0) { case FileSource.Missing: _State = IntegrationState.VBoxReinstallRequired; _StateComment = "Missing VBoxDD0.dll"; break; case FileSource.Unknown: case FileSource.VirtualKD: _State = IntegrationState.VBoxReinstallRequired; _StateComment = "Unrecognized VBoxDD0.dll"; break; case FileSource.VirtualBox: _State = IntegrationState.Successful; _StateComment = null; break; } break; case FileSource.Unknown: _State = IntegrationState.Unknown; _StateComment = "Unrecognized VBoxDD.dll"; break; } }