using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using Tango.BL.Enumerations; using Tango.FSE.Common; namespace Tango.FSE.UI.Tiles.Events { public class EventsTile : DashboardTile { private double _InfoEvents; public double InfoEvents { get { return _InfoEvents; } set { _InfoEvents = value; RaisePropertyChangedAuto(); } } private double _warningEvents; public double WarningEvents { get { return _warningEvents; } set { _warningEvents = value; RaisePropertyChangedAuto(); } } private double _errorEvents; public double ErrorEvents { get { return _errorEvents; } set { _errorEvents = value; RaisePropertyChangedAuto(); } } private double _criticalEvents; public double CriticalEvents { get { return _criticalEvents; } set { _criticalEvents = value; RaisePropertyChangedAuto(); } } private bool _canExecuteJob; public bool CanExecuteJob { get { return _canExecuteJob; } set { _canExecuteJob = value; RaisePropertyChangedAuto(); } } public EventsTile() { Name = "Active Events"; AutoContainerStyle = false; AutoTitleAlignment = System.Windows.Controls.Dock.Right; Column = 8; Row = 0; ColumnSpan = 4; RowSpan = 6; CanExecuteJob = true; } public override void OnApplicationStarted() { EventsProvider.ActiveEvents.CollectionChanged += ActiveEvents_CollectionChanged; } private void ActiveEvents_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { InfoEvents = EventsProvider.ActiveEvents.ToList().Where(x => x.Category == EventTypeCategories.Info).Count(); WarningEvents = EventsProvider.ActiveEvents.ToList().Where(x => x.Category == EventTypeCategories.Warning).Count(); ErrorEvents = EventsProvider.ActiveEvents.ToList().Where(x => x.Category == EventTypeCategories.Error).Count(); CriticalEvents = EventsProvider.ActiveEvents.ToList().Where(x => x.Category == EventTypeCategories.Critical).Count(); CanExecuteJob = !EventsProvider.ActiveEvents.Any(x => x.EventType.Actions.Contains(EventTypeActions.PreventJob)); } public override FrameworkElement GetView() { return new EventsTileView(); } } }