aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs
diff options
context:
space:
mode:
authorAvi Levkovich <avi@twine-s.com>2019-10-30 17:55:39 +0200
committerAvi Levkovich <avi@twine-s.com>2019-10-30 17:55:39 +0200
commit3e22430905c4c247672237a6d64425f3f958626e (patch)
treea0fbf053a2ddf1fefc9f0ae3281fb06e70e5e52e /Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs
parentcc657620eac3b626cf0790802c2a5ae3196c396b (diff)
parent43113f6b264c8d334393c6116e1858eeec7ca5c6 (diff)
downloadTango-3e22430905c4c247672237a6d64425f3f958626e.tar.gz
Tango-3e22430905c4c247672237a6d64425f3f958626e.zip
Merge branch 'master' of https://twinetfs.visualstudio.com/_git/Tango
Diffstat (limited to 'Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs')
-rw-r--r--Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs42
1 files changed, 25 insertions, 17 deletions
diff --git a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs
index c813e9752..2c3886ea4 100644
--- a/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs
+++ b/Software/Visual_Studio/MachineStudio/Modules/Tango.MachineStudio.Logging/ViewModels/EventsViewVM.cs
@@ -135,31 +135,39 @@ namespace Tango.MachineStudio.Logging.ViewModels
{
using (_notification.PushTaskItem("Loading machine events..."))
{
- await Task.Factory.StartNew(() =>
+ try
{
- _db = ObservablesContext.CreateDefault();
+ await Task.Factory.StartNew(() =>
+ {
+ _db = ObservablesContext.CreateDefault();
- _db.EventTypes.Load();
+ _db.EventTypes.Load();
- DateTime now = DateTime.UtcNow.AddMonths(-1);
+ DateTime now = DateTime.UtcNow.AddMonths(-1);
- _history_events = _db.MachinesEvents.Where(x => x.MachineGuid == SelectedMachine.Guid && x.DateTime > now).Include(x => x.User).Include(x => x.User.Contact).Include(x => x.Machine).ToList();
+ _history_events = _db.MachinesEvents.Where(x => x.MachineGuid == SelectedMachine.Guid && x.DateTime > now).Include(x => x.User).Include(x => x.User.Contact).Include(x => x.Machine).ToList();
- Dates = new ObservableCollection<DateTime>();
+ Dates = new ObservableCollection<DateTime>();
- foreach (var day in _history_events.GroupBy(x => x.DateTime.DayOfYear).Select(x => x.First().DateTime).OrderByDescending(x => x))
- {
- Dates.Add(day);
- }
+ foreach (var day in _history_events.GroupBy(x => x.DateTime.DayOfYear).Select(x => x.First().DateTime).OrderByDescending(x => x))
+ {
+ Dates.Add(day);
+ }
- if (Dates.Count > 0)
- {
- MinDate = Dates.Min();
- MaxDate = Dates.Max();
- }
+ if (Dates.Count > 0)
+ {
+ MinDate = Dates.Min();
+ MaxDate = Dates.Max();
+ }
- SelectedDate = Dates.FirstOrDefault();
- });
+ SelectedDate = Dates.FirstOrDefault();
+ });
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error loading machine events.");
+ _notification.ShowError($"An error occurred while trying to load the selected machine events.\n{ex.FlattenMessage()}");
+ }
}
}
}