aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-18 18:30:55 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2020-03-18 18:30:55 +0200
commitb96d52dcf527339d4d1c43c06d49b375a5f42e0c (patch)
treec884cc3917a6b19dfeeba89536fd7e0634780116 /Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels
parent7ae0a7f52c656e5a9e4ddaf60a72d5aaaa00b0e5 (diff)
downloadTango-b96d52dcf527339d4d1c43c06d49b375a5f42e0c.tar.gz
Tango-b96d52dcf527339d4d1c43c06d49b375a5f42e0c.zip
Implemented machine counters on PPC maintenance.
Diffstat (limited to 'Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels')
-rw-r--r--Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs40
1 files changed, 40 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
index 8d221c3f3..759d43415 100644
--- a/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
+++ b/Software/Visual_Studio/PPC/Modules/Tango.PPC.Maintenance/ViewModels/MaintenanceViewVM.cs
@@ -2,9 +2,11 @@
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
+using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
using Tango.Core.Commands;
using Tango.Explorer;
using Tango.Integration.Operation;
@@ -39,6 +41,20 @@ namespace Tango.PPC.Maintenance.ViewModels
set { _overallTemperature = value; RaisePropertyChangedAuto(); }
}
+ private String _totalDyeTime;
+ public String TotalDyeTime
+ {
+ get { return _totalDyeTime; }
+ set { _totalDyeTime = value; RaisePropertyChangedAuto(); }
+ }
+
+ private String _totalDyeMeters;
+ public String TotalDyeMeters
+ {
+ get { return _totalDyeMeters; }
+ set { _totalDyeMeters = value; RaisePropertyChangedAuto(); }
+ }
+
public RelayCommand ExportLogsCommand { get; set; }
public OpenCloseDyeingHeadCommand OpenCloseDyeingHeadCommand { get; set; }
@@ -167,5 +183,29 @@ namespace Tango.PPC.Maintenance.ViewModels
}
}
}
+
+ public async override void OnNavigatedTo()
+ {
+ base.OnNavigatedTo();
+
+ try
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ var jobRuns = await db.JobRuns.Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).ToListAsync();
+
+ TotalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours)).ToString(@"hh\:mm\:ss");
+
+ int meters = (int)jobRuns.Select(x => x.EndPosition).Sum();
+ TotalDyeMeters = $"{meters.ToString("N0")} meters";
+ }
+ }
+ catch (Exception ex)
+ {
+ LogManager.Log(ex, "Error loading machine counters.");
+ TotalDyeTime = "error!";
+ TotalDyeMeters = "error!";
+ }
+ }
}
}