blob: b59753f283915134a8b6a6df3360ce998bd46ea0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.BL.Entities;
using Tango.BL.Enumerations;
using Tango.FSE.Common;
using Tango.FSE.Common.Navigation;
using Tango.FSE.UI.Contracts;
using static Tango.FSE.UI.ViewModels.EventsViewVM;
namespace Tango.FSE.UI.ViewModels
{
public class EventsViewVM : FSEViewModel<IEventsView>, INavigationObjectReceiver<NavigationObject>
{
public class NavigationObject
{
public MachinesEvent SelectedEvent { get; set; }
}
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(); }
}
private MachinesEvent _selectedEvent;
public MachinesEvent SelectedEvent
{
get { return _selectedEvent; }
set { _selectedEvent = value; RaisePropertyChangedAuto(); }
}
public EventsViewVM()
{
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 void OnNavigatedToWithObject(NavigationObject obj)
{
SelectedEvent = obj.SelectedEvent;
View?.ScrollToActiveEvent(SelectedEvent);
}
}
}
|