aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsHistoryModule.cs
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2025-07-30 12:36:30 +0300
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2025-07-30 12:36:30 +0300
commit4222eddece906d6f0877022c06b853deb5068472 (patch)
treea29b706b3a5aedb28a42b209d5bb72b0ef94d40e /Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsHistoryModule.cs
parenta802fe75f9538371004f1833e69a69b798892d0c (diff)
downloadTango-4222eddece906d6f0877022c06b853deb5068472.tar.gz
Tango-4222eddece906d6f0877022c06b853deb5068472.zip
Telemetry source.
Diffstat (limited to 'Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsHistoryModule.cs')
-rw-r--r--Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsHistoryModule.cs61
1 files changed, 61 insertions, 0 deletions
diff --git a/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsHistoryModule.cs b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsHistoryModule.cs
new file mode 100644
index 000000000..6cb597e4b
--- /dev/null
+++ b/Software/Visual_Studio/Tango.Telemetry/Sources/TelemetryJobRunsHistoryModule.cs
@@ -0,0 +1,61 @@
+using System;
+using System.Collections.Generic;
+using System.Data.Entity;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Tango.BL;
+using Tango.Telemetry.Telemetries;
+
+namespace Tango.Telemetry.Sources
+{
+ public class TelemetryJobRunsHistorySource : TelemetryConfigurableSource<TelemetryJobRunsHistorySourceConfig>, ITelemetryHistorySource
+ {
+ private bool _isBusy;
+
+ public string Name { get; private set; } = "JobRuns History";
+
+ public Task<bool> CanRequestHistory(DateTime from)
+ {
+ return Task.FromResult(!_isBusy);
+ }
+
+ public async Task<IEnumerable<ITelemetry>> RequestHistory(DateTime from)
+ {
+ try
+ {
+ _isBusy = true;
+
+ using (ObservablesContext db = ObservablesContext.CreateDefault())
+ {
+ var runs = await db.JobRuns
+ .Where(x => x.LastUpdated > from)
+ .OrderBy(x => x.LastUpdated)
+ .Take(Config.MaxJobRunsPerRequest)
+ .ToListAsync();
+
+ List<TelemetryJobRun> tRuns = new List<TelemetryJobRun>();
+
+ foreach (var run in runs)
+ {
+ TelemetryJobRun tRun = new TelemetryJobRun();
+ tRun.Time = run.LastUpdated;
+ //Fill the object..
+ tRuns.Add(tRun);
+ }
+
+ return tRuns;
+ }
+ }
+ finally
+ {
+ _isBusy = false;
+ }
+ }
+
+ public void Dispose()
+ {
+
+ }
+ }
+}