diff --git a/Service.EDMIService/EDMIService.vb b/Service.EDMIService/EDMIService.vb
index 54512f66..2c36be07 100644
--- a/Service.EDMIService/EDMIService.vb
+++ b/Service.EDMIService/EDMIService.vb
@@ -31,6 +31,9 @@ Public Class EDMIService
Public Const TBIDB_ACCESSRIGHT = "TBIDB_ACCESSRIGHT"
' ── Aktive Sessions: SessionId → Username (thread-safe) ──────────────────
Private Shared ReadOnly _ActiveSessions As New Collections.Concurrent.ConcurrentDictionary(Of String, String)
+ ' ► NEU: Letzte Aktivität je Benutzer (für Monitoring auch nach Session-Close)
+ Private Shared ReadOnly _RecentUsers As New Collections.Concurrent.ConcurrentDictionary(Of String, DateTime)
+ Private Shared ReadOnly _RecentUserMaxAge As TimeSpan = TimeSpan.FromMinutes(15)
Public Shared ReadOnly Property ActiveSessions As Integer
Get
@@ -121,6 +124,8 @@ Public Class EDMIService
End If
_ActiveSessions(oSessionId) = _Username
+ ' ► NEU: Letzten Zugriff für diesen Benutzer aktualisieren
+ _RecentUsers(_Username) = DateTime.Now
' ← Neu: Session-Start loggen
_Logger.Debug("Session opened | User=[{0}] | SessionId=[{1}] | ActiveSessions=[{2}]",
_Username, oSessionId, _ActiveSessions.Count)
@@ -160,15 +165,29 @@ Public Class EDMIService
''' Returns a snapshot of all currently active sessions for monitoring purposes
'''
Public Function GetServiceStatus() As Messages.ServiceStatusResponse Implements IEDMIService.GetServiceStatus
- _Logger.Debug("GetServiceStatus called by User=[{0}]", _Username)
- ' Snapshot nur einmal erstellen, nicht zweimal iterieren:
+ ' Aktuell offene Sessions
Dim oSnapshot = _ActiveSessions.ToArray()
+
+ ' ► NEU: Kürzlich aktive Benutzer (max. 15 Min. alt) bereinigen und zurückgeben
+ Dim oCutoff = DateTime.Now.Subtract(_RecentUserMaxAge)
+ Dim oStaleKeys = _RecentUsers.Where(Function(p) p.Value < oCutoff).Select(Function(p) p.Key).ToList()
+ For Each oKey In oStaleKeys
+ Dim oIgnored As DateTime
+ _RecentUsers.TryRemove(oKey, oIgnored)
+ Next
+
+ Dim oRecentUserList = _RecentUsers.
+ OrderByDescending(Function(p) p.Value).
+ Select(Function(p) $"{p.Key} (zuletzt: {p.Value:HH:mm:ss})").
+ ToList()
+
Return New Messages.ServiceStatusResponse With {
- .ActiveSessionCount = oSnapshot.Length,
- .ActiveUsers = oSnapshot.Select(Function(p) p.Value).Distinct().OrderBy(Function(u) u).ToList(),
- .ActiveSessions = oSnapshot.ToDictionary(Function(p) p.Key, Function(p) p.Value),
- .Timestamp = DateTime.Now
- }
+ .ActiveSessionCount = oSnapshot.Length,
+ .ActiveUsers = oSnapshot.Select(Function(p) p.Value).Distinct().OrderBy(Function(u) u).ToList(),
+ .ActiveSessions = oSnapshot.ToDictionary(Function(p) p.Key, Function(p) p.Value),
+ .Timestamp = DateTime.Now,
+ .RecentUsers = oRecentUserList ' ◄ NEU – im Response-Objekt ergänzen
+ }
End Function
#End Region
diff --git a/Service.EDMIService/EDMIService.vbproj b/Service.EDMIService/EDMIService.vbproj
index 77b88c2a..e956fe74 100644
--- a/Service.EDMIService/EDMIService.vbproj
+++ b/Service.EDMIService/EDMIService.vbproj
@@ -155,7 +155,6 @@
-
diff --git a/Service.EDMIService/GetServiceStatus.vb b/Service.EDMIService/GetServiceStatus.vb
deleted file mode 100644
index df7fd77c..00000000
--- a/Service.EDMIService/GetServiceStatus.vb
+++ /dev/null
@@ -1,6 +0,0 @@
-Imports System.Runtime.Serialization
-
-Public Class GetServiceStatus
-
-
-End Class
diff --git a/Service.EDMIService/Messages/GetServiceStatus.vb b/Service.EDMIService/Messages/GetServiceStatus.vb
index 34c75466..01bed182 100644
--- a/Service.EDMIService/Messages/GetServiceStatus.vb
+++ b/Service.EDMIService/Messages/GetServiceStatus.vb
@@ -1,11 +1,12 @@
Imports System.Runtime.Serialization
Namespace Messages
-
+
Public Class ServiceStatusResponse
- Public Property ActiveSessionCount As Integer
- Public Property ActiveUsers As List(Of String) ' Distinct, sortiert
- Public Property ActiveSessions As Dictionary(Of String, String) ' SessionId → Username
- Public Property Timestamp As DateTime
+ Public Property ActiveSessionCount As Integer
+ Public Property ActiveUsers As List(Of String)
+ Public Property ActiveSessions As Dictionary(Of String, String)
+ Public Property Timestamp As DateTime
+ Public Property RecentUsers As List(Of String) = New List(Of String)()
End Class
End Namespace
\ No newline at end of file