public void MAStatusChanged(MAStatus status) { switch (status.ErrorState) { case ErrorState.ControllerFaulted: this.Message = "An unexpected error occurred in the controller"; break; case ErrorState.None: this.Message = status.Message; break; case ErrorState.ThresholdExceeded: this.Message = "Threshold exceeded"; break; case ErrorState.UnexpectedChange: this.Message = "The controller was terminated due to unexpected changes"; break; } this.ExecutingRunProfile = status.ExecutingRunProfile; this.ExecutionQueue = status.ExecutionQueue; this.DisplayState = status.DisplayState; this.ControlState = status.ControlState; this.ExecutionState = status.ExecutionState; this.HasExclusiveLock = status.HasExclusiveLock; this.HasSyncLock = status.HasSyncLock; this.HasForeignLock = status.HasForeignLock; this.ErrorState = status.ErrorState; this.Disabled = this.ControlState == ControlState.Disabled; }
private void SubscribeToStateChanges() { Trace.WriteLine($"Attempting to open event channel for {this.ManagementAgentName}/{this.ManagementAgentID}"); InstanceContext i = new InstanceContext(this); this.IsConnected = false; while (!this.IsConnected) { try { this.DisplayState = "Disconnected"; this.client = App.GetDefaultEventClient(i); this.client.Open(); this.client.Register(this.ManagementAgentID); this.IsConnected = true; this.faultedCount = 0; } catch (TimeoutException) { this.client.Abort(); Trace.WriteLine("Timeout connecting to server"); Thread.Sleep(UserSettings.ReconnectInterval); } catch (Exception ex) { this.client.Abort(); Trace.WriteLine("Error connecting to server"); Trace.WriteLine(ex); Thread.Sleep(UserSettings.ReconnectInterval); } } Trace.WriteLine($"Registered event channel for {this.ManagementAgentName}/{this.ManagementAgentID}"); this.client.InnerChannel.Closed += this.InnerChannel_Closed; this.client.InnerChannel.Faulted += this.InnerChannel_Faulted; Debug.WriteLine($"Requesting full update for {this.ManagementAgentName}/{this.ManagementAgentID}"); MAStatus status = this.client.GetFullUpdate(this.ManagementAgentID); Debug.WriteLine($"Got full update from {this.ManagementAgentName}/{this.ManagementAgentID}"); this.StartPingTimer(); if (status != null) { this.MAStatusChanged(status); } }
public void MAStatusChanged(MAStatus status) { this.Message = status.Message; this.ExecutingRunProfile = status.ExecutingRunProfile; this.ExecutionQueue = status.ExecutionQueue; this.DisplayState = status.DisplayState; this.ControlState = status.ControlState; this.ExecutionState = status.ExecutionState; this.HasExclusiveLock = status.HasExclusiveLock; this.HasSyncLock = status.HasSyncLock; this.HasForeignLock = status.HasForeignLock; this.Disabled = this.ControlState == ControlState.Disabled; }