aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo
diff options
context:
space:
mode:
authorRoy <Roy.mail.net@gmail.com>2022-10-23 23:56:56 +0300
committerRoy <Roy.mail.net@gmail.com>2022-10-23 23:56:56 +0300
commit5e02391d9f37336169a045b9f7d1328bd72a7aef (patch)
tree158e519a9e10f5bde7eec62863922d0d18e087ad /Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo
parentddde7144515d7cb48a8f41d085aa738c6e4d36fa (diff)
downloadTango-5e02391d9f37336169a045b9f7d1328bd72a7aef.tar.gz
Tango-5e02391d9f37336169a045b9f7d1328bd72a7aef.zip
Total Dye Time & Meters on FSE.
Diffstat (limited to 'Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo')
-rw-r--r--Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs28
1 files changed, 28 insertions, 0 deletions
diff --git a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
index 0c818483c..3c3a0247b 100644
--- a/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
+++ b/Software/Visual_Studio/PPC/Tango.PPC.Common/SystemInfo/DefaultSystemInfoService.cs
@@ -1,10 +1,12 @@
using Microsoft.WindowsAPICodePack.Net;
using System;
using System.Collections.Generic;
+using System.Data.Entity;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
+using Tango.BL;
using Tango.Core;
using Tango.Core.DI;
using Tango.Integration.ExternalBridge;
@@ -130,6 +132,32 @@ namespace Tango.PPC.Common.SystemInfo
}, token);
}
+ [ExternalBridgeRequestHandlerMethod(typeof(GetMachineCountersRequest), RequestHandlerLoggingMode.LogRequestName)]
+ public async Task OnGetMachineCountersRequest(GetMachineCountersRequest request, String token, ExternalBridgeReceiver receiver)
+ {
+ var counters = await GetCounters();
+
+ var response = new GetMachineCountersResponse();
+ response.TotalDyeTime = counters.Item1;
+ response.TotalDyeMeters = counters.Item2;
+
+ await receiver.SendGenericResponse(response, token);
+ }
+
+ private async Task<Tuple<TimeSpan, int>> GetCounters()
+ {
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ var jobRuns = await db.JobRuns.Select(x => new { x.StartDate, x.EndDate, x.EndPosition }).ToListAsync();
+
+ TimeSpan totalDyeTime = TimeSpan.FromHours(jobRuns.Select(x => x.EndDate - x.StartDate).Sum(x => x.TotalHours));
+
+ int meters = (int)jobRuns.Select(x => x.EndPosition).Sum();
+
+ return new Tuple<TimeSpan, int>(totalDyeTime, meters);
+ }
+ }
+
public void OnReceiverDisconnected(ExternalBridgeReceiver receiver)
{