Exemplo n.º 1
0
        private void PushEvent(Operation operation)
        {
            // Sanity-check
            if (AvailableEvents.Any(o => o.Operation.Id == operation.Id))
            {
                return;
            }

            bool isOperationNew = !operation.IsAcknowledged;
            if (!isOperationNew && App.GetApp().Configuration.TreatOldOperationsAsNew)
            {
                Logger.Instance.LogFormat(LogType.Warning, this, "Debug option activated - treating operation '{0}' as a new operation!", operation.OperationNumber);
                isOperationNew = true;
            }

            // Notify operation viewer of this new operation (only if the operation is not acknowledged and thus new)
            if (isOperationNew)
            {
                _operationViewer.OnNewOperation(operation);
            }

            // Add the operation and perform a "sanity-sort" (don't trust the web service or whoever...)
            OperationViewModel ovm = new OperationViewModel(operation);
            AvailableEvents.Add(ovm);
            AvailableEvents = new List<OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.Timestamp));

            UpdateProperties();

            // If no event is selected yet, select the newest one (also do this if the selected operation is older. Newer operations have priority!).
            if (SelectedEvent == null || (SelectedEvent != null && SelectedEvent.Operation.Timestamp < AvailableEvents[0].Operation.Timestamp))
            {
                SelectedEvent = AvailableEvents[0];
            }

            // Call the UI-jobs now on this specific job (only if the operation is not acknowledged and thus new)
            if (isOperationNew)
            {
                App.GetApp().ExtensionManager.RunUIJobs(_operationViewer, operation);
            }

            // When the jobs are done, change over to the job (necessary in most cases albeit not perfect solution :-/ )
            _operationViewer.OnOperationChanged(SelectedEvent.Operation);
        }
Exemplo n.º 2
0
        private void RemoveEvent(OperationViewModel operation)
        {
            AvailableEvents.Remove(operation);
            AvailableEvents = new List<OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.Timestamp));

            UpdateProperties();
        }
Exemplo n.º 3
0
        private void RemoveEvent(OperationViewModel operation)
        {
            AvailableEvents.Remove(operation);
            AvailableEvents = new List<OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.TimestampIncome));

            SelectedEvent = AvailableEvents.FirstOrDefault();

            OnPropertyChanged("SelectedEvent");
            OnPropertyChanged("SelectedEvent.Operation");
            OnPropertyChanged("SelectedEvent.Operation.IsAcknowledged");
            UpdateProperties();
        }
        private void RemoveEvent(OperationViewModel operation)
        {
            AvailableEvents.Remove(operation);
            AvailableEvents = new List<OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.Timestamp));

            OnPropertyChanged("AvailableEvents");
            OnPropertyChanged("AreMultipleEventsPresent");
        }
Exemplo n.º 5
0
        /// <summary>
        /// Adds the operation to the list of available alarms and returns if the operation is a new one.
        /// An operation is "new" if it was once added to the list.
        /// </summary>
        /// <param name="operation"></param>
        /// <returns>Whether or not the added operation is "new".</returns>
        private bool AddOperation(Operation operation)
        {
            bool operationIsInList = ContainsEvent(operation.Id);

            // Add the operation and perform a "sanity-sort" (don't trust the web service or whoever...)
            OperationViewModel ovm = new OperationViewModel(operation);
            AvailableEvents.Add(ovm);
            AvailableEvents = new List<OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.TimestampIncome));

            // If we shall have a limit of alarms in the UI...
            int maxAlarmsInUI = App.GetApp().Configuration.MaxAlarmsInUI;
            if (maxAlarmsInUI > 0 && (AvailableEvents.Count > maxAlarmsInUI))
            {
                // ... remove older alarms until we have our amount.
                int count = AvailableEvents.Count - maxAlarmsInUI;
                AvailableEvents.RemoveRange(maxAlarmsInUI, count);
            }

            bool operationWasAddedToList = ContainsEvent(operation.Id);
            return (!operationIsInList && operationWasAddedToList);
        }
Exemplo n.º 6
0
 private void AcknowledgeOperationAndGoToFirst(OperationViewModel operation)
 {
     try
     {
         if (!operation.Operation.IsAcknowledged)
         {
             _service.AcknowledgeOperation(operation.Operation.Id);
         }
     }
     catch (Exception ex)
     {
         Logger.Instance.LogFormat(LogType.Error, this, Resources.AcknowledgeOperationFailed);
         Logger.Instance.LogException(this, ex);
     }
 }
        private void RemoveEvent(OperationViewModel operation)
        {
            AvailableEvents.Remove(operation);
            AvailableEvents = new List<OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.TimestampIncome));

            SelectedEvent = AvailableEvents.FirstOrDefault();

            UpdateEventsProperties();
            UpdateSelectedEventProperties();
        }
        /// <summary>
        /// Adds the operation to the list of available alarms.
        /// </summary>
        /// <param name="operation"></param>
        /// <returns>Whether or not the added operation was added to the list.</returns>
        private bool AddOperation(Operation operation)
        {
            bool operationIsInList = ContainsEvent(operation.Id);

            OperationViewModel ovm = new OperationViewModel(operation);
            AvailableEvents.Add(ovm);
            AvailableEvents = new List<OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.TimestampIncome));

            CheckAndRemoveOldOperations();

            bool operationWasAddedToList = ContainsEvent(operation.Id);
            return (!operationIsInList && operationWasAddedToList);
        }
        /// <summary>
        /// Pushes a new event to the window, either causing it to spawn, or to extend its list box by this event if already shown.
        /// </summary>
        /// <param name="operation">The event to push.</param>
        /// <returns>Whether or not the event was pushed. This is true if the event was a new one, and false if the event did already exist.</returns>
        public bool PushEvent(Operation operation)
        {
            // Sanity-check
            if (AvailableEvents.Any(o => o.Operation.Id == operation.Id))
            {
                return false;
            }

            bool isOperationNew = !operation.IsAcknowledged;

            // Notify operation viewer of this new operation (only if the operation is not acknowledged and thus new)
            if (isOperationNew)
            {
                _operationViewer.OnNewOperation(operation);
            }

            // Add the operation and perform a "sanity-sort" (don't trust the web service or whoever...)
            OperationViewModel ovm = new OperationViewModel(operation);
            AvailableEvents.Add(ovm);
            AvailableEvents = new List<OperationViewModel>(AvailableEvents.OrderByDescending(o => o.Operation.Timestamp));

            OnPropertyChanged("AvailableEvents");
            OnPropertyChanged("AreMultipleEventsPresent");

            // If no event is selected yet, select the newest one (also do this if the selected operation is older. Newer operations have priority!).
            if (SelectedEvent == null || (SelectedEvent != null && SelectedEvent.Operation.Timestamp < AvailableEvents[0].Operation.Timestamp))
            {
                SelectedEvent = AvailableEvents[0];
            }

            // Call the UI-jobs now on this specific job (only if the operation is not acknowledged and thus new)
            if (isOperationNew)
            {
                App.GetApp().ExtensionManager.RunUIJobs(_operationViewer, operation);
            }

            // When the jobs are done, change over to the job (necessary in most cases albeit not perfect solution :-/ )
            _operationViewer.OnOperationChanged(SelectedEvent.Operation);

            return true;
        }