Added basics for issue #99
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -125,6 +125,7 @@
|
||||
<Compile Include="Classes\clsGameFilter.vb" />
|
||||
<Compile Include="Classes\clsGameFilterField.vb" />
|
||||
<Compile Include="Classes\clsSavedPath.vb" />
|
||||
<Compile Include="Classes\clsSession.vb" />
|
||||
<Compile Include="Classes\XML Serialize Classes\ExportData.vb" />
|
||||
<Compile Include="Classes\XML Serialize Classes\ExportInformation.vb" />
|
||||
<Compile Include="Classes\XML Serialize Classes\Tag.vb" />
|
||||
@@ -227,6 +228,7 @@
|
||||
<Compile Include="Managers\mgrPath.vb" />
|
||||
<Compile Include="Managers\mgrRestore.vb" />
|
||||
<Compile Include="Managers\mgrSavedPath.vb" />
|
||||
<Compile Include="Managers\mgrSessions.vb" />
|
||||
<Compile Include="Managers\mgrSettings.vb" />
|
||||
<Compile Include="Managers\mgrBackup.vb" />
|
||||
<Compile Include="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"
|
||||
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user