/// <summary> /// Assigns from configuration setting based on <see cref="ObservationState"/>. /// </summary> /// <param name="observationState">The <see cref="ObservationState"/>.</param> /// <param name="isEnabled">if set to <c>true</c> setting related to given <see cref="observationState"/> will be enabled; otherwise disabled.</param> public void AssignFromObeservationStateActivity(ObservationState observationState, bool isEnabled) { switch (observationState) { case ObservationState.Failure: this.FailureNotificationEnabled = isEnabled; break; case ObservationState.Running: this.RunningNotificationEnabled = isEnabled; break; case ObservationState.Success: this.SuccessNotificationEnabled = isEnabled; break; case ObservationState.Unstable: this.UnstableNotificationEnabled = isEnabled; break; case ObservationState.Unknown: this.UnknownNotificationEnabled = isEnabled; break; default: throw new ArgumentOutOfRangeException(nameof(observationState), observationState, null); } }
/// <summary> /// Checks if the notification should be shown. /// </summary> /// <param name="currentStatus">The current status.</param> /// <param name="stateToCheck">The state to check.</param> /// <param name="notificationConfiguration">The notification configuration.</param> /// <returns>True if the notification should be shown, otherwise false.</returns> internal bool CheckNotificationShow(StatusViewModel currentStatus, ObservationState stateToCheck, NotificationConfiguration notificationConfiguration) { var enabledCheck = this.GetEnabledStateCheck(stateToCheck, notificationConfiguration); if (!enabledCheck()) { return(false); } var connectorSnapshots = currentStatus.Parent.ConnectorSnapshots; if (connectorSnapshots == null || connectorSnapshots.Count == 1 || notificationConfiguration.OnlyIfChanged == false) { return(currentStatus.State == stateToCheck); } var historicalOrderedConnectorSnapshots = connectorSnapshots.Reverse().Skip(1); foreach (var historicalOrderedConnectorSnapshot in historicalOrderedConnectorSnapshots) { var snapshotEnabledCheck = this.GetEnabledStateCheck(historicalOrderedConnectorSnapshot.State, notificationConfiguration); if (snapshotEnabledCheck() && currentStatus.State == stateToCheck) { if (historicalOrderedConnectorSnapshot.State != currentStatus.State) { return(true); } return(false); } } return(false); }
/// <summary> /// Gets the enabled state check method call. /// </summary> /// <param name="stateToCheck">The state to check.</param> /// <param name="notificationConfiguration">The notification configuration.</param> /// <returns>The enabled state check method call.</returns> private Func <bool> GetEnabledStateCheck(ObservationState stateToCheck, NotificationConfiguration notificationConfiguration) { Func <bool> enabledCheck; switch (stateToCheck) { case ObservationState.Unknown: enabledCheck = () => notificationConfiguration.UnknownNotificationEnabled; break; case ObservationState.Unstable: enabledCheck = () => notificationConfiguration.UnstableNotificationEnabled; break; case ObservationState.Failure: enabledCheck = () => notificationConfiguration.FailureNotificationEnabled; break; case ObservationState.Success: enabledCheck = () => notificationConfiguration.SuccessNotificationEnabled; break; case ObservationState.Running: enabledCheck = () => notificationConfiguration.RunningNotificationEnabled; break; default: throw new ArgumentOutOfRangeException(nameof(stateToCheck), stateToCheck, null); } return(enabledCheck); }
private static Color GetColor(ObservationState state) { switch (state) { case ObservationState.Unstable: return(System.Windows.Media.Colors.Orange); break; case ObservationState.Failure: return(Color.FromRgb(201, 42, 60)); break; case ObservationState.Success: return(Color.FromRgb(66, 171, 20)); break; case ObservationState.Running: return(System.Windows.Media.Colors.DarkCyan); break; default: return(Color.FromRgb(120, 144, 156)); break; } }
/// <summary> /// Empieza a observar un espacio /// </summary> /// <param name="obj">Objeto a observar</param> public void ObserveObject (ISpaceable obj) { if (IsBeingObserved (obj)) throw new InvalidOperationException ("Object already being observed."); var state = new ObservationState (obj); observedObjects.Add (state); }
public static JenkinsJob GetProject(ObservationState state, int lastBuildNumber) { return(new JenkinsJob { LastBuild = GetBuild(state, lastBuildNumber), }); }
public static JenkinsBuild GetBuild(ObservationState state, int number) { return(new JenkinsBuild { Number = number, Result = state.ToString(), Building = state == ObservationState.Running, }); }
public static JenkinsBuild GetBuild(ObservationState state, int number) { return(new JenkinsBuild { Number = number, Result = state.ToString(), Building = state == ObservationState.Running, Timestamp = (long)(new DateTime(2020, 1, 1, 12, number, 0, 0) - new DateTime(1970, 1, 1)).TotalMilliseconds, }); }
public bool CheckNotificationShowTest(bool onlyIfChanged, ObservationState currentState, ObservationState historyState1, ObservationState historyState2, ObservationState historyState3, ObservationState historyState4) { var observationScheduler = new ObservationScheduler(); var configuration = new ApplicationConfiguration(); configuration.OpenMinimized = true; var trayHandler = new TrayHandler(observationScheduler, configuration); var connectorViewModel = new ConnectorViewModel(); var statusViewModel = new StatusViewModel(connectorViewModel); statusViewModel.State = currentState; var status1 = new BuildStatusViewModel(connectorViewModel) { State = currentState }; var status2 = new BuildStatusViewModel(connectorViewModel) { State = historyState1 }; var status3 = new BuildStatusViewModel(connectorViewModel) { State = historyState2 }; var status4 = new BuildStatusViewModel(connectorViewModel) { State = historyState3 }; var status5 = new BuildStatusViewModel(connectorViewModel) { State = historyState4 }; connectorViewModel.ConnectorSnapshots.Add(status5); connectorViewModel.ConnectorSnapshots.Add(status4); connectorViewModel.ConnectorSnapshots.Add(status3); connectorViewModel.ConnectorSnapshots.Add(status2); connectorViewModel.ConnectorSnapshots.Add(status1); var notificationConfiguration = new NotificationConfiguration(); notificationConfiguration.OnlyIfChanged = onlyIfChanged; notificationConfiguration.RunningNotificationEnabled = false; return(trayHandler.CheckNotificationShow(statusViewModel, currentState, notificationConfiguration)); }
/// <summary> /// RTeturns flag of <see cref="ObservationState"/> enabled state in the configuration. /// </summary> /// <param name="observationState">State of the observation.</param> /// <returns>True if given <see cref="ObservationState"/> is activated in the configuration, otherwise false.</returns> public bool AsObservationStateFlag(ObservationState observationState) { switch (observationState) { case ObservationState.Unstable: return(this.UnstableNotificationEnabled); case ObservationState.Failure: return(this.FailureNotificationEnabled); case ObservationState.Success: return(this.SuccessNotificationEnabled); case ObservationState.Running: return(this.RunningNotificationEnabled); case ObservationState.Unknown: return(this.UnknownNotificationEnabled); default: throw new ArgumentOutOfRangeException(nameof(observationState), observationState, null); } }
/// <summary> /// Removes the unsupported <see cref="ObservationState"/>s by plugin. /// </summary> /// <param name="observationStates">The observation states collection.</param> /// <param name="observationState"><see cref="ObservationState"/> to check it's support on plugin.</param> /// <param name="supportsState">Call to support state check.</param> private void RemoveNotSupportedObservationState(ICollection <ObservationState> observationStates, ObservationState observationState, Func <bool> supportsState) { var observationStateListItem = observationStates.FirstOrDefault(s => s == observationState); if (observationStateListItem != default(ObservationState) && !supportsState()) { observationStates.Remove(observationStateListItem); } }
/// <summary> /// Initializes a new instance of the <see cref="ServerHealthStatus"/> class. /// </summary> /// <param name="state">The state of job.</param> public ServerHealthStatus(ObservationState state) : base(state) { }
/// <summary> /// Raises the ratón se fue event. /// </summary> /// <param name="e">E.</param> protected virtual void OnRatónSeFue (ObservationState e) { RatónSeFue?.Invoke (this, e); }
/// <summary> /// Raises the ratón encima event. /// </summary> /// <param name="e">E.</param> protected virtual void OnRatónEncima (ObservationState e) { RatónEncima?.Invoke (this, e); }
public Status(ObservationState state) { this.State = state; }
public JenkinsStatus(ObservationState state) : base(state) { }
public Status(ObservationState state) { this.Properties = new Dictionary <string, string>(); this.State = state; }