diff --git a/GBM/Classes/clsSession.vb b/GBM/Classes/clsSession.vb
new file mode 100644
index 0000000..cec5e2b
--- /dev/null
+++ b/GBM/Classes/clsSession.vb
@@ -0,0 +1,44 @@
+Public Class clsSession
+
+ Private sMonitorID As String
+ Private dStart As DateTime
+ Private dEnd As DateTime
+ Private sComputerName As String = My.Computer.Name
+
+ Public Property MonitorID As String
+ Set(value As String)
+ sMonitorID = value
+ End Set
+ Get
+ Return sMonitorID
+ End Get
+ End Property
+
+ Public Property SessionStart As DateTime
+ Set(value As DateTime)
+ dStart = value
+ End Set
+ Get
+ Return dStart
+ End Get
+ End Property
+
+ Public Property SessionEnd As DateTime
+ Set(value As DateTime)
+ dEnd = value
+ End Set
+ Get
+ Return dEnd
+ End Get
+ End Property
+
+ Public Property ComputerName As String
+ Set(value As String)
+ sComputerName = value
+ End Set
+ Get
+ Return sComputerName
+ End Get
+ End Property
+
+End Class
diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb
index 3b98374..8bd4884 100644
--- a/GBM/Forms/frmMain.vb
+++ b/GBM/Forms/frmMain.vb
@@ -714,6 +714,17 @@ Public Class frmMain
UpdateTimeSpent(dCurrentHours, oProcess.TimeSpent.TotalHours)
End Sub
+ Private Sub HandleSession()
+ Dim oSession As New clsSession
+
+ 'Record Session
+ oSession.MonitorID = oProcess.GameInfo.ID
+ oSession.SessionStart = oProcess.StartTime
+ oSession.SessionEnd = oProcess.EndTime
+
+ mgrSessions.AddSession(oSession)
+ End Sub
+
Private Function SupressBackup() As Boolean
Dim iSession As Integer
If oSettings.SupressBackup Then
@@ -1765,6 +1776,7 @@ Public Class frmMain
bContinue = False
If oSettings.TimeTracking Then
HandleTimeSpent()
+ HandleSession()
End If
UpdateLog(mgrCommon.FormatString(frmMain_ErrorBackupUnknownPath, oProcess.GameInfo.Name), False)
oProcess.GameInfo = Nothing
@@ -1778,6 +1790,7 @@ Public Class frmMain
UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False)
If oSettings.TimeTracking Then
HandleTimeSpent()
+ HandleSession()
End If
RunBackup()
Else
diff --git a/GBM/Game Backup Monitor.vbproj b/GBM/Game Backup Monitor.vbproj
index 52688e2..d77d052 100644
--- a/GBM/Game Backup Monitor.vbproj
+++ b/GBM/Game Backup Monitor.vbproj
@@ -125,6 +125,7 @@
+
@@ -227,6 +228,7 @@
+
diff --git a/GBM/Managers/mgrSQLite.vb b/GBM/Managers/mgrSQLite.vb
index f7bc44c..7c498ad 100644
--- a/GBM/Managers/mgrSQLite.vb
+++ b/GBM/Managers/mgrSQLite.vb
@@ -132,6 +132,10 @@ Public Class mgrSQLite
'Add Tables (Remote Game Tags)
sSql &= "CREATE TABLE gametags (TagID TEXT NOT NULL, MonitorID TEXT NOT NULL, PRIMARY KEY(TagID, MonitorID)); "
+ 'Add Tables (Sessions)
+ sSql &= "CREATE TABLE sessions (MonitorID TEXT NOT NULL, Start INTEGER NOT NULL, End INTEGER NOT NULL, " &
+ "ComputerName TEXT NOT NULL, PRIMARY KEY(MonitorID, Start));"
+
'Set Version
sSql &= "PRAGMA user_version=" & mgrCommon.AppVersion
@@ -697,8 +701,12 @@ Public Class mgrSQLite
'Backup DB before starting
BackupDB("v102")
+ 'Add Tables (Sessions)
+ sSQL = "CREATE TABLE sessions (MonitorID TEXT NOT NULL, Start INTEGER NOT NULL, End INTEGER NOT NULL, " &
+ "ComputerName TEXT NOT NULL, PRIMARY KEY(MonitorID, Start));"
+
'Add new field(s)
- sSQL = "ALTER TABLE monitorlist ADD COLUMN Comments TEXT;"
+ sSQL &= "ALTER TABLE monitorlist ADD COLUMN Comments TEXT;"
sSQL &= "PRAGMA user_version=105"
diff --git a/GBM/Managers/mgrSession.vb b/GBM/Managers/mgrSession.vb
new file mode 100644
index 0000000..36cd9cb
--- /dev/null
+++ b/GBM/Managers/mgrSession.vb
@@ -0,0 +1,35 @@
+Public Class mgrSession
+
+ Private Shared Function MapToObject(ByVal dr As DataRow) As clsSession
+ Dim oSession As New clsSession
+
+ oSession.MonitorID = CStr(dr("MonitorID"))
+ oSession.SessionStart = CStr(dr("Start"))
+ oSession.SessionEnd = CStr(dr("End"))
+
+ Return oSession
+ End Function
+
+ Private Shared Function SetCoreParameters(ByVal oSession As clsSession) As Hashtable
+ Dim hshParams As New Hashtable
+
+ hshParams.Add("MonitorID", oSession.MonitorID)
+ hshParams.Add("Start", oSession.SessionStart)
+ hshParams.Add("End", oSession.SessionEnd)
+
+ Return hshParams
+ End Function
+
+ Public Shared Sub DoSessionAdd(ByVal oSession As clsSession, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local)
+ Dim oDatabase As New mgrSQLite(iSelectDB)
+ Dim sSQL As String
+ Dim hshParams As Hashtable
+
+ sSQL = "INSERT INTO sessions VALUES (@MonitorID, @Start, @End)"
+
+ hshParams = SetCoreParameters(oSession)
+
+ oDatabase.RunParamQuery(sSQL, hshParams)
+ End Sub
+
+End Class
diff --git a/GBM/Managers/mgrSessions.vb b/GBM/Managers/mgrSessions.vb
new file mode 100644
index 0000000..e33c785
--- /dev/null
+++ b/GBM/Managers/mgrSessions.vb
@@ -0,0 +1,49 @@
+Public Class mgrSessions
+
+ Private Shared Function MapToObject(ByVal dr As DataRow) As clsSession
+ Dim oSession As New clsSession
+
+ oSession.MonitorID = CStr(dr("MonitorID"))
+ oSession.SessionStart = mgrCommon.UnixToDate(CInt(dr("Start")))
+ oSession.SessionEnd = mgrCommon.UnixToDate(CInt(dr("End")))
+ oSession.ComputerName = CStr(dr("ComputerName"))
+
+ Return oSession
+ End Function
+
+ Private Shared Function SetCoreParameters(ByVal oSession As clsSession) As Hashtable
+ Dim hshParams As New Hashtable
+
+ hshParams.Add("MonitorID", oSession.MonitorID)
+ hshParams.Add("Start", mgrCommon.DateToUnix(oSession.SessionStart))
+ hshParams.Add("End", mgrCommon.DateToUnix(oSession.SessionEnd))
+ hshParams.Add("ComputerName", oSession.ComputerName)
+
+ Return hshParams
+ End Function
+
+ Public Shared Sub AddSession(ByVal oSession As clsSession)
+ Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Remote)
+ Dim sSQL As String
+ Dim hshParams As Hashtable
+
+ sSQL = "INSERT INTO sessions (MonitorID, Start, End, ComputerName) VALUES (@MonitorID, @Start, @End, @ComputerName);"
+
+ hshParams = SetCoreParameters(oSession)
+
+ oDatabase.RunParamQuery(sSQL, hshParams)
+ End Sub
+
+ Public Shared Function GetSessionsByGame(ByVal sMonitorID As String) As DataSet
+ Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Remote)
+ Dim sSQL As String
+ Dim hshParams As New Hashtable
+
+ sSQL = "SELECT Start, End, ComputerName FROM sessions WHERE MonitorID = @MonitorID;"
+
+ hshParams.Add("MonitorID", sMonitorID)
+
+ Return oDatabase.ReadParamData(sSQL, hshParams)
+ End Function
+
+End Class
\ No newline at end of file