From 644d073af0d08ce010b82787cd546989d1715627 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Mon, 20 Nov 2017 10:54:06 -0600 Subject: [PATCH 01/21] Changes for issue #109 --- .../XML Serialize Classes/ExportData.vb | 32 +++++++++++++ .../ExportInformation.vb | 32 +++++++++++++ GBM/Game Backup Monitor.vbproj | 2 + GBM/Managers/mgrXML.vb | 46 ++++++++++++++----- 4 files changed, 100 insertions(+), 12 deletions(-) create mode 100644 GBM/Classes/XML Serialize Classes/ExportData.vb create mode 100644 GBM/Classes/XML Serialize Classes/ExportInformation.vb diff --git a/GBM/Classes/XML Serialize Classes/ExportData.vb b/GBM/Classes/XML Serialize Classes/ExportData.vb new file mode 100644 index 0000000..306516e --- /dev/null +++ b/GBM/Classes/XML Serialize Classes/ExportData.vb @@ -0,0 +1,32 @@ +Public Class ExportData + Dim oExportInformation As ExportInformation + Dim oConfigs As List(Of Game) + + Property Information As ExportInformation + Set(value As ExportInformation) + oExportInformation = value + End Set + Get + Return oExportInformation + End Get + End Property + + Property Configurations As List(Of Game) + Set(value As List(Of Game)) + oConfigs = value + End Set + Get + Return oConfigs + End Get + End Property + + Public Sub New() + oExportInformation = New ExportInformation() + oConfigs = New List(Of Game) + End Sub + + Public Sub New(ByVal oInitExportInformation As ExportInformation, ByVal oInitConfigs As List(Of Game)) + oExportInformation = oInitExportInformation + oConfigs = oInitConfigs + End Sub +End Class diff --git a/GBM/Classes/XML Serialize Classes/ExportInformation.vb b/GBM/Classes/XML Serialize Classes/ExportInformation.vb new file mode 100644 index 0000000..8d4ad4a --- /dev/null +++ b/GBM/Classes/XML Serialize Classes/ExportInformation.vb @@ -0,0 +1,32 @@ +Public Class ExportInformation + Private dExported As Int64 + Private iAppVer As Integer + + Property Exported As Int64 + Set(value As Int64) + dExported = value + End Set + Get + Return dExported + End Get + End Property + + Property AppVer As Integer + Set(value As Integer) + iAppVer = value + End Set + Get + Return iAppVer + End Get + End Property + + Public Sub New() + dExported = 0 + iAppVer = 0 + End Sub + + Public Sub New(ByVal dInitExported As Int64, ByVal iInitAppVer As Integer) + dExported = dInitExported + iAppVer = iInitAppVer + End Sub +End Class diff --git a/GBM/Game Backup Monitor.vbproj b/GBM/Game Backup Monitor.vbproj index d747e38..b543ad8 100644 --- a/GBM/Game Backup Monitor.vbproj +++ b/GBM/Game Backup Monitor.vbproj @@ -126,6 +126,8 @@ + + diff --git a/GBM/Managers/mgrXML.vb b/GBM/Managers/mgrXML.vb index 7b4258c..73f512a 100644 --- a/GBM/Managers/mgrXML.vb +++ b/GBM/Managers/mgrXML.vb @@ -46,38 +46,60 @@ Public Class mgrXML Return hshList End Function - Public Shared Function ImportandDeserialize(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) As List(Of Game) + Private Shared Function ReadImportData(ByVal sLocation As String, ByVal bWebRead As Boolean) Dim oReader As StreamReader Dim oWebClient As WebClient + + If bWebRead Then + oWebClient = New WebClient + oReader = New StreamReader(oWebClient.OpenRead(sLocation)) + Else + oReader = New StreamReader(sLocation) + End If + + Return oReader + End Function + + Public Shared Function ImportandDeserialize(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) As List(Of Game) + Dim oReader As StreamReader Dim oSerializer As XmlSerializer - Dim oList As New List(Of Game) + Dim oExportData As New ExportData + Dim oConfigurations As New List(Of Game) Try - If bWebRead Then - oWebClient = New WebClient - oReader = New StreamReader(oWebClient.OpenRead(sLocation)) + oReader = ReadImportData(sLocation, bWebRead) + oSerializer = New XmlSerializer(oExportData.GetType(), New XmlRootAttribute("gbm")) + oExportData = oSerializer.Deserialize(oReader) + oReader.Close() + + 'Compatability Mode + If oExportData.Information.AppVer = 0 Then + oReader = ReadImportData(sLocation, bWebRead) + oSerializer = New XmlSerializer(oConfigurations.GetType(), New XmlRootAttribute("gbm")) + oConfigurations = oSerializer.Deserialize(oReader) + oReader.Close() Else - oReader = New StreamReader(sLocation) + oConfigurations = oExportData.Configurations End If - oSerializer = New XmlSerializer(oList.GetType(), New XmlRootAttribute("gbm")) - oList = oSerializer.Deserialize(oReader) - oReader.Close() Catch ex As Exception mgrCommon.ShowMessage(mgrXML_ErrorImportFailure, ex.Message, MsgBoxStyle.Exclamation) End Try - Return oList + Return oConfigurations End Function Public Shared Function SerializeAndExport(ByVal oList As List(Of Game), ByVal sLocation As String) As Boolean Dim oSerializer As XmlSerializer Dim oWriter As StreamWriter + Dim oExportInformation = New ExportInformation(mgrCommon.DateToUnix(Now), mgrCommon.AppVersion) + Dim oExportData As ExportData Try - oSerializer = New XmlSerializer(oList.GetType(), New XmlRootAttribute("gbm")) + oExportData = New ExportData(oExportInformation, oList) + oSerializer = New XmlSerializer(oExportData.GetType(), New XmlRootAttribute("gbm")) oWriter = New StreamWriter(sLocation) - oSerializer.Serialize(oWriter.BaseStream, oList) + oSerializer.Serialize(oWriter.BaseStream, oExportData) oWriter.Flush() oWriter.Close() Return True From ad4c66605164ad1f75da7c40cbc03165b2b22388 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Mon, 20 Nov 2017 12:56:28 -0600 Subject: [PATCH 02/21] Revert all changes for issue #99 --- GBM/Classes/clsSession.vb | 44 ---------- GBM/Forms/frmGameManager.Designer.vb | 60 ++++++-------- GBM/Forms/frmGameManager.vb | 13 --- GBM/Forms/frmMain.vb | 13 --- GBM/Forms/frmSession.Designer.vb | 63 -------------- GBM/Forms/frmSession.resx | 120 --------------------------- GBM/Forms/frmSession.vb | 37 --------- GBM/Game Backup Monitor.vbproj | 11 --- GBM/Managers/mgrSQLite.vb | 10 +-- GBM/Managers/mgrSessions.vb | 49 ----------- GBM/My Project/Resources.Designer.vb | 45 ---------- GBM/My Project/Resources.resx | 15 ---- 12 files changed, 25 insertions(+), 455 deletions(-) delete mode 100644 GBM/Classes/clsSession.vb delete mode 100644 GBM/Forms/frmSession.Designer.vb delete mode 100644 GBM/Forms/frmSession.resx delete mode 100644 GBM/Forms/frmSession.vb delete mode 100644 GBM/Managers/mgrSessions.vb diff --git a/GBM/Classes/clsSession.vb b/GBM/Classes/clsSession.vb deleted file mode 100644 index cec5e2b..0000000 --- a/GBM/Classes/clsSession.vb +++ /dev/null @@ -1,44 +0,0 @@ -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/frmGameManager.Designer.vb b/GBM/Forms/frmGameManager.Designer.vb index b658e3c..38fb8d0 100644 --- a/GBM/Forms/frmGameManager.Designer.vb +++ b/GBM/Forms/frmGameManager.Designer.vb @@ -28,6 +28,8 @@ Partial Class frmGameManager Me.btnBackup = New System.Windows.Forms.Button() Me.btnClose = New System.Windows.Forms.Button() Me.grpConfig = New System.Windows.Forms.GroupBox() + Me.lblComments = New System.Windows.Forms.Label() + Me.txtComments = New System.Windows.Forms.TextBox() Me.txtParameter = New System.Windows.Forms.TextBox() Me.lblParameter = New System.Windows.Forms.Label() Me.chkCleanFolder = New System.Windows.Forms.CheckBox() @@ -98,9 +100,6 @@ Partial Class frmGameManager Me.cmsDeleteBackup = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.cmsDeleteOne = New System.Windows.Forms.ToolStripMenuItem() Me.cmsDeleteAll = New System.Windows.Forms.ToolStripMenuItem() - Me.btnSessions = New System.Windows.Forms.Button() - Me.txtComments = New System.Windows.Forms.TextBox() - Me.lblComments = New System.Windows.Forms.Label() Me.grpConfig.SuspendLayout() CType(Me.nudLimit, System.ComponentModel.ISupportInitialize).BeginInit() Me.grpExtra.SuspendLayout() @@ -140,7 +139,7 @@ Partial Class frmGameManager Me.btnBackup.Location = New System.Drawing.Point(616, 586) Me.btnBackup.Name = "btnBackup" Me.btnBackup.Size = New System.Drawing.Size(75, 23) - Me.btnBackup.TabIndex = 19 + Me.btnBackup.TabIndex = 18 Me.btnBackup.Text = "&Backup" Me.btnBackup.UseVisualStyleBackColor = True ' @@ -150,7 +149,7 @@ Partial Class frmGameManager Me.btnClose.Location = New System.Drawing.Point(697, 586) Me.btnClose.Name = "btnClose" Me.btnClose.Size = New System.Drawing.Size(75, 23) - Me.btnClose.TabIndex = 20 + Me.btnClose.TabIndex = 19 Me.btnClose.Text = "C&lose" Me.btnClose.UseVisualStyleBackColor = True ' @@ -187,6 +186,24 @@ Partial Class frmGameManager Me.grpConfig.TabStop = False Me.grpConfig.Text = "Configuration" ' + 'lblComments + ' + Me.lblComments.AutoSize = True + Me.lblComments.Location = New System.Drawing.Point(7, 157) + Me.lblComments.Name = "lblComments" + Me.lblComments.Size = New System.Drawing.Size(59, 13) + Me.lblComments.TabIndex = 18 + Me.lblComments.Text = "Comments:" + ' + 'txtComments + ' + Me.txtComments.Location = New System.Drawing.Point(70, 154) + Me.txtComments.Multiline = True + Me.txtComments.Name = "txtComments" + Me.txtComments.ScrollBars = System.Windows.Forms.ScrollBars.Vertical + Me.txtComments.Size = New System.Drawing.Size(413, 54) + Me.txtComments.TabIndex = 17 + ' 'txtParameter ' Me.txtParameter.Location = New System.Drawing.Point(333, 45) @@ -662,7 +679,7 @@ Partial Class frmGameManager Me.btnMarkAsRestored.Location = New System.Drawing.Point(429, 586) Me.btnMarkAsRestored.Name = "btnMarkAsRestored" Me.btnMarkAsRestored.Size = New System.Drawing.Size(100, 23) - Me.btnMarkAsRestored.TabIndex = 17 + Me.btnMarkAsRestored.TabIndex = 16 Me.btnMarkAsRestored.Text = "&Mark as Restored" Me.btnMarkAsRestored.UseVisualStyleBackColor = True ' @@ -672,7 +689,7 @@ Partial Class frmGameManager Me.btnRestore.Location = New System.Drawing.Point(535, 586) Me.btnRestore.Name = "btnRestore" Me.btnRestore.Size = New System.Drawing.Size(75, 23) - Me.btnRestore.TabIndex = 18 + Me.btnRestore.TabIndex = 17 Me.btnRestore.Text = "&Restore" Me.btnRestore.UseVisualStyleBackColor = True ' @@ -844,39 +861,11 @@ Partial Class frmGameManager Me.cmsDeleteAll.Size = New System.Drawing.Size(114, 22) Me.cmsDeleteAll.Text = "&All Files" ' - 'btnSessions - ' - Me.btnSessions.Location = New System.Drawing.Point(323, 586) - Me.btnSessions.Name = "btnSessions" - Me.btnSessions.Size = New System.Drawing.Size(100, 23) - Me.btnSessions.TabIndex = 12 - Me.btnSessions.Text = "&View Sessions..." - Me.btnSessions.UseVisualStyleBackColor = True - ' - 'txtComments - ' - Me.txtComments.Location = New System.Drawing.Point(70, 154) - Me.txtComments.Multiline = True - Me.txtComments.Name = "txtComments" - Me.txtComments.ScrollBars = System.Windows.Forms.ScrollBars.Vertical - Me.txtComments.Size = New System.Drawing.Size(413, 54) - Me.txtComments.TabIndex = 17 - ' - 'lblComments - ' - Me.lblComments.AutoSize = True - Me.lblComments.Location = New System.Drawing.Point(7, 157) - Me.lblComments.Name = "lblComments" - Me.lblComments.Size = New System.Drawing.Size(59, 13) - Me.lblComments.TabIndex = 18 - Me.lblComments.Text = "Comments:" - ' 'frmGameManager ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(784, 621) - Me.Controls.Add(Me.btnSessions) Me.Controls.Add(Me.lblQuickFilter) Me.Controls.Add(Me.txtQuickFilter) Me.Controls.Add(Me.btnExport) @@ -996,7 +985,6 @@ Partial Class frmGameManager Friend WithEvents chkCleanFolder As CheckBox Friend WithEvents txtParameter As TextBox Friend WithEvents lblParameter As Label - Friend WithEvents btnSessions As Button Friend WithEvents lblComments As Label Friend WithEvents txtComments As TextBox End Class diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index b7d68f0..73b9a42 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -907,7 +907,6 @@ Public Class frmGameManager btnExclude.Text = frmGameManager_btnExclude btnImport.Enabled = False btnExport.Enabled = False - btnSessions.Enabled = False Case eModes.Edit grpFilter.Enabled = False lstGames.Enabled = False @@ -932,7 +931,6 @@ Public Class frmGameManager lblTags.Visible = True btnImport.Enabled = False btnExport.Enabled = False - btnSessions.Enabled = False Case eModes.View grpFilter.Enabled = True lstGames.Enabled = True @@ -952,7 +950,6 @@ Public Class frmGameManager lblTags.Visible = True btnImport.Enabled = True btnExport.Enabled = True - btnSessions.Enabled = True Case eModes.ViewTemp grpFilter.Enabled = True lstGames.Enabled = True @@ -975,7 +972,6 @@ Public Class frmGameManager btnExclude.Text = frmGameManager_btnExclude btnImport.Enabled = True btnExport.Enabled = True - btnSessions.Enabled = False Case eModes.Disabled grpFilter.Enabled = True lstGames.Enabled = True @@ -1003,7 +999,6 @@ Public Class frmGameManager btnExclude.Text = frmGameManager_btnExclude btnImport.Enabled = True btnExport.Enabled = True - btnSessions.Enabled = False Case eModes.MultiSelect lstGames.Enabled = True lblQuickFilter.Enabled = False @@ -1030,7 +1025,6 @@ Public Class frmGameManager lblTags.Visible = False btnImport.Enabled = True btnExport.Enabled = True - btnSessions.Enabled = False End Select lstGames.Focus() @@ -1555,7 +1549,6 @@ Public Class frmGameManager lblLimit.Text = frmGameManager_lblLimit cmsDeleteOne.Text = frmGameManager_cmsDeleteOne cmsDeleteAll.Text = frmGameManager_cmsDeleteAll - btnSessions.Text = frmGameManager_btnSessions 'Init Filter Timer tmFilterTimer = New Timer() @@ -1735,12 +1728,6 @@ Public Class frmGameManager ExportGameList() End Sub - Private Sub btnSessions_Click(sender As Object, e As EventArgs) Handles btnSessions.Click - Dim frm As New frmSession - frm.Game = CurrentGame - frm.ShowDialog() - End Sub - Private Sub txtQuickFilter_TextChanged(sender As Object, e As EventArgs) Handles txtQuickFilter.TextChanged If Not tmFilterTimer.Enabled Then tmFilterTimer.Enabled = True diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index db15ac7..f1991d2 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -714,17 +714,6 @@ 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 @@ -1777,7 +1766,6 @@ 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 @@ -1791,7 +1779,6 @@ 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/Forms/frmSession.Designer.vb b/GBM/Forms/frmSession.Designer.vb deleted file mode 100644 index 0af880c..0000000 --- a/GBM/Forms/frmSession.Designer.vb +++ /dev/null @@ -1,63 +0,0 @@ - _ -Partial Class frmSession - Inherits System.Windows.Forms.Form - - 'Form overrides dispose to clean up the component list. - _ - Protected Overrides Sub Dispose(ByVal disposing As Boolean) - Try - If disposing AndAlso components IsNot Nothing Then - components.Dispose() - End If - Finally - MyBase.Dispose(disposing) - End Try - End Sub - - 'Required by the Windows Form Designer - Private components As System.ComponentModel.IContainer - - 'NOTE: The following procedure is required by the Windows Form Designer - 'It can be modified using the Windows Form Designer. - 'Do not modify it using the code editor. - _ - Private Sub InitializeComponent() - Me.dgSessions = New System.Windows.Forms.DataGridView() - CType(Me.dgSessions, System.ComponentModel.ISupportInitialize).BeginInit() - Me.SuspendLayout() - ' - 'dgSessions - ' - Me.dgSessions.AllowUserToAddRows = False - Me.dgSessions.AllowUserToDeleteRows = False - Me.dgSessions.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize - Me.dgSessions.Location = New System.Drawing.Point(11, 11) - Me.dgSessions.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) - Me.dgSessions.Name = "dgSessions" - Me.dgSessions.ReadOnly = True - Me.dgSessions.RowHeadersVisible = False - Me.dgSessions.RowTemplate.Height = 24 - Me.dgSessions.Size = New System.Drawing.Size(612, 389) - Me.dgSessions.TabIndex = 0 - ' - 'frmSession - ' - Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) - Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(634, 411) - Me.Controls.Add(Me.dgSessions) - Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle - Me.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) - Me.MaximizeBox = False - Me.MinimizeBox = False - Me.Name = "frmSession" - Me.ShowIcon = False - Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen - Me.Text = "Sessions" - CType(Me.dgSessions, System.ComponentModel.ISupportInitialize).EndInit() - Me.ResumeLayout(False) - - End Sub - - Friend WithEvents dgSessions As DataGridView -End Class diff --git a/GBM/Forms/frmSession.resx b/GBM/Forms/frmSession.resx deleted file mode 100644 index 1af7de1..0000000 --- a/GBM/Forms/frmSession.resx +++ /dev/null @@ -1,120 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 2.0 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - \ No newline at end of file diff --git a/GBM/Forms/frmSession.vb b/GBM/Forms/frmSession.vb deleted file mode 100644 index 0f62ec7..0000000 --- a/GBM/Forms/frmSession.vb +++ /dev/null @@ -1,37 +0,0 @@ -Imports GBM.My.Resources - -Public Class frmSession - - Private oGame As clsGame - - Property Game As clsGame - Set(value As clsGame) - oGame = value - End Set - Get - Return oGame - End Get - End Property - - Private Sub FormatGrid() - dgSessions.Columns.Add("Start", frmSession_ColumnStart) - dgSessions.Columns.Add("End", frmSession_ColumnEnd) - dgSessions.Columns.Add("Name", frmSession_ColumnComputerName) - End Sub - - Private Sub LoadData() - Me.Text = Game.Name & " " & frmSession_Name - - Dim oData As DataSet = mgrSessions.GetSessionsByGame(Game.ID) - - For Each dr As DataRow In oData.Tables(0).Rows - dgSessions.Rows.Add(New Object() {mgrCommon.UnixToDate(dr("Start")), mgrCommon.UnixToDate(dr("End")), dr("ComputerName")}) - Next - dgSessions.AutoResizeColumns() - End Sub - - Private Sub frmSession_Load(sender As Object, e As EventArgs) Handles MyBase.Load - FormatGrid() - LoadData() - End Sub -End Class \ No newline at end of file diff --git a/GBM/Game Backup Monitor.vbproj b/GBM/Game Backup Monitor.vbproj index b543ad8..52688e2 100644 --- a/GBM/Game Backup Monitor.vbproj +++ b/GBM/Game Backup Monitor.vbproj @@ -125,7 +125,6 @@ - @@ -171,12 +170,6 @@ Form - - frmSession.vb - - - Form - frmStartUpWizard.vb @@ -234,7 +227,6 @@ - @@ -277,9 +269,6 @@ frmIncludeExclude.vb - - frmSession.vb - frmStartUpWizard.vb Designer diff --git a/GBM/Managers/mgrSQLite.vb b/GBM/Managers/mgrSQLite.vb index 937a0a1..f7bc44c 100644 --- a/GBM/Managers/mgrSQLite.vb +++ b/GBM/Managers/mgrSQLite.vb @@ -132,10 +132,6 @@ 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 @@ -701,12 +697,8 @@ 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/mgrSessions.vb b/GBM/Managers/mgrSessions.vb deleted file mode 100644 index ce92811..0000000 --- a/GBM/Managers/mgrSessions.vb +++ /dev/null @@ -1,49 +0,0 @@ -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 diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 9acc98a..d1c3aba 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -1536,15 +1536,6 @@ Namespace My.Resources End Get End Property - ''' - ''' Looks up a localized string similar to &View Sessions.... - ''' - Friend ReadOnly Property frmGameManager_btnSessions() As String - Get - Return ResourceManager.GetString("frmGameManager_btnSessions", resourceCulture) - End Get - End Property - ''' ''' Looks up a localized string similar to Tags.... ''' @@ -3570,42 +3561,6 @@ Namespace My.Resources End Get End Property - ''' - ''' Looks up a localized string similar to Computer Name. - ''' - Friend ReadOnly Property frmSession_ColumnComputerName() As String - Get - Return ResourceManager.GetString("frmSession_ColumnComputerName", resourceCulture) - End Get - End Property - - ''' - ''' Looks up a localized string similar to End. - ''' - Friend ReadOnly Property frmSession_ColumnEnd() As String - Get - Return ResourceManager.GetString("frmSession_ColumnEnd", resourceCulture) - End Get - End Property - - ''' - ''' Looks up a localized string similar to Start. - ''' - Friend ReadOnly Property frmSession_ColumnStart() As String - Get - Return ResourceManager.GetString("frmSession_ColumnStart", resourceCulture) - End Get - End Property - - ''' - ''' Looks up a localized string similar to Sessions. - ''' - Friend ReadOnly Property frmSession_Name() As String - Get - Return ResourceManager.GetString("frmSession_Name", resourceCulture) - End Get - End Property - ''' ''' Looks up a localized string similar to Executable. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 06677f7..d190a54 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1885,21 +1885,6 @@ Sort Options - - &View Sessions... - - - Computer Name - - - End - - - Start - - - Sessions - Comments From d610b2507ec9735a46b413d487c08131cb03768d Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Tue, 21 Nov 2017 13:49:27 -0600 Subject: [PATCH 03/21] Changes for issue #103 --- GBM/Classes/clsGameFilter.vb | 10 ++ GBM/Forms/frmFilter.Designer.vb | 183 +++++++++++++++++++-------- GBM/Forms/frmFilter.vb | 120 +++++++++++++----- GBM/Forms/frmGameManager.vb | 14 +- GBM/Managers/mgrMonitorList.vb | 120 ++++++++++++++---- GBM/My Project/Resources.Designer.vb | 72 ++++++++--- GBM/My Project/Resources.resx | 26 +++- 7 files changed, 401 insertions(+), 144 deletions(-) diff --git a/GBM/Classes/clsGameFilter.vb b/GBM/Classes/clsGameFilter.vb index b1395d3..191cef6 100644 --- a/GBM/Classes/clsGameFilter.vb +++ b/GBM/Classes/clsGameFilter.vb @@ -2,6 +2,7 @@ Private sID As String Private oField As clsGameFilterField + Private bNot As Boolean Private oData As Object Private eNumericOperator As eNumericOperators = eNumericOperators.Equals @@ -31,6 +32,15 @@ End Set End Property + Public Property NotCondition As Boolean + Get + Return bNot + End Get + Set(value As Boolean) + bNot = value + End Set + End Property + Public Property Data As Object Get Return oData diff --git a/GBM/Forms/frmFilter.Designer.vb b/GBM/Forms/frmFilter.Designer.vb index 71f4469..ddfcc1d 100644 --- a/GBM/Forms/frmFilter.Designer.vb +++ b/GBM/Forms/frmFilter.Designer.vb @@ -23,17 +23,23 @@ Partial Class frmFilter _ Private Sub InitializeComponent() Me.grpTagFilter = New System.Windows.Forms.GroupBox() + Me.lblExcludeTags = New System.Windows.Forms.Label() + Me.btnExcludeRemove = New System.Windows.Forms.Button() + Me.btnExcludeAdd = New System.Windows.Forms.Button() + Me.lstExcludeTags = New System.Windows.Forms.ListBox() Me.grpTagOptions = New System.Windows.Forms.GroupBox() Me.optAll = New System.Windows.Forms.RadioButton() Me.optAny = New System.Windows.Forms.RadioButton() - Me.lblGameTags = New System.Windows.Forms.Label() + Me.lblIncludeTags = New System.Windows.Forms.Label() Me.lblTags = New System.Windows.Forms.Label() - Me.btnRemove = New System.Windows.Forms.Button() - Me.btnAdd = New System.Windows.Forms.Button() - Me.lstTagFilter = New System.Windows.Forms.ListBox() + Me.btnIncludeRemove = New System.Windows.Forms.Button() + Me.btnIncludeAdd = New System.Windows.Forms.Button() + Me.lstIncludeTags = New System.Windows.Forms.ListBox() Me.lstTags = New System.Windows.Forms.ListBox() Me.btnOK = New System.Windows.Forms.Button() Me.grpGameFilter = New System.Windows.Forms.GroupBox() + Me.lblNot = New System.Windows.Forms.Label() + Me.chkNot = New System.Windows.Forms.CheckBox() Me.cboBoolFilter = New System.Windows.Forms.ComboBox() Me.numFilter = New System.Windows.Forms.NumericUpDown() Me.cboNumericOps = New System.Windows.Forms.ComboBox() @@ -68,19 +74,60 @@ Partial Class frmFilter ' 'grpTagFilter ' + Me.grpTagFilter.Controls.Add(Me.lblExcludeTags) + Me.grpTagFilter.Controls.Add(Me.btnExcludeRemove) + Me.grpTagFilter.Controls.Add(Me.btnExcludeAdd) + Me.grpTagFilter.Controls.Add(Me.lstExcludeTags) Me.grpTagFilter.Controls.Add(Me.grpTagOptions) - Me.grpTagFilter.Controls.Add(Me.lblGameTags) + Me.grpTagFilter.Controls.Add(Me.lblIncludeTags) Me.grpTagFilter.Controls.Add(Me.lblTags) - Me.grpTagFilter.Controls.Add(Me.btnRemove) - Me.grpTagFilter.Controls.Add(Me.btnAdd) - Me.grpTagFilter.Controls.Add(Me.lstTagFilter) + Me.grpTagFilter.Controls.Add(Me.btnIncludeRemove) + Me.grpTagFilter.Controls.Add(Me.btnIncludeAdd) + Me.grpTagFilter.Controls.Add(Me.lstIncludeTags) Me.grpTagFilter.Controls.Add(Me.lstTags) Me.grpTagFilter.Location = New System.Drawing.Point(12, 236) Me.grpTagFilter.Name = "grpTagFilter" - Me.grpTagFilter.Size = New System.Drawing.Size(385, 198) + Me.grpTagFilter.Size = New System.Drawing.Size(410, 198) Me.grpTagFilter.TabIndex = 3 Me.grpTagFilter.TabStop = False ' + 'lblExcludeTags + ' + Me.lblExcludeTags.AutoSize = True + Me.lblExcludeTags.Location = New System.Drawing.Point(313, 16) + Me.lblExcludeTags.Name = "lblExcludeTags" + Me.lblExcludeTags.Size = New System.Drawing.Size(72, 13) + Me.lblExcludeTags.TabIndex = 10 + Me.lblExcludeTags.Text = "Exclude Tags" + ' + 'btnExcludeRemove + ' + Me.btnExcludeRemove.Location = New System.Drawing.Point(261, 91) + Me.btnExcludeRemove.Name = "btnExcludeRemove" + Me.btnExcludeRemove.Size = New System.Drawing.Size(31, 23) + Me.btnExcludeRemove.TabIndex = 9 + Me.btnExcludeRemove.Text = "<" + Me.btnExcludeRemove.UseVisualStyleBackColor = True + ' + 'btnExcludeAdd + ' + Me.btnExcludeAdd.Location = New System.Drawing.Point(261, 62) + Me.btnExcludeAdd.Name = "btnExcludeAdd" + Me.btnExcludeAdd.Size = New System.Drawing.Size(31, 23) + Me.btnExcludeAdd.TabIndex = 8 + Me.btnExcludeAdd.Text = ">" + Me.btnExcludeAdd.UseVisualStyleBackColor = True + ' + 'lstExcludeTags + ' + Me.lstExcludeTags.FormattingEnabled = True + Me.lstExcludeTags.Location = New System.Drawing.Point(298, 32) + Me.lstExcludeTags.Name = "lstExcludeTags" + Me.lstExcludeTags.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended + Me.lstExcludeTags.Size = New System.Drawing.Size(103, 108) + Me.lstExcludeTags.Sorted = True + Me.lstExcludeTags.TabIndex = 7 + ' 'grpTagOptions ' Me.grpTagOptions.Controls.Add(Me.optAll) @@ -113,65 +160,65 @@ Partial Class frmFilter Me.optAny.Text = "Any Tag" Me.optAny.UseVisualStyleBackColor = True ' - 'lblGameTags + 'lblIncludeTags ' - Me.lblGameTags.AutoSize = True - Me.lblGameTags.Location = New System.Drawing.Point(271, 16) - Me.lblGameTags.Name = "lblGameTags" - Me.lblGameTags.Size = New System.Drawing.Size(66, 13) - Me.lblGameTags.TabIndex = 4 - Me.lblGameTags.Text = "Current Filter" + Me.lblIncludeTags.AutoSize = True + Me.lblIncludeTags.Location = New System.Drawing.Point(23, 16) + Me.lblIncludeTags.Name = "lblIncludeTags" + Me.lblIncludeTags.Size = New System.Drawing.Size(69, 13) + Me.lblIncludeTags.TabIndex = 4 + Me.lblIncludeTags.Text = "Include Tags" ' 'lblTags ' Me.lblTags.AutoSize = True - Me.lblTags.Location = New System.Drawing.Point(43, 16) + Me.lblTags.Location = New System.Drawing.Point(165, 16) Me.lblTags.Name = "lblTags" Me.lblTags.Size = New System.Drawing.Size(77, 13) Me.lblTags.TabIndex = 0 Me.lblTags.Text = "Available Tags" ' - 'btnRemove + 'btnIncludeRemove ' - Me.btnRemove.Location = New System.Drawing.Point(162, 88) - Me.btnRemove.Name = "btnRemove" - Me.btnRemove.Size = New System.Drawing.Size(61, 23) - Me.btnRemove.TabIndex = 3 - Me.btnRemove.Text = "<" - Me.btnRemove.UseVisualStyleBackColor = True + Me.btnIncludeRemove.Location = New System.Drawing.Point(115, 91) + Me.btnIncludeRemove.Name = "btnIncludeRemove" + Me.btnIncludeRemove.Size = New System.Drawing.Size(31, 23) + Me.btnIncludeRemove.TabIndex = 3 + Me.btnIncludeRemove.Text = ">" + Me.btnIncludeRemove.UseVisualStyleBackColor = True ' - 'btnAdd + 'btnIncludeAdd ' - Me.btnAdd.Location = New System.Drawing.Point(162, 59) - Me.btnAdd.Name = "btnAdd" - Me.btnAdd.Size = New System.Drawing.Size(61, 23) - Me.btnAdd.TabIndex = 2 - Me.btnAdd.Text = ">" - Me.btnAdd.UseVisualStyleBackColor = True + Me.btnIncludeAdd.Location = New System.Drawing.Point(115, 62) + Me.btnIncludeAdd.Name = "btnIncludeAdd" + Me.btnIncludeAdd.Size = New System.Drawing.Size(31, 23) + Me.btnIncludeAdd.TabIndex = 2 + Me.btnIncludeAdd.Text = "<" + Me.btnIncludeAdd.UseVisualStyleBackColor = True ' - 'lstTagFilter + 'lstIncludeTags ' - Me.lstTagFilter.FormattingEnabled = True - Me.lstTagFilter.Location = New System.Drawing.Point(229, 32) - Me.lstTagFilter.Name = "lstTagFilter" - Me.lstTagFilter.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended - Me.lstTagFilter.Size = New System.Drawing.Size(150, 108) - Me.lstTagFilter.Sorted = True - Me.lstTagFilter.TabIndex = 5 + Me.lstIncludeTags.FormattingEnabled = True + Me.lstIncludeTags.Location = New System.Drawing.Point(6, 32) + Me.lstIncludeTags.Name = "lstIncludeTags" + Me.lstIncludeTags.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended + Me.lstIncludeTags.Size = New System.Drawing.Size(103, 108) + Me.lstIncludeTags.Sorted = True + Me.lstIncludeTags.TabIndex = 5 ' 'lstTags ' Me.lstTags.FormattingEnabled = True - Me.lstTags.Location = New System.Drawing.Point(6, 32) + Me.lstTags.Location = New System.Drawing.Point(152, 32) Me.lstTags.Name = "lstTags" Me.lstTags.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended - Me.lstTags.Size = New System.Drawing.Size(150, 108) + Me.lstTags.Size = New System.Drawing.Size(103, 108) Me.lstTags.Sorted = True Me.lstTags.TabIndex = 1 ' 'btnOK ' - Me.btnOK.Location = New System.Drawing.Point(322, 526) + Me.btnOK.Location = New System.Drawing.Point(347, 526) Me.btnOK.Name = "btnOK" Me.btnOK.Size = New System.Drawing.Size(75, 23) Me.btnOK.TabIndex = 6 @@ -180,6 +227,8 @@ Partial Class frmFilter ' 'grpGameFilter ' + Me.grpGameFilter.Controls.Add(Me.lblNot) + Me.grpGameFilter.Controls.Add(Me.chkNot) Me.grpGameFilter.Controls.Add(Me.cboBoolFilter) Me.grpGameFilter.Controls.Add(Me.numFilter) Me.grpGameFilter.Controls.Add(Me.cboNumericOps) @@ -194,15 +243,33 @@ Partial Class frmFilter Me.grpGameFilter.Controls.Add(Me.txtStringFilter) Me.grpGameFilter.Location = New System.Drawing.Point(12, 35) Me.grpGameFilter.Name = "grpGameFilter" - Me.grpGameFilter.Size = New System.Drawing.Size(385, 172) + Me.grpGameFilter.Size = New System.Drawing.Size(410, 172) Me.grpGameFilter.TabIndex = 1 Me.grpGameFilter.TabStop = False ' + 'lblNot + ' + Me.lblNot.AutoSize = True + Me.lblNot.Location = New System.Drawing.Point(161, 20) + Me.lblNot.Name = "lblNot" + Me.lblNot.Size = New System.Drawing.Size(24, 13) + Me.lblNot.TabIndex = 11 + Me.lblNot.Text = "Not" + ' + 'chkNot + ' + Me.chkNot.AutoSize = True + Me.chkNot.Location = New System.Drawing.Point(166, 39) + Me.chkNot.Name = "chkNot" + Me.chkNot.Size = New System.Drawing.Size(15, 14) + Me.chkNot.TabIndex = 10 + Me.chkNot.UseVisualStyleBackColor = True + ' 'cboBoolFilter ' Me.cboBoolFilter.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.cboBoolFilter.FormattingEnabled = True - Me.cboBoolFilter.Location = New System.Drawing.Point(162, 36) + Me.cboBoolFilter.Location = New System.Drawing.Point(187, 36) Me.cboBoolFilter.Name = "cboBoolFilter" Me.cboBoolFilter.Size = New System.Drawing.Size(136, 21) Me.cboBoolFilter.TabIndex = 3 @@ -210,7 +277,7 @@ Partial Class frmFilter 'numFilter ' Me.numFilter.DecimalPlaces = 1 - Me.numFilter.Location = New System.Drawing.Point(233, 37) + Me.numFilter.Location = New System.Drawing.Point(258, 37) Me.numFilter.Maximum = New Decimal(New Integer() {1000000, 0, 0, 0}) Me.numFilter.Name = "numFilter" Me.numFilter.Size = New System.Drawing.Size(65, 20) @@ -220,7 +287,7 @@ Partial Class frmFilter ' Me.cboNumericOps.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList Me.cboNumericOps.FormattingEnabled = True - Me.cboNumericOps.Location = New System.Drawing.Point(162, 36) + Me.cboNumericOps.Location = New System.Drawing.Point(188, 36) Me.cboNumericOps.Name = "cboNumericOps" Me.cboNumericOps.Size = New System.Drawing.Size(65, 21) Me.cboNumericOps.TabIndex = 3 @@ -237,7 +304,7 @@ Partial Class frmFilter 'lblFilterData ' Me.lblFilterData.AutoSize = True - Me.lblFilterData.Location = New System.Drawing.Point(214, 20) + Me.lblFilterData.Location = New System.Drawing.Point(239, 20) Me.lblFilterData.Name = "lblFilterData" Me.lblFilterData.Size = New System.Drawing.Size(32, 13) Me.lblFilterData.TabIndex = 2 @@ -271,7 +338,7 @@ Partial Class frmFilter ' 'btnAddFilter ' - Me.btnAddFilter.Location = New System.Drawing.Point(304, 34) + Me.btnAddFilter.Location = New System.Drawing.Point(329, 34) Me.btnAddFilter.Name = "btnAddFilter" Me.btnAddFilter.Size = New System.Drawing.Size(75, 23) Me.btnAddFilter.TabIndex = 5 @@ -320,7 +387,7 @@ Partial Class frmFilter ' 'txtStringFilter ' - Me.txtStringFilter.Location = New System.Drawing.Point(162, 36) + Me.txtStringFilter.Location = New System.Drawing.Point(187, 36) Me.txtStringFilter.Name = "txtStringFilter" Me.txtStringFilter.Size = New System.Drawing.Size(136, 20) Me.txtStringFilter.TabIndex = 3 @@ -332,7 +399,7 @@ Partial Class frmFilter Me.grpSorting.Controls.Add(Me.cboSortField) Me.grpSorting.Location = New System.Drawing.Point(12, 440) Me.grpSorting.Name = "grpSorting" - Me.grpSorting.Size = New System.Drawing.Size(385, 80) + Me.grpSorting.Size = New System.Drawing.Size(410, 80) Me.grpSorting.TabIndex = 4 Me.grpSorting.TabStop = False Me.grpSorting.Text = "Sorting" @@ -421,7 +488,7 @@ Partial Class frmFilter ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font - Me.ClientSize = New System.Drawing.Size(409, 561) + Me.ClientSize = New System.Drawing.Size(434, 561) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.grpSorting) Me.Controls.Add(Me.chkTag) @@ -455,11 +522,11 @@ Partial Class frmFilter Friend WithEvents grpTagOptions As System.Windows.Forms.GroupBox Friend WithEvents optAll As System.Windows.Forms.RadioButton Friend WithEvents optAny As System.Windows.Forms.RadioButton - Friend WithEvents lblGameTags As System.Windows.Forms.Label + Friend WithEvents lblIncludeTags As System.Windows.Forms.Label Friend WithEvents lblTags As System.Windows.Forms.Label - Friend WithEvents btnRemove As System.Windows.Forms.Button - Friend WithEvents btnAdd As System.Windows.Forms.Button - Friend WithEvents lstTagFilter As System.Windows.Forms.ListBox + Friend WithEvents btnIncludeRemove As System.Windows.Forms.Button + Friend WithEvents btnIncludeAdd As System.Windows.Forms.Button + Friend WithEvents lstIncludeTags As System.Windows.Forms.ListBox Friend WithEvents lstTags As System.Windows.Forms.ListBox Friend WithEvents btnOK As System.Windows.Forms.Button Friend WithEvents grpGameFilter As System.Windows.Forms.GroupBox @@ -486,4 +553,10 @@ Partial Class frmFilter Friend WithEvents lblSortFields As Label Friend WithEvents Label1 As Label Friend WithEvents grpSortOptions As GroupBox + Friend WithEvents lblExcludeTags As Label + Friend WithEvents btnExcludeRemove As Button + Friend WithEvents btnExcludeAdd As Button + Friend WithEvents lstExcludeTags As ListBox + Friend WithEvents lblNot As Label + Friend WithEvents chkNot As CheckBox End Class diff --git a/GBM/Forms/frmFilter.vb b/GBM/Forms/frmFilter.vb index 6464c24..2a98186 100644 --- a/GBM/Forms/frmFilter.vb +++ b/GBM/Forms/frmFilter.vb @@ -9,7 +9,8 @@ Public Class frmFilter NoTags = 4 End Enum - Dim oTagFilters As New List(Of clsTag) + Dim oIncludeTagFilters As New List(Of clsTag) + Dim oExcludeTagFilters As New List(Of clsTag) Dim oGameFilters As New List(Of clsGameFilter) Dim oValidFields As New List(Of clsGameFilterField) Dim eCurrentFilterType As eFilterType = eFilterType.BaseFilter @@ -28,12 +29,21 @@ Public Class frmFilter End Set End Property - Public Property TagFilters As List(Of clsTag) + Public Property IncludeTagFilters As List(Of clsTag) Get - Return oTagFilters + Return oIncludeTagFilters End Get Set(value As List(Of clsTag)) - oTagFilters = value + oIncludeTagFilters = value + End Set + End Property + + Public Property ExcludeTagFilters As List(Of clsTag) + Get + Return oExcludeTagFilters + End Get + Set(value As List(Of clsTag)) + oExcludeTagFilters = value End Set End Property @@ -73,13 +83,13 @@ Public Class frmFilter End Set End Property - Private Sub AddTag() + Private Sub AddTag(ByRef lst As ListBox) Dim oData As KeyValuePair(Of String, String) Dim oTags As List(Of KeyValuePair(Of String, String)) If lstTags.SelectedItems.Count = 1 Then oData = lstTags.SelectedItems(0) - lstTagFilter.Items.Add(oData) + lst.Items.Add(oData) lstTags.Items.Remove(oData) ElseIf lstTags.SelectedItems.Count > 1 Then oTags = New List(Of KeyValuePair(Of String, String)) @@ -89,30 +99,30 @@ Public Class frmFilter Next For Each kp As KeyValuePair(Of String, String) In oTags - lstTagFilter.Items.Add(kp) + lst.Items.Add(kp) lstTags.Items.Remove(kp) Next End If End Sub - Private Sub RemoveTag() + Private Sub RemoveTag(ByRef lst As ListBox) Dim oData As KeyValuePair(Of String, String) Dim oTags As List(Of KeyValuePair(Of String, String)) - If lstTagFilter.SelectedItems.Count = 1 Then - oData = lstTagFilter.SelectedItems(0) - lstTagFilter.Items.Remove(oData) + If lst.SelectedItems.Count = 1 Then + oData = lst.SelectedItems(0) + lst.Items.Remove(oData) lstTags.Items.Add(oData) - ElseIf lstTagFilter.SelectedItems.Count > 1 Then + ElseIf lst.SelectedItems.Count > 1 Then oTags = New List(Of KeyValuePair(Of String, String)) - For Each oData In lstTagFilter.SelectedItems + For Each oData In lst.SelectedItems oTags.Add(oData) Next For Each kp As KeyValuePair(Of String, String) In oTags - lstTagFilter.Items.Remove(kp) + lst.Items.Remove(kp) lstTags.Items.Add(kp) Next End If @@ -283,13 +293,17 @@ Public Class frmFilter 'Handle Lists lstTags.Items.Clear() - lstTagFilter.Items.Clear() + lstIncludeTags.Items.Clear() + lstExcludeTags.Items.Clear() lstTags.ValueMember = "Key" lstTags.DisplayMember = "Value" - lstTagFilter.ValueMember = "Key" - lstTagFilter.DisplayMember = "Value" + lstIncludeTags.ValueMember = "Key" + lstIncludeTags.DisplayMember = "Value" + + lstExcludeTags.ValueMember = "Key" + lstExcludeTags.DisplayMember = "Value" For Each de As DictionaryEntry In hshTags oTag = DirectCast(de.Value, clsTag) @@ -322,16 +336,35 @@ Public Class frmFilter sFilter = oFilter.Field.FriendlyFieldName & " = " & oFilter.Data End Select + If oFilter.NotCondition Then + sFilter &= " (" & frmFilter_lblNot & ")" + End If + lstFilter.Items.Add(New KeyValuePair(Of clsGameFilter, String)(oFilter, sFilter)) Next End If 'Tag Filters - If oTagFilters.Count > 0 Then + If oIncludeTagFilters.Count > 0 Then chkTag.Checked = True - For Each oTag As clsTag In oTagFilters + For Each oTag As clsTag In oIncludeTagFilters oListTag = New KeyValuePair(Of String, String)(oTag.ID, oTag.Name) - lstTagFilter.Items.Add(oListTag) + lstIncludeTags.Items.Add(oListTag) + lstTags.Items.Remove(oListTag) + Next + + If eCurrentFilterType = eFilterType.AllTags Then + optAll.Checked = True + Else + optAny.Checked = True + End If + End If + + If oExcludeTagFilters.Count > 0 Then + chkTag.Checked = True + For Each oTag As clsTag In oExcludeTagFilters + oListTag = New KeyValuePair(Of String, String)(oTag.ID, oTag.Name) + lstExcludeTags.Items.Add(oListTag) lstTags.Items.Remove(oListTag) Next @@ -402,6 +435,13 @@ Public Class frmFilter sFilter = oFilter.Field.FriendlyFieldName & " = " & oFilter.Data End Select + If chkNot.Checked Then + oFilter.NotCondition = True + sFilter &= " (" & frmFilter_lblNot & ")" + Else + oFilter.NotCondition = False + End If + oGameFilters.Add(oFilter) lstFilter.Items.Add(New KeyValuePair(Of clsGameFilter, String)(oFilter, sFilter)) @@ -431,14 +471,19 @@ Public Class frmFilter If chkTag.Checked Then 'Set Tags - TagFilters.Clear() - For Each oData In lstTagFilter.Items + IncludeTagFilters.Clear() + For Each oData In lstIncludeTags.Items oTag = DirectCast(hshTags(oData.Value), clsTag) - TagFilters.Add(oTag) + IncludeTagFilters.Add(oTag) + Next + ExcludeTagFilters.Clear() + For Each oData In lstExcludeTags.Items + oTag = DirectCast(hshTags(oData.Value), clsTag) + ExcludeTagFilters.Add(oTag) Next 'Set Filter Type - If TagFilters.Count = 0 Then + If IncludeTagFilters.Count = 0 And ExcludeTagFilters.Count = 0 Then eCurrentFilterType = eFilterType.NoTags ElseIf optAll.Checked Then eCurrentFilterType = eFilterType.AllTags @@ -525,10 +570,13 @@ Public Class frmFilter grpFilterType.Text = frmFilter_grpFilterType optAll.Text = frmFilter_optAll optAny.Text = frmFilter_optAny - lblGameTags.Text = frmFilter_lblGameTags + lblIncludeTags.Text = frmFilter_lblIncludeTags + lblExcludeTags.Text = frmFilter_lblExcludeTags lblTags.Text = frmFilter_lblTags - btnRemove.Text = frmFilter_btnRemove - btnAdd.Text = frmFilter_btnAdd + btnIncludeRemove.Text = frmFilter_btnIncludeRemove + btnIncludeAdd.Text = frmFilter_btnIncludeAdd + btnExcludeRemove.Text = frmFilter_btnExcludeRemove + btnExcludeAdd.Text = frmFilter_btnExcludeAdd btnOK.Text = frmFilter_btnOK grpTagOptions.Text = frmFilter_grpTagOptions chkTag.Text = frmFilter_chkTag @@ -569,12 +617,20 @@ Public Class frmFilter Me.Close() End Sub - Private Sub btnAdd_Click(sender As Object, e As EventArgs) Handles btnAdd.Click - AddTag() + Private Sub btnIncludeAdd_Click(sender As Object, e As EventArgs) Handles btnIncludeAdd.Click + AddTag(lstIncludeTags) End Sub - Private Sub btnRemove_Click(sender As Object, e As EventArgs) Handles btnRemove.Click - RemoveTag() + Private Sub btnExcludeAdd_Click(sender As Object, e As EventArgs) Handles btnExcludeAdd.Click + AddTag(lstExcludeTags) + End Sub + + Private Sub btnExcludeRemove_Click(sender As Object, e As EventArgs) Handles btnExcludeRemove.Click + RemoveTag(lstExcludeTags) + End Sub + + Private Sub btnIncludeRemove_Click(sender As Object, e As EventArgs) Handles btnIncludeRemove.Click + RemoveTag(lstIncludeTags) End Sub Private Sub frmFilter_FormClosing(sender As Object, e As FormClosingEventArgs) Handles MyBase.FormClosing @@ -599,7 +655,7 @@ Public Class frmFilter grpTagFilter.Enabled = True Else grpTagFilter.Enabled = False - oTagFilters.Clear() + oIncludeTagFilters.Clear() LoadTagData() End If End Sub diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 73b9a42..57cee42 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -19,7 +19,8 @@ Public Class frmGameManager Private oRemoteBackupData As SortedList Private bIsDirty As Boolean = False Private bIsLoading As Boolean = False - Private oCurrentTagFilters As New List(Of clsTag) + Private oCurrentIncludeTagFilters As New List(Of clsTag) + Private oCurrentExcludeTagFilters As New List(Of clsTag) Private oCurrentFilters As New List(Of clsGameFilter) Private eCurrentFilter As frmFilter.eFilterType = frmFilter.eFilterType.BaseFilter Private bCurrentAndOperator As Boolean = False @@ -227,7 +228,8 @@ Public Class frmGameManager If Not bRetainFilter Then frm = New frmFilter - frm.TagFilters = oCurrentTagFilters + frm.IncludeTagFilters = oCurrentIncludeTagFilters + frm.ExcludeTagFilters = oCurrentExcludeTagFilters frm.GameFilters = oCurrentFilters frm.FilterType = eCurrentFilter frm.AndOperator = bCurrentAndOperator @@ -236,7 +238,8 @@ Public Class frmGameManager frm.ShowDialog() - oCurrentTagFilters = frm.TagFilters + oCurrentIncludeTagFilters = frm.IncludeTagFilters + oCurrentExcludeTagFilters = frm.ExcludeTagFilters oCurrentFilters = frm.GameFilters eCurrentFilter = frm.FilterType bCurrentAndOperator = frm.AndOperator @@ -244,14 +247,15 @@ Public Class frmGameManager sCurrentSortField = frm.SortField End If Else - oCurrentTagFilters.Clear() + oCurrentIncludeTagFilters.Clear() + oCurrentExcludeTagFilters.Clear() oCurrentFilters.Clear() eCurrentFilter = frmFilter.eFilterType.BaseFilter bCurrentSortAsc = True sCurrentSortField = "Name" End If - GameData = mgrMonitorList.ReadFilteredList(oCurrentTagFilters, oCurrentFilters, eCurrentFilter, bCurrentAndOperator, bCurrentSortAsc, sCurrentSortField) + GameData = mgrMonitorList.ReadFilteredList(oCurrentIncludeTagFilters, oCurrentExcludeTagFilters, oCurrentFilters, eCurrentFilter, bCurrentAndOperator, bCurrentSortAsc, sCurrentSortField) If optPendingRestores.Checked Then oRestoreData = mgrRestore.CompareManifests diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index 2364f74..58f344c 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -500,8 +500,9 @@ Public Class mgrMonitorList End Sub 'Filter Functions - Private Shared Function BuildFilterQuery(ByVal oTagFilters As List(Of clsTag), ByVal oFilters As List(Of clsGameFilter), ByVal eFilterType As frmFilter.eFilterType, ByVal bAndOperator As Boolean, - ByVal bSortAsc As Boolean, ByVal sSortField As String, ByRef hshParams As Hashtable) As String + Private Shared Function BuildFilterQuery(ByVal oIncludeTagFilters As List(Of clsTag), ByVal oExcludeTagFilters As List(Of clsTag), ByVal oFilters As List(Of clsGameFilter), + ByVal eFilterType As frmFilter.eFilterType, ByVal bAndOperator As Boolean, ByVal bSortAsc As Boolean, ByVal sSortField As String, + ByRef hshParams As Hashtable) As String Dim sSQL As String = String.Empty Dim iCounter As Integer = 0 Dim sBaseSelect As String = "MonitorID, Name, Process, Path, AbsolutePath, FolderSave, FileType, TimeStamp, ExcludeList, ProcessPath, Icon, Hours, Version, Company, Enabled, MonitorOnly, BackupLimit, CleanFolder, Parameter, Comments FROM monitorlist" @@ -517,28 +518,87 @@ Public Class mgrMonitorList Case frmFilter.eFilterType.BaseFilter sSQL = "SELECT " & sBaseSelect Case frmFilter.eFilterType.AnyTag - sSQL = "SELECT DISTINCT " & sBaseSelect - sSQL &= " NATURAL JOIN gametags WHERE gametags.TagID IN (" - For Each oTag As clsTag In oTagFilters - sSQL &= "@TagID" & iCounter & "," - hshParams.Add("TagID" & iCounter, oTag.ID) - iCounter += 1 - Next + If oExcludeTagFilters.Count > 0 And oIncludeTagFilters.Count = 0 Then + sSQL = "SELECT " & sBaseSelect - sSQL = sSQL.TrimEnd(",") - sSQL &= ")" - Case frmFilter.eFilterType.AllTags - sSQL = "SELECT " & sBaseSelect & " WHERE MonitorID IN " + sSQL &= " WHERE MonitorID NOT IN (SELECT MonitorID FROM monitorlist NATURAL JOIN gametags WHERE gametags.TagID IN (" - For Each oTag As clsTag In oTagFilters - sSQL &= "(SELECT MonitorID FROM gametags WHERE monitorlist.MonitorID = gametags.MonitorID And TagID = @TagID" & iCounter & ")" - If iCounter <> oTagFilters.Count - 1 Then - sSQL &= " AND MonitorID IN " + For Each oTag As clsTag In oExcludeTagFilters + sSQL &= "@TagID" & iCounter & "," + hshParams.Add("TagID" & iCounter, oTag.ID) + iCounter += 1 + Next + + sSQL = sSQL.TrimEnd(",") + sSQL &= "))" + Else + sSQL = "SELECT DISTINCT " & sBaseSelect + + sSQL &= " NATURAL JOIN gametags WHERE gametags.TagID IN (" + + For Each oTag As clsTag In oIncludeTagFilters + sSQL &= "@TagID" & iCounter & "," + hshParams.Add("TagID" & iCounter, oTag.ID) + iCounter += 1 + Next + + sSQL = sSQL.TrimEnd(",") + sSQL &= ")" + + If oExcludeTagFilters.Count > 0 Then + sSQL &= " AND MonitorID NOT IN (SELECT MonitorID FROM monitorlist NATURAL JOIN gametags WHERE gametags.TagID IN (" + + For Each oTag As clsTag In oExcludeTagFilters + sSQL &= "@TagID" & iCounter & "," + hshParams.Add("TagID" & iCounter, oTag.ID) + iCounter += 1 + Next + + sSQL = sSQL.TrimEnd(",") + sSQL &= "))" End If - hshParams.Add("TagID" & iCounter, oTag.ID) - iCounter += 1 - Next + End If + + Case frmFilter.eFilterType.AllTags + + If oExcludeTagFilters.Count > 0 And oIncludeTagFilters.Count = 0 Then + sSQL = "SELECT " & sBaseSelect & " WHERE MonitorID NOT IN " + + For Each oTag As clsTag In oExcludeTagFilters + sSQL &= "(SELECT MonitorID FROM gametags WHERE monitorlist.MonitorID = gametags.MonitorID And TagID = @TagID" & iCounter & ")" + If iCounter <> oExcludeTagFilters.Count - 1 Then + sSQL &= " AND MonitorID IN " + End If + hshParams.Add("TagID" & iCounter, oTag.ID) + iCounter += 1 + Next + Else + sSQL = "SELECT " & sBaseSelect & " WHERE MonitorID IN " + + For Each oTag As clsTag In oIncludeTagFilters + sSQL &= "(SELECT MonitorID FROM gametags WHERE monitorlist.MonitorID = gametags.MonitorID And TagID = @TagID" & iCounter & ")" + If iCounter <> oIncludeTagFilters.Count - 1 Then + sSQL &= " AND MonitorID IN " + End If + hshParams.Add("TagID" & iCounter, oTag.ID) + iCounter += 1 + Next + + If oExcludeTagFilters.Count > 0 Then + sSQL &= " AND MonitorID NOT IN (SELECT MonitorID FROM monitorlist NATURAL JOIN gametags WHERE gametags.TagID IN (" + + For Each oTag As clsTag In oExcludeTagFilters + sSQL &= "@TagID" & iCounter & "," + hshParams.Add("TagID" & iCounter, oTag.ID) + iCounter += 1 + Next + + sSQL = sSQL.TrimEnd(",") + sSQL &= "))" + End If + End If + Case frmFilter.eFilterType.NoTags sSQL = "SELECT " & sBaseSelect & " WHERE MonitorID NOT IN (SELECT MonitorID FROM gametags)" End Select @@ -553,6 +613,10 @@ Public Class mgrMonitorList iCounter = 0 For Each oFilter As clsGameFilter In oFilters + If oFilter.NotCondition Then + sSQL &= " NOT " + End If + Select Case oFilter.Field.Type Case clsGameFilterField.eDataType.fString sSQL &= oFilter.Field.FieldName & " LIKE @" & oFilter.ID @@ -584,7 +648,7 @@ Public Class mgrMonitorList End Function - Public Shared Function ReadFilteredList(ByVal oTagFilters As List(Of clsTag), ByVal oFilters As List(Of clsGameFilter), ByVal eFilterType As frmFilter.eFilterType, ByVal bAndOperator As Boolean, + Public Shared Function ReadFilteredList(ByVal oIncludeTagFilters As List(Of clsTag), ByVal oExcludeTagFilters As List(Of clsTag), ByVal oFilters As List(Of clsGameFilter), ByVal eFilterType As frmFilter.eFilterType, ByVal bAndOperator As Boolean, ByVal bSortAsc As Boolean, ByVal sSortField As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As OrderedDictionary Dim oDatabase As New mgrSQLite(iSelectDB) Dim oData As DataSet @@ -594,7 +658,7 @@ Public Class mgrMonitorList Dim hshParams As New Hashtable Dim iCounter As Integer = 0 - sSQL = BuildFilterQuery(oTagFilters, oFilters, eFilterType, bAndOperator, bSortAsc, sSortField, hshParams) + sSQL = BuildFilterQuery(oIncludeTagFilters, oExcludeTagFilters, oFilters, eFilterType, bAndOperator, bSortAsc, sSortField, hshParams) oData = oDatabase.ReadParamData(sSQL, hshParams) @@ -609,7 +673,7 @@ Public Class mgrMonitorList 'Import / Export Functions - Public Shared Function ReadListForExport(ByVal oTagFilters As List(Of clsTag), ByVal oFilters As List(Of clsGameFilter), ByVal eFilterType As frmFilter.eFilterType, ByVal bAndOperator As Boolean, + Public Shared Function ReadListForExport(ByVal oIncludeTagFilters As List(Of clsTag), ByVal oExcludeTagFilters As List(Of clsTag), ByVal oFilters As List(Of clsGameFilter), ByVal eFilterType As frmFilter.eFilterType, ByVal bAndOperator As Boolean, ByVal bSortAsc As Boolean, ByVal sSortField As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As List(Of Game) Dim oDatabase As New mgrSQLite(iSelectDB) Dim oData As DataSet @@ -619,7 +683,7 @@ Public Class mgrMonitorList Dim oGame As Game Dim hshParams As New Hashtable - sSQL = BuildFilterQuery(oTagFilters, oFilters, eFilterType, bAndOperator, bSortAsc, sSortField, hshParams) + sSQL = BuildFilterQuery(oIncludeTagFilters, oExcludeTagFilters, oFilters, eFilterType, bAndOperator, bSortAsc, sSortField, hshParams) oData = oDatabase.ReadParamData(sSQL, hshParams) @@ -713,7 +777,8 @@ Public Class mgrMonitorList Public Shared Sub ExportMonitorList(ByVal sLocation As String) Dim oList As List(Of Game) Dim bSuccess As Boolean = False - Dim oTagFilters As New List(Of clsTag) + Dim oIncludeTagFilters As New List(Of clsTag) + Dim oExcludeTagFilters As New List(Of clsTag) Dim oFilters As New List(Of clsGameFilter) Dim eCurrentFilter As frmFilter.eFilterType = frmFilter.eFilterType.BaseFilter Dim bAndOperator As Boolean = True @@ -723,7 +788,8 @@ Public Class mgrMonitorList If mgrCommon.ShowMessage(mgrMonitorList_ConfirmApplyFilter, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then Dim frm As New frmFilter frm.ShowDialog() - oTagFilters = frm.TagFilters + oIncludeTagFilters = frm.IncludeTagFilters + oExcludeTagFilters = frm.ExcludeTagFilters oFilters = frm.GameFilters eCurrentFilter = frm.FilterType bAndOperator = frm.AndOperator @@ -731,7 +797,7 @@ Public Class mgrMonitorList sSortField = frm.SortField End If - oList = ReadListForExport(oTagFilters, oFilters, eCurrentFilter, bAndOperator, bSortAsc, sSortField) + oList = ReadListForExport(oIncludeTagFilters, oExcludeTagFilters, oFilters, eCurrentFilter, bAndOperator, bSortAsc, sSortField) bSuccess = mgrXML.SerializeAndExport(oList, sLocation) diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index d1c3aba..e5a32b4 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -915,15 +915,6 @@ Namespace My.Resources End Get End Property - ''' - ''' Looks up a localized string similar to >. - ''' - Friend ReadOnly Property frmFilter_btnAdd() As String - Get - Return ResourceManager.GetString("frmFilter_btnAdd", resourceCulture) - End Get - End Property - ''' ''' Looks up a localized string similar to Add. ''' @@ -934,20 +925,47 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to &OK. + ''' Looks up a localized string similar to >. ''' - Friend ReadOnly Property frmFilter_btnOK() As String + Friend ReadOnly Property frmFilter_btnExcludeAdd() As String Get - Return ResourceManager.GetString("frmFilter_btnOK", resourceCulture) + Return ResourceManager.GetString("frmFilter_btnExcludeAdd", resourceCulture) End Get End Property ''' ''' Looks up a localized string similar to <. ''' - Friend ReadOnly Property frmFilter_btnRemove() As String + Friend ReadOnly Property frmFilter_btnExcludeRemove() As String Get - Return ResourceManager.GetString("frmFilter_btnRemove", resourceCulture) + Return ResourceManager.GetString("frmFilter_btnExcludeRemove", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to <. + ''' + Friend ReadOnly Property frmFilter_btnIncludeAdd() As String + Get + Return ResourceManager.GetString("frmFilter_btnIncludeAdd", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to >. + ''' + Friend ReadOnly Property frmFilter_btnIncludeRemove() As String + Get + Return ResourceManager.GetString("frmFilter_btnIncludeRemove", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to &OK. + ''' + Friend ReadOnly Property frmFilter_btnOK() As String + Get + Return ResourceManager.GetString("frmFilter_btnOK", resourceCulture) End Get End Property @@ -1195,7 +1213,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to Options. + ''' Looks up a localized string similar to Include Options. ''' Friend ReadOnly Property frmFilter_grpTagOptions() As String Get @@ -1212,6 +1230,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Exclude Tags. + ''' + Friend ReadOnly Property frmFilter_lblExcludeTags() As String + Get + Return ResourceManager.GetString("frmFilter_lblExcludeTags", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Available Fields. ''' @@ -1231,11 +1258,20 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to Current Filter. + ''' Looks up a localized string similar to Include Tags. ''' - Friend ReadOnly Property frmFilter_lblGameTags() As String + Friend ReadOnly Property frmFilter_lblIncludeTags() As String Get - Return ResourceManager.GetString("frmFilter_lblGameTags", resourceCulture) + Return ResourceManager.GetString("frmFilter_lblIncludeTags", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Not. + ''' + Friend ReadOnly Property frmFilter_lblNot() As String + Get + Return ResourceManager.GetString("frmFilter_lblNot", resourceCulture) End Get End Property diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index d190a54..0c37006 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -883,20 +883,20 @@ Do you wish to search the [PARAM] drive? - - > + + < &OK - - < + + > Custom Filter - - Current Filter + + Include Tags Available Tags @@ -1010,7 +1010,7 @@ Filter Type - Options + Include Options Configuration @@ -1888,4 +1888,16 @@ Comments + + > + + + < + + + Exclude Tags + + + Not + \ No newline at end of file From bc1c9ecbd5a74fd777fe5f8afb30084d80797bda Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Tue, 21 Nov 2017 13:58:45 -0600 Subject: [PATCH 04/21] Small UI fix for issue #103 --- GBM/Forms/frmFilter.vb | 1 + 1 file changed, 1 insertion(+) diff --git a/GBM/Forms/frmFilter.vb b/GBM/Forms/frmFilter.vb index 2a98186..3f2fd69 100644 --- a/GBM/Forms/frmFilter.vb +++ b/GBM/Forms/frmFilter.vb @@ -393,6 +393,7 @@ Public Class frmFilter cboBoolFilter.SelectedIndex = 0 numFilter.Value = 0 txtStringFilter.Text = String.Empty + chkNot.Checked = False 'Reset Visibilty cboBoolFilter.Visible = False From e106d7c09c004753c8d32dd217d97e1ac69d6934 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Thu, 23 Nov 2017 08:56:06 -0600 Subject: [PATCH 05/21] Added new export field for issue #109 --- .../XML Serialize Classes/ExportInformation.vb | 14 +++++++++++++- GBM/Forms/frmGameManager.Designer.vb | 2 +- GBM/Managers/mgrXML.vb | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/GBM/Classes/XML Serialize Classes/ExportInformation.vb b/GBM/Classes/XML Serialize Classes/ExportInformation.vb index 8d4ad4a..602aef6 100644 --- a/GBM/Classes/XML Serialize Classes/ExportInformation.vb +++ b/GBM/Classes/XML Serialize Classes/ExportInformation.vb @@ -1,5 +1,6 @@ Public Class ExportInformation Private dExported As Int64 + Private iTotalConfigs As Integer Private iAppVer As Integer Property Exported As Int64 @@ -11,6 +12,15 @@ End Get End Property + Property TotalConfigurations As Integer + Set(value As Integer) + iTotalConfigs = value + End Set + Get + Return iTotalConfigs + End Get + End Property + Property AppVer As Integer Set(value As Integer) iAppVer = value @@ -22,11 +32,13 @@ Public Sub New() dExported = 0 + iTotalConfigs = 0 iAppVer = 0 End Sub - Public Sub New(ByVal dInitExported As Int64, ByVal iInitAppVer As Integer) + Public Sub New(ByVal dInitExported As Int64, ByVal iInitTotalConfigs As Integer, ByVal iInitAppVer As Integer) dExported = dInitExported + iTotalConfigs = iInitTotalConfigs iAppVer = iInitAppVer End Sub End Class diff --git a/GBM/Forms/frmGameManager.Designer.vb b/GBM/Forms/frmGameManager.Designer.vb index 38fb8d0..cc094b2 100644 --- a/GBM/Forms/frmGameManager.Designer.vb +++ b/GBM/Forms/frmGameManager.Designer.vb @@ -715,7 +715,7 @@ Partial Class frmGameManager 'btnCancel ' Me.btnCancel.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) - Me.btnCancel.Location = New System.Drawing.Point(697, 392) + Me.btnCancel.Location = New System.Drawing.Point(697, 394) Me.btnCancel.Name = "btnCancel" Me.btnCancel.Size = New System.Drawing.Size(75, 23) Me.btnCancel.TabIndex = 14 diff --git a/GBM/Managers/mgrXML.vb b/GBM/Managers/mgrXML.vb index 73f512a..3b3f265 100644 --- a/GBM/Managers/mgrXML.vb +++ b/GBM/Managers/mgrXML.vb @@ -92,7 +92,7 @@ Public Class mgrXML Public Shared Function SerializeAndExport(ByVal oList As List(Of Game), ByVal sLocation As String) As Boolean Dim oSerializer As XmlSerializer Dim oWriter As StreamWriter - Dim oExportInformation = New ExportInformation(mgrCommon.DateToUnix(Now), mgrCommon.AppVersion) + Dim oExportInformation = New ExportInformation(mgrCommon.DateToUnix(Now), oList.Count, mgrCommon.AppVersion) Dim oExportData As ExportData Try From 2c0fdb776e20af4a2efa73461968c66abed04f09 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Tue, 5 Dec 2017 18:06:22 -0600 Subject: [PATCH 06/21] Changes for issue #109 --- GBM/Forms/frmAdvancedImport.Designer.vb | 19 ++++++++++++++++--- GBM/Forms/frmAdvancedImport.vb | 17 +++++++++++++++++ GBM/Forms/frmMain.vb | 3 +-- GBM/Managers/mgrCommon.vb | 6 ++++++ GBM/Managers/mgrMonitorList.vb | 4 +++- GBM/Managers/mgrXML.vb | 21 +++++++++++---------- GBM/My Project/Resources.Designer.vb | 9 +++++++++ GBM/My Project/Resources.resx | 3 +++ 8 files changed, 66 insertions(+), 16 deletions(-) diff --git a/GBM/Forms/frmAdvancedImport.Designer.vb b/GBM/Forms/frmAdvancedImport.Designer.vb index 21aae4c..5d3ecc5 100644 --- a/GBM/Forms/frmAdvancedImport.Designer.vb +++ b/GBM/Forms/frmAdvancedImport.Designer.vb @@ -30,6 +30,7 @@ Partial Class frmAdvancedImport Me.lstGames = New System.Windows.Forms.ListView() Me.txtFilter = New System.Windows.Forms.TextBox() Me.lblFilter = New System.Windows.Forms.Label() + Me.lblInfo = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'btnImport @@ -44,7 +45,7 @@ Partial Class frmAdvancedImport 'chkSelectAll ' Me.chkSelectAll.AutoSize = True - Me.chkSelectAll.Location = New System.Drawing.Point(12, 12) + Me.chkSelectAll.Location = New System.Drawing.Point(12, 11) Me.chkSelectAll.Name = "chkSelectAll" Me.chkSelectAll.Size = New System.Drawing.Size(70, 17) Me.chkSelectAll.TabIndex = 0 @@ -98,18 +99,29 @@ Partial Class frmAdvancedImport ' 'lblFilter ' - Me.lblFilter.Location = New System.Drawing.Point(307, 12) + Me.lblFilter.Location = New System.Drawing.Point(371, 12) Me.lblFilter.Name = "lblFilter" - Me.lblFilter.Size = New System.Drawing.Size(103, 14) + Me.lblFilter.Size = New System.Drawing.Size(39, 14) Me.lblFilter.TabIndex = 0 Me.lblFilter.Text = "Filter:" Me.lblFilter.TextAlign = System.Drawing.ContentAlignment.TopRight ' + 'lblInfo + ' + Me.lblInfo.AutoEllipsis = True + Me.lblInfo.Location = New System.Drawing.Point(88, 12) + Me.lblInfo.Name = "lblInfo" + Me.lblInfo.Size = New System.Drawing.Size(277, 14) + Me.lblInfo.TabIndex = 0 + Me.lblInfo.Text = "Import Information" + Me.lblInfo.TextAlign = System.Drawing.ContentAlignment.TopCenter + ' 'frmAdvancedImport ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(584, 411) + Me.Controls.Add(Me.lblInfo) Me.Controls.Add(Me.lblFilter) Me.Controls.Add(Me.txtFilter) Me.Controls.Add(Me.lstGames) @@ -137,4 +149,5 @@ Partial Class frmAdvancedImport Friend WithEvents lstGames As System.Windows.Forms.ListView Friend WithEvents txtFilter As System.Windows.Forms.TextBox Friend WithEvents lblFilter As System.Windows.Forms.Label + Friend WithEvents lblInfo As Label End Class diff --git a/GBM/Forms/frmAdvancedImport.vb b/GBM/Forms/frmAdvancedImport.vb index 70ef96b..fafbd3d 100644 --- a/GBM/Forms/frmAdvancedImport.vb +++ b/GBM/Forms/frmAdvancedImport.vb @@ -3,6 +3,7 @@ Imports System.IO Public Class frmAdvancedImport + Private oImportInfo As ExportInformation Private hshImportData As Hashtable Private hshFinalData As New Hashtable Private bSelectAll As Boolean = True @@ -10,6 +11,15 @@ Public Class frmAdvancedImport Private iCurrentSort As Integer = 0 Private WithEvents tmFilterTimer As Timer + Public Property ImportInfo As ExportInformation + Set(value As ExportInformation) + oImportInfo = value + End Set + Get + Return oImportInfo + End Get + End Property + Public Property ImportData As Hashtable Set(value As Hashtable) hshImportData = value @@ -141,6 +151,13 @@ Public Class frmAdvancedImport btnImport.Text = frmAdvancedImport_btnImport chkSelectAll.Text = frmAdvancedImport_chkSelectAll + 'Import Information + If ImportInfo.Exported <> 0 Then + lblInfo.Text = mgrCommon.FormatString(frmAdvancedImport_lblInfo, New String() {mgrCommon.UnixToDate(ImportInfo.Exported).Date, mgrCommon.DisplayAppVersion}) + Else + lblInfo.Text = String.Empty + End If + chkSelectAll.Checked = True 'Init Filter Timer diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index f1991d2..3b98374 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -813,14 +813,13 @@ Public Class frmMain Private Sub OpenAbout() Dim iProcessType As System.Reflection.ProcessorArchitecture = System.Reflection.AssemblyName.GetAssemblyName(Application.ExecutablePath()).ProcessorArchitecture - Dim sVersion As String = My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor & "." & My.Application.Info.Version.Build Dim sProcessType = [Enum].GetName(GetType(System.Reflection.ProcessorArchitecture), iProcessType) Dim sRevision As String = My.Application.Info.Version.Revision Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Local) Dim sSqliteVersion As String = oDatabase.ReportVersion Dim sConstCopyright As String = Chr(169) & mgrCommon.FormatString(App_Copyright, Now.Year.ToString) - mgrCommon.ShowMessage(frmMain_About, New String() {sVersion, sProcessType, sRevision, sSqliteVersion, sConstCopyright}, MsgBoxStyle.Information) + mgrCommon.ShowMessage(frmMain_About, New String() {mgrCommon.DisplayAppVersion, sProcessType, sRevision, sSqliteVersion, sConstCopyright}, MsgBoxStyle.Information) End Sub Private Sub OpenTags() diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb index 2339d33..fa59326 100644 --- a/GBM/Managers/mgrCommon.vb +++ b/GBM/Managers/mgrCommon.vb @@ -37,6 +37,12 @@ Public Class mgrCommon End Get End Property + Public Shared ReadOnly Property DisplayAppVersion As String + Get + Return My.Application.Info.Version.Major & "." & My.Application.Info.Version.Minor & "." & My.Application.Info.Version.Build + End Get + End Property + 'Source - https://stackoverflow.com/questions/18873152/deep-copy-of-ordereddictionary Public Shared Function GenericClone(ByVal oOriginal As Object) As Object 'Construct a temporary memory stream diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index 58f344c..24d3474 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -735,11 +735,12 @@ Public Class mgrMonitorList Dim hshSyncItems As Hashtable Dim oFromItem As clsGame Dim oToItem As clsGame + Dim oExportInfo As New ExportInformation Cursor.Current = Cursors.WaitCursor 'Add / Update Sync - hshCompareFrom = mgrXML.ReadMonitorList(sLocation, bWebRead) + hshCompareFrom = mgrXML.ReadMonitorList(sLocation, oExportInfo, bWebRead) hshCompareTo = ReadList(eListTypes.FullList, mgrSQLite.Database.Local) hshSyncItems = hshCompareFrom.Clone @@ -757,6 +758,7 @@ Public Class mgrMonitorList If hshSyncItems.Count > 0 Then Dim frm As New frmAdvancedImport + frm.ImportInfo = oExportInfo frm.ImportData = hshSyncItems If frm.ShowDialog() = DialogResult.OK Then Cursor.Current = Cursors.WaitCursor diff --git a/GBM/Managers/mgrXML.vb b/GBM/Managers/mgrXML.vb index 3b3f265..b8829bb 100644 --- a/GBM/Managers/mgrXML.vb +++ b/GBM/Managers/mgrXML.vb @@ -6,18 +6,22 @@ Imports System.Net Public Class mgrXML - Public Shared Function ReadMonitorList(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) As Hashtable + Public Shared Function ReadMonitorList(ByVal sLocation As String, ByRef oExportInfo As ExportInformation, Optional ByVal bWebRead As Boolean = False) As Hashtable Dim oList As List(Of Game) Dim hshList As New Hashtable Dim hshDupeList As New Hashtable + Dim oExportData As ExportData Dim oGame As clsGame + 'If the file doesn't exist return an empty list If Not File.Exists(sLocation) And Not bWebRead Then Return hshList End If - oList = ImportandDeserialize(sLocation, bWebRead) + oExportData = ImportandDeserialize(sLocation, bWebRead) + oList = oExportData.Configurations + oExportInfo = oExportData.Information For Each g As Game In oList oGame = New clsGame @@ -60,33 +64,30 @@ Public Class mgrXML Return oReader End Function - Public Shared Function ImportandDeserialize(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) As List(Of Game) + Public Shared Function ImportandDeserialize(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) As ExportData Dim oReader As StreamReader Dim oSerializer As XmlSerializer Dim oExportData As New ExportData - Dim oConfigurations As New List(Of Game) Try oReader = ReadImportData(sLocation, bWebRead) - oSerializer = New XmlSerializer(oExportData.GetType(), New XmlRootAttribute("gbm")) + oSerializer = New XmlSerializer(GetType(ExportData), New XmlRootAttribute("gbm")) oExportData = oSerializer.Deserialize(oReader) oReader.Close() 'Compatability Mode If oExportData.Information.AppVer = 0 Then oReader = ReadImportData(sLocation, bWebRead) - oSerializer = New XmlSerializer(oConfigurations.GetType(), New XmlRootAttribute("gbm")) - oConfigurations = oSerializer.Deserialize(oReader) + oSerializer = New XmlSerializer(GetType(List(Of Game)), New XmlRootAttribute("gbm")) + oExportData.Configurations = oSerializer.Deserialize(oReader) oReader.Close() - Else - oConfigurations = oExportData.Configurations End If Catch ex As Exception mgrCommon.ShowMessage(mgrXML_ErrorImportFailure, ex.Message, MsgBoxStyle.Exclamation) End Try - Return oConfigurations + Return oExportData End Function Public Shared Function SerializeAndExport(ByVal oList As List(Of Game), ByVal sLocation As String) As Boolean diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index e5a32b4..ecae674 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -807,6 +807,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Last Update: [PARAM] (v[PARAM]). + ''' + Friend ReadOnly Property frmAdvancedImport_lblInfo() As String + Get + Return ResourceManager.GetString("frmAdvancedImport_lblInfo", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Selected ([PARAM]). ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 0c37006..84c8c4b 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1900,4 +1900,7 @@ Not + + Last Update: [PARAM] (v[PARAM]) + \ No newline at end of file From 82f287f3221a0b5a12fce817cf50f81450134b8b Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Tue, 5 Dec 2017 19:55:39 -0600 Subject: [PATCH 07/21] Changed date display for issue #109 --- GBM/Forms/frmAdvancedImport.Designer.vb | 19 +++---------------- GBM/Forms/frmAdvancedImport.vb | 12 +++++------- GBM/My Project/Resources.Designer.vb | 9 --------- GBM/My Project/Resources.resx | 3 --- 4 files changed, 8 insertions(+), 35 deletions(-) diff --git a/GBM/Forms/frmAdvancedImport.Designer.vb b/GBM/Forms/frmAdvancedImport.Designer.vb index 5d3ecc5..d081c55 100644 --- a/GBM/Forms/frmAdvancedImport.Designer.vb +++ b/GBM/Forms/frmAdvancedImport.Designer.vb @@ -1,9 +1,9 @@ - _ + Partial Class frmAdvancedImport Inherits System.Windows.Forms.Form 'Form overrides dispose to clean up the component list. - _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) Try If disposing AndAlso components IsNot Nothing Then @@ -20,7 +20,7 @@ Partial Class frmAdvancedImport 'NOTE: The following procedure is required by the Windows Form Designer 'It can be modified using the Windows Form Designer. 'Do not modify it using the code editor. - _ + Private Sub InitializeComponent() Me.btnImport = New System.Windows.Forms.Button() Me.chkSelectAll = New System.Windows.Forms.CheckBox() @@ -30,7 +30,6 @@ Partial Class frmAdvancedImport Me.lstGames = New System.Windows.Forms.ListView() Me.txtFilter = New System.Windows.Forms.TextBox() Me.lblFilter = New System.Windows.Forms.Label() - Me.lblInfo = New System.Windows.Forms.Label() Me.SuspendLayout() ' 'btnImport @@ -106,22 +105,11 @@ Partial Class frmAdvancedImport Me.lblFilter.Text = "Filter:" Me.lblFilter.TextAlign = System.Drawing.ContentAlignment.TopRight ' - 'lblInfo - ' - Me.lblInfo.AutoEllipsis = True - Me.lblInfo.Location = New System.Drawing.Point(88, 12) - Me.lblInfo.Name = "lblInfo" - Me.lblInfo.Size = New System.Drawing.Size(277, 14) - Me.lblInfo.TabIndex = 0 - Me.lblInfo.Text = "Import Information" - Me.lblInfo.TextAlign = System.Drawing.ContentAlignment.TopCenter - ' 'frmAdvancedImport ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(584, 411) - Me.Controls.Add(Me.lblInfo) Me.Controls.Add(Me.lblFilter) Me.Controls.Add(Me.txtFilter) Me.Controls.Add(Me.lstGames) @@ -149,5 +137,4 @@ Partial Class frmAdvancedImport Friend WithEvents lstGames As System.Windows.Forms.ListView Friend WithEvents txtFilter As System.Windows.Forms.TextBox Friend WithEvents lblFilter As System.Windows.Forms.Label - Friend WithEvents lblInfo As Label End Class diff --git a/GBM/Forms/frmAdvancedImport.vb b/GBM/Forms/frmAdvancedImport.vb index fafbd3d..f2260b3 100644 --- a/GBM/Forms/frmAdvancedImport.vb +++ b/GBM/Forms/frmAdvancedImport.vb @@ -145,19 +145,17 @@ Public Class frmAdvancedImport 'Set Form Name Me.Text = frmAdvancedImport_FormName + 'Add configuration date to title if applicable + If ImportInfo.Exported <> 0 Then + Me.Text &= " [" & mgrCommon.UnixToDate(ImportInfo.Exported).Date & "]" + End If + 'Set Form Text lblFilter.Text = frmAdvancedImport_lblFilter btnCancel.Text = frmAdvancedImport_btnCancel btnImport.Text = frmAdvancedImport_btnImport chkSelectAll.Text = frmAdvancedImport_chkSelectAll - 'Import Information - If ImportInfo.Exported <> 0 Then - lblInfo.Text = mgrCommon.FormatString(frmAdvancedImport_lblInfo, New String() {mgrCommon.UnixToDate(ImportInfo.Exported).Date, mgrCommon.DisplayAppVersion}) - Else - lblInfo.Text = String.Empty - End If - chkSelectAll.Checked = True 'Init Filter Timer diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index ecae674..e5a32b4 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -807,15 +807,6 @@ Namespace My.Resources End Get End Property - ''' - ''' Looks up a localized string similar to Last Update: [PARAM] (v[PARAM]). - ''' - Friend ReadOnly Property frmAdvancedImport_lblInfo() As String - Get - Return ResourceManager.GetString("frmAdvancedImport_lblInfo", resourceCulture) - End Get - End Property - ''' ''' Looks up a localized string similar to Selected ([PARAM]). ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 84c8c4b..0c37006 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1900,7 +1900,4 @@ Not - - Last Update: [PARAM] (v[PARAM]) - \ No newline at end of file From ab06db102c0ea17b07585efd1d3bd1a41466a815 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Wed, 6 Dec 2017 00:21:26 -0600 Subject: [PATCH 08/21] Added basics for issue #99 --- GBM/Classes/clsSession.vb | 44 ++++++++++++++++++++++++++++++ GBM/Forms/frmMain.vb | 13 +++++++++ GBM/Game Backup Monitor.vbproj | 2 ++ GBM/Managers/mgrSQLite.vb | 10 ++++++- GBM/Managers/mgrSession.vb | 35 ++++++++++++++++++++++++ GBM/Managers/mgrSessions.vb | 49 ++++++++++++++++++++++++++++++++++ 6 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 GBM/Classes/clsSession.vb create mode 100644 GBM/Managers/mgrSession.vb create mode 100644 GBM/Managers/mgrSessions.vb 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 From 9a8350c2ed6ae5483c9a52d27388b711dfe255ca Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Wed, 6 Dec 2017 22:58:52 -0600 Subject: [PATCH 09/21] Removed useless class file --- GBM/Managers/mgrSession.vb | 35 ----------------------------------- 1 file changed, 35 deletions(-) delete mode 100644 GBM/Managers/mgrSession.vb diff --git a/GBM/Managers/mgrSession.vb b/GBM/Managers/mgrSession.vb deleted file mode 100644 index 36cd9cb..0000000 --- a/GBM/Managers/mgrSession.vb +++ /dev/null @@ -1,35 +0,0 @@ -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 From c8453c9cbd224fe80316da67cf0715568ad0aa55 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Thu, 7 Dec 2017 11:54:03 -0600 Subject: [PATCH 10/21] Change session storage to local --- GBM/Managers/mgrSQLite.vb | 18 ++++++++---------- GBM/Managers/mgrSessions.vb | 8 ++++---- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/GBM/Managers/mgrSQLite.vb b/GBM/Managers/mgrSQLite.vb index 7c498ad..d2837c4 100644 --- a/GBM/Managers/mgrSQLite.vb +++ b/GBM/Managers/mgrSQLite.vb @@ -98,6 +98,9 @@ Public Class mgrSQLite sSql &= "CREATE TABLE manifest (ManifestID TEXT NOT NULL PRIMARY KEY, Name TEXT NOT NULL, FileName TEXT NOT NULL, RestorePath TEXT NOT NULL, " & "AbsolutePath BOOLEAN NOT NULL, DateUpdated TEXT NOT NULL, UpdatedBy TEXT NOT NULL, CheckSum TEXT);" + 'Add Tables (Sessions) + sSql &= "CREATE TABLE sessions (MonitorID TEXT NOT NULL, Start INTEGER NOT NULL, End INTEGER NOT NULL, PRIMARY KEY(MonitorID, Start));" + 'Set Version sSql &= "PRAGMA user_version=" & mgrCommon.AppVersion @@ -132,10 +135,6 @@ 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 @@ -690,8 +689,11 @@ 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, 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" @@ -701,12 +703,8 @@ 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/mgrSessions.vb b/GBM/Managers/mgrSessions.vb index e33c785..b87c884 100644 --- a/GBM/Managers/mgrSessions.vb +++ b/GBM/Managers/mgrSessions.vb @@ -22,8 +22,8 @@ Return hshParams End Function - Public Shared Sub AddSession(ByVal oSession As clsSession) - Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Remote) + Public Shared Sub AddSession(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 @@ -34,8 +34,8 @@ oDatabase.RunParamQuery(sSQL, hshParams) End Sub - Public Shared Function GetSessionsByGame(ByVal sMonitorID As String) As DataSet - Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Remote) + Public Shared Function GetSessionsByGame(ByVal sMonitorID As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DataSet + Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String Dim hshParams As New Hashtable From 11101f7f229d01be87637f53c3389e54a3457f92 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Thu, 7 Dec 2017 15:50:37 -0600 Subject: [PATCH 11/21] Added session viewer for issue #99 --- GBM/Forms/frmMain.Designer.vb | 26 ++++-- GBM/Forms/frmMain.vb | 13 +++ GBM/Forms/frmSessions.Designer.vb | 85 +++++++++++++++++++ GBM/Forms/frmSessions.resx | 120 +++++++++++++++++++++++++++ GBM/Forms/frmSessions.vb | 61 ++++++++++++++ GBM/Game Backup Monitor.vbproj | 9 ++ GBM/Managers/mgrSessions.vb | 20 +++-- GBM/My Project/Resources.Designer.vb | 45 ++++++++++ GBM/My Project/Resources.resx | 15 ++++ 9 files changed, 383 insertions(+), 11 deletions(-) create mode 100644 GBM/Forms/frmSessions.Designer.vb create mode 100644 GBM/Forms/frmSessions.resx create mode 100644 GBM/Forms/frmSessions.vb diff --git a/GBM/Forms/frmMain.Designer.vb b/GBM/Forms/frmMain.Designer.vb index 8ba204b..4ecf822 100644 --- a/GBM/Forms/frmMain.Designer.vb +++ b/GBM/Forms/frmMain.Designer.vb @@ -68,6 +68,7 @@ Partial Class frmMain Me.gMonToolsLog = New System.Windows.Forms.ToolStripMenuItem() Me.gMonLogClear = New System.Windows.Forms.ToolStripMenuItem() Me.gMonLogSave = New System.Windows.Forms.ToolStripMenuItem() + Me.gMonToolsSessions = New System.Windows.Forms.ToolStripMenuItem() Me.gMonHelp = New System.Windows.Forms.ToolStripMenuItem() Me.gMonHelpWebSite = New System.Windows.Forms.ToolStripMenuItem() Me.gMonHelpManual = New System.Windows.Forms.ToolStripMenuItem() @@ -84,6 +85,7 @@ Partial Class frmMain Me.lblStatus2 = New System.Windows.Forms.Label() Me.lblStatus3 = New System.Windows.Forms.Label() Me.pbTime = New System.Windows.Forms.PictureBox() + Me.gMonTrayToolsSessions = New System.Windows.Forms.ToolStripMenuItem() Me.gMonTrayMenu.SuspendLayout() Me.gMonStatusStrip.SuspendLayout() Me.gMonMainMenu.SuspendLayout() @@ -103,7 +105,7 @@ Partial Class frmMain ' Me.gMonTrayMenu.Items.AddRange(New System.Windows.Forms.ToolStripItem() {Me.gMonTrayNotification, Me.gMonTrayShow, Me.gMonTraySep2, Me.gMonTrayMon, Me.gMonTraySettings, Me.gMonTraySetup, Me.gMonTrayTools, Me.gMonTraySep1, Me.gMonTrayExit}) Me.gMonTrayMenu.Name = "gMonTrayMenu" - Me.gMonTrayMenu.Size = New System.Drawing.Size(162, 170) + Me.gMonTrayMenu.Size = New System.Drawing.Size(162, 192) ' 'gMonTrayNotification ' @@ -168,7 +170,7 @@ Partial Class frmMain ' 'gMonTrayTools ' - Me.gMonTrayTools.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.gMonTrayToolsCleanMan, Me.gMonTrayToolsCompact, Me.gMonTrayToolsLog}) + Me.gMonTrayTools.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.gMonTrayToolsCleanMan, Me.gMonTrayToolsCompact, Me.gMonTrayToolsLog, Me.gMonTrayToolsSessions}) Me.gMonTrayTools.Name = "gMonTrayTools" Me.gMonTrayTools.Size = New System.Drawing.Size(161, 22) Me.gMonTrayTools.Text = "&Tools" @@ -195,13 +197,13 @@ Partial Class frmMain 'gMonTrayLogClear ' Me.gMonTrayLogClear.Name = "gMonTrayLogClear" - Me.gMonTrayLogClear.Size = New System.Drawing.Size(101, 22) + Me.gMonTrayLogClear.Size = New System.Drawing.Size(152, 22) Me.gMonTrayLogClear.Text = "&Clear" ' 'gMonTrayLogSave ' Me.gMonTrayLogSave.Name = "gMonTrayLogSave" - Me.gMonTrayLogSave.Size = New System.Drawing.Size(101, 22) + Me.gMonTrayLogSave.Size = New System.Drawing.Size(152, 22) Me.gMonTrayLogSave.Text = "&Save" ' 'gMonTraySep1 @@ -348,7 +350,7 @@ Partial Class frmMain ' 'gMonTools ' - Me.gMonTools.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.gMonToolsCleanMan, Me.gMonToolsCompact, Me.gMonToolsLog}) + Me.gMonTools.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.gMonToolsCleanMan, Me.gMonToolsCompact, Me.gMonToolsLog, Me.gMonToolsSessions}) Me.gMonTools.Name = "gMonTools" Me.gMonTools.Size = New System.Drawing.Size(47, 20) Me.gMonTools.Text = "&Tools" @@ -384,6 +386,12 @@ Partial Class frmMain Me.gMonLogSave.Size = New System.Drawing.Size(101, 22) Me.gMonLogSave.Text = "&Save" ' + 'gMonToolsSessions + ' + Me.gMonToolsSessions.Name = "gMonToolsSessions" + Me.gMonToolsSessions.Size = New System.Drawing.Size(184, 22) + Me.gMonToolsSessions.Text = "&Session Viewer..." + ' 'gMonHelp ' Me.gMonHelp.DropDownItems.AddRange(New System.Windows.Forms.ToolStripItem() {Me.gMonHelpWebSite, Me.gMonHelpManual, Me.gMonHelpCheckforUpdates, Me.gMonHelpAbout}) @@ -524,6 +532,12 @@ Partial Class frmMain Me.pbTime.TabIndex = 18 Me.pbTime.TabStop = False ' + 'gMonTrayToolsSessions + ' + Me.gMonTrayToolsSessions.Name = "gMonTrayToolsSessions" + Me.gMonTrayToolsSessions.Size = New System.Drawing.Size(184, 22) + Me.gMonTrayToolsSessions.Text = "&Session Viewer..." + ' 'frmMain ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -621,4 +635,6 @@ Partial Class frmMain Friend WithEvents gMonTrayLogSave As ToolStripMenuItem Friend WithEvents gMonStripAdminButton As System.Windows.Forms.ToolStripStatusLabel Friend WithEvents gMonStripStatusButton As System.Windows.Forms.ToolStripStatusLabel + Friend WithEvents gMonToolsSessions As ToolStripMenuItem + Friend WithEvents gMonTrayToolsSessions As ToolStripMenuItem End Class diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 8bd4884..099a390 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -878,6 +878,13 @@ Public Class frmMain ResumeScan() End Sub + Private Sub OpenSessions() + Dim frm As New frmSessions + PauseScan() + frm.ShowDialog() + ResumeScan() + End Sub + Private Sub OpenGameWizard() Dim frm As New frmAddWizard PauseScan() @@ -1287,6 +1294,7 @@ Public Class frmMain gMonToolsCleanMan.Text = frmMain_gMonToolsCleanMan gMonToolsCompact.Text = frmMain_gMonToolsCompact gMonToolsLog.Text = frmMain_gMonToolsLog + gMonToolsSessions.Text = frmMain_gMonToolsSessions gMonLogClear.Text = frmMain_gMonLogClear gMonLogSave.Text = frmMain_gMonLogSave gMonHelp.Text = frmMain_gMonHelp @@ -1308,6 +1316,7 @@ Public Class frmMain gMonTrayToolsCleanMan.Text = frmMain_gMonToolsCleanMan gMonTrayToolsCompact.Text = frmMain_gMonToolsCompact gMonTrayToolsLog.Text = frmMain_gMonToolsLog + gMonTrayToolsSessions.Text = frmMain_gMonToolsSessions gMonTrayLogClear.Text = frmMain_gMonLogClear gMonTrayLogSave.Text = frmMain_gMonLogSave gMonTrayExit.Text = frmMain_gMonFileExit @@ -1631,6 +1640,10 @@ Public Class frmMain SaveLog() End Sub + Private Sub gMonToolsSessions_Click(sender As Object, e As EventArgs) Handles gMonToolsSessions.Click, gMonTrayToolsSessions.Click + OpenSessions() + End Sub + Private Sub gMonNotification_Click(sender As Object, e As EventArgs) Handles gMonNotification.Click, gMonTrayNotification.Click gMonNotification.Visible = False gMonTrayNotification.Visible = False diff --git a/GBM/Forms/frmSessions.Designer.vb b/GBM/Forms/frmSessions.Designer.vb new file mode 100644 index 0000000..5640618 --- /dev/null +++ b/GBM/Forms/frmSessions.Designer.vb @@ -0,0 +1,85 @@ + _ +Partial Class frmSessions + Inherits System.Windows.Forms.Form + + 'Form overrides dispose to clean up the component list. + _ + Protected Overrides Sub Dispose(ByVal disposing As Boolean) + Try + If disposing AndAlso components IsNot Nothing Then + components.Dispose() + End If + Finally + MyBase.Dispose(disposing) + End Try + End Sub + + 'Required by the Windows Form Designer + Private components As System.ComponentModel.IContainer + + 'NOTE: The following procedure is required by the Windows Form Designer + 'It can be modified using the Windows Form Designer. + 'Do not modify it using the code editor. + _ + Private Sub InitializeComponent() + Me.lblQuickFilter = New System.Windows.Forms.Label() + Me.txtFilter = New System.Windows.Forms.TextBox() + Me.dgSessions = New System.Windows.Forms.DataGridView() + CType(Me.dgSessions, System.ComponentModel.ISupportInitialize).BeginInit() + Me.SuspendLayout() + ' + 'lblQuickFilter + ' + Me.lblQuickFilter.AutoSize = True + Me.lblQuickFilter.Location = New System.Drawing.Point(12, 9) + Me.lblQuickFilter.Name = "lblQuickFilter" + Me.lblQuickFilter.Size = New System.Drawing.Size(63, 13) + Me.lblQuickFilter.TabIndex = 0 + Me.lblQuickFilter.Text = "Game Filter:" + ' + 'txtFilter + ' + Me.txtFilter.Location = New System.Drawing.Point(80, 6) + Me.txtFilter.Name = "txtFilter" + Me.txtFilter.Size = New System.Drawing.Size(160, 20) + Me.txtFilter.TabIndex = 1 + ' + 'dgSessions + ' + Me.dgSessions.AllowUserToAddRows = False + Me.dgSessions.AllowUserToDeleteRows = False + Me.dgSessions.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _ + Or System.Windows.Forms.AnchorStyles.Left) _ + Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.dgSessions.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize + Me.dgSessions.EditMode = System.Windows.Forms.DataGridViewEditMode.EditOnF2 + Me.dgSessions.Location = New System.Drawing.Point(12, 32) + Me.dgSessions.Name = "dgSessions" + Me.dgSessions.ReadOnly = True + Me.dgSessions.RowHeadersVisible = False + Me.dgSessions.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect + Me.dgSessions.Size = New System.Drawing.Size(760, 517) + Me.dgSessions.TabIndex = 2 + ' + 'frmSessions + ' + Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) + Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font + Me.ClientSize = New System.Drawing.Size(784, 561) + Me.Controls.Add(Me.dgSessions) + Me.Controls.Add(Me.lblQuickFilter) + Me.Controls.Add(Me.txtFilter) + Me.Name = "frmSessions" + Me.ShowIcon = False + Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen + Me.Text = "Session Viewer" + CType(Me.dgSessions, System.ComponentModel.ISupportInitialize).EndInit() + Me.ResumeLayout(False) + Me.PerformLayout() + + End Sub + + Friend WithEvents lblQuickFilter As Label + Friend WithEvents txtFilter As TextBox + Friend WithEvents dgSessions As DataGridView +End Class diff --git a/GBM/Forms/frmSessions.resx b/GBM/Forms/frmSessions.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/GBM/Forms/frmSessions.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/GBM/Forms/frmSessions.vb b/GBM/Forms/frmSessions.vb new file mode 100644 index 0000000..fa8425f --- /dev/null +++ b/GBM/Forms/frmSessions.vb @@ -0,0 +1,61 @@ +Imports GBM.My.Resources + +Public Class frmSessions + + Private WithEvents tmFilterTimer As Timer + + Private Sub FormatGrid() + dgSessions.Columns.Add("Name", frmSessions_ColumnGameName) + dgSessions.Columns.Add("Start", frmSessions_ColumnStart) + dgSessions.Columns.Add("End", frmSessions_ColumnEnd) + End Sub + + Private Sub LoadData() + Dim oData As DataSet + Dim sFilter As String + + If txtFilter.Text = String.Empty Then + oData = mgrSessions.GetSessions + Else + sFilter = txtFilter.Text.ToLower + oData = mgrSessions.GetSessionsByGameName(sFilter) + End If + + dgSessions.Rows.Clear() + + For Each dr As DataRow In oData.Tables(0).Rows + dgSessions.Rows.Add(New Object() {dr("Name"), mgrCommon.UnixToDate(dr("Start")), mgrCommon.UnixToDate(dr("End"))}) + Next + + dgSessions.AutoResizeColumns() + End Sub + + Private Sub SetForm() + Me.Text = frmSessions_Name + + 'Init Filter Timer + tmFilterTimer = New Timer() + tmFilterTimer.Interval = 1000 + tmFilterTimer.Enabled = False + End Sub + + Private Sub txtFilter_TextChanged(sender As Object, e As EventArgs) Handles txtFilter.TextChanged + If Not tmFilterTimer.Enabled Then + tmFilterTimer.Enabled = True + tmFilterTimer.Start() + End If + End Sub + + Private Sub tmFilterTimer_Tick(sender As Object, ByVal e As EventArgs) Handles tmFilterTimer.Tick + LoadData() + tmFilterTimer.Stop() + tmFilterTimer.Enabled = False + End Sub + + Private Sub frmSession_Load(sender As Object, e As EventArgs) Handles MyBase.Load + SetForm() + FormatGrid() + LoadData() + End Sub + +End Class \ No newline at end of file diff --git a/GBM/Game Backup Monitor.vbproj b/GBM/Game Backup Monitor.vbproj index d77d052..dc616fb 100644 --- a/GBM/Game Backup Monitor.vbproj +++ b/GBM/Game Backup Monitor.vbproj @@ -171,6 +171,12 @@ Form + + frmSessions.vb + + + Form + frmStartUpWizard.vb @@ -271,6 +277,9 @@ frmIncludeExclude.vb + + frmSessions.vb + frmStartUpWizard.vb Designer diff --git a/GBM/Managers/mgrSessions.vb b/GBM/Managers/mgrSessions.vb index b87c884..9eac59e 100644 --- a/GBM/Managers/mgrSessions.vb +++ b/GBM/Managers/mgrSessions.vb @@ -6,7 +6,6 @@ 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 @@ -17,7 +16,6 @@ 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 @@ -27,21 +25,31 @@ Dim sSQL As String Dim hshParams As Hashtable - sSQL = "INSERT INTO sessions (MonitorID, Start, End, ComputerName) VALUES (@MonitorID, @Start, @End, @ComputerName);" + sSQL = "INSERT INTO sessions (MonitorID, Start, End) VALUES (@MonitorID, @Start, @End);" hshParams = SetCoreParameters(oSession) oDatabase.RunParamQuery(sSQL, hshParams) End Sub - Public Shared Function GetSessionsByGame(ByVal sMonitorID As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DataSet + Public Shared Function GetSessions(Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DataSet Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String Dim hshParams As New Hashtable - sSQL = "SELECT Start, End, ComputerName FROM sessions WHERE MonitorID = @MonitorID;" + sSQL = "SELECT Name, Start, End FROM sessions NATURAL JOIN monitorlist;" - hshParams.Add("MonitorID", sMonitorID) + Return oDatabase.ReadParamData(sSQL, hshParams) + End Function + + Public Shared Function GetSessionsByGameName(ByVal sGameName As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DataSet + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + + sSQL = "SELECT Name, Start, End FROM sessions NATURAL JOIN monitorlist WHERE monitorlist.Name LIKE @Name;" + + hshParams.Add("Name", "%" & sGameName & "%") Return oDatabase.ReadParamData(sSQL, hshParams) End Function diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index e5a32b4..090a8d6 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -3237,6 +3237,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to &Session Viewer.... + ''' + Friend ReadOnly Property frmMain_gMonToolsSessions() As String + Get + Return ResourceManager.GetString("frmMain_gMonToolsSessions", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Show / Hide. ''' @@ -3597,6 +3606,42 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to End. + ''' + Friend ReadOnly Property frmSessions_ColumnEnd() As String + Get + Return ResourceManager.GetString("frmSessions_ColumnEnd", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Game. + ''' + Friend ReadOnly Property frmSessions_ColumnGameName() As String + Get + Return ResourceManager.GetString("frmSessions_ColumnGameName", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Start. + ''' + Friend ReadOnly Property frmSessions_ColumnStart() As String + Get + Return ResourceManager.GetString("frmSessions_ColumnStart", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Session Viewer. + ''' + Friend ReadOnly Property frmSessions_Name() As String + Get + Return ResourceManager.GetString("frmSessions_Name", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Executable. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 0c37006..8f06d19 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1900,4 +1900,19 @@ Not + + &Session Viewer... + + + End + + + Game + + + Start + + + Session Viewer + \ No newline at end of file From e6a73019ef733cfb2a0b607e4d9e44e9fdb50b2a Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Thu, 7 Dec 2017 21:23:43 -0600 Subject: [PATCH 12/21] Added functionality to session viewer for issue #99 --- GBM/Forms/frmMain.vb | 6 +- GBM/Forms/frmSessions.Designer.vb | 109 +++++++++++++++++++++++---- GBM/Forms/frmSessions.vb | 109 ++++++++++++++++++++++++--- GBM/Managers/mgrSQLite.vb | 21 ++++++ GBM/Managers/mgrSessions.vb | 77 ++++++++++++++++++- GBM/My Project/Resources.Designer.vb | 72 ++++++++++++++++++ GBM/My Project/Resources.resx | 24 ++++++ 7 files changed, 389 insertions(+), 29 deletions(-) diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 099a390..05240a2 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -881,7 +881,11 @@ Public Class frmMain Private Sub OpenSessions() Dim frm As New frmSessions PauseScan() - frm.ShowDialog() + If mgrSessions.CountRows > 0 Then + frm.ShowDialog() + Else + mgrCommon.ShowMessage(frmMain_ErrorNoSessions, MsgBoxStyle.Information) + End If ResumeScan() End Sub diff --git a/GBM/Forms/frmSessions.Designer.vb b/GBM/Forms/frmSessions.Designer.vb index 5640618..1cb7e83 100644 --- a/GBM/Forms/frmSessions.Designer.vb +++ b/GBM/Forms/frmSessions.Designer.vb @@ -22,26 +22,33 @@ Partial Class frmSessions 'Do not modify it using the code editor. _ Private Sub InitializeComponent() - Me.lblQuickFilter = New System.Windows.Forms.Label() + Me.lblFilter = New System.Windows.Forms.Label() Me.txtFilter = New System.Windows.Forms.TextBox() Me.dgSessions = New System.Windows.Forms.DataGridView() + Me.dtpStart = New System.Windows.Forms.DateTimePicker() + Me.dtpEnd = New System.Windows.Forms.DateTimePicker() + Me.lblTo = New System.Windows.Forms.Label() + Me.btnReset = New System.Windows.Forms.Button() + Me.btnDelete = New System.Windows.Forms.Button() + Me.btnClose = New System.Windows.Forms.Button() + Me.lblDateRange = New System.Windows.Forms.Label() CType(Me.dgSessions, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' - 'lblQuickFilter + 'lblFilter ' - Me.lblQuickFilter.AutoSize = True - Me.lblQuickFilter.Location = New System.Drawing.Point(12, 9) - Me.lblQuickFilter.Name = "lblQuickFilter" - Me.lblQuickFilter.Size = New System.Drawing.Size(63, 13) - Me.lblQuickFilter.TabIndex = 0 - Me.lblQuickFilter.Text = "Game Filter:" + Me.lblFilter.AutoSize = True + Me.lblFilter.Location = New System.Drawing.Point(12, 9) + Me.lblFilter.Name = "lblFilter" + Me.lblFilter.Size = New System.Drawing.Size(63, 13) + Me.lblFilter.TabIndex = 0 + Me.lblFilter.Text = "Game Filter:" ' 'txtFilter ' Me.txtFilter.Location = New System.Drawing.Point(80, 6) Me.txtFilter.Name = "txtFilter" - Me.txtFilter.Size = New System.Drawing.Size(160, 20) + Me.txtFilter.Size = New System.Drawing.Size(190, 20) Me.txtFilter.TabIndex = 1 ' 'dgSessions @@ -58,16 +65,85 @@ Partial Class frmSessions Me.dgSessions.ReadOnly = True Me.dgSessions.RowHeadersVisible = False Me.dgSessions.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect - Me.dgSessions.Size = New System.Drawing.Size(760, 517) - Me.dgSessions.TabIndex = 2 + Me.dgSessions.Size = New System.Drawing.Size(760, 488) + Me.dgSessions.TabIndex = 6 + ' + 'dtpStart + ' + Me.dtpStart.Location = New System.Drawing.Point(384, 6) + Me.dtpStart.Name = "dtpStart" + Me.dtpStart.Size = New System.Drawing.Size(175, 20) + Me.dtpStart.TabIndex = 3 + ' + 'dtpEnd + ' + Me.dtpEnd.Location = New System.Drawing.Point(597, 6) + Me.dtpEnd.Name = "dtpEnd" + Me.dtpEnd.Size = New System.Drawing.Size(175, 20) + Me.dtpEnd.TabIndex = 5 + ' + 'lblTo + ' + Me.lblTo.Location = New System.Drawing.Point(565, 9) + Me.lblTo.Name = "lblTo" + Me.lblTo.Size = New System.Drawing.Size(26, 17) + Me.lblTo.TabIndex = 4 + Me.lblTo.Text = "to" + Me.lblTo.TextAlign = System.Drawing.ContentAlignment.TopCenter + ' + 'btnReset + ' + Me.btnReset.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnReset.Location = New System.Drawing.Point(591, 526) + Me.btnReset.Name = "btnReset" + Me.btnReset.Size = New System.Drawing.Size(100, 23) + Me.btnReset.TabIndex = 2 + Me.btnReset.Text = "&Reset Filters" + Me.btnReset.UseVisualStyleBackColor = True + ' + 'btnDelete + ' + Me.btnDelete.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Left), System.Windows.Forms.AnchorStyles) + Me.btnDelete.Location = New System.Drawing.Point(12, 526) + Me.btnDelete.Name = "btnDelete" + Me.btnDelete.Size = New System.Drawing.Size(100, 23) + Me.btnDelete.TabIndex = 7 + Me.btnDelete.Text = "&Delete Session" + Me.btnDelete.UseVisualStyleBackColor = True + ' + 'btnClose + ' + Me.btnClose.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) + Me.btnClose.Location = New System.Drawing.Point(697, 526) + Me.btnClose.Name = "btnClose" + Me.btnClose.Size = New System.Drawing.Size(75, 23) + Me.btnClose.TabIndex = 8 + Me.btnClose.Text = "&Close" + Me.btnClose.UseVisualStyleBackColor = True + ' + 'lblDateRange + ' + Me.lblDateRange.AutoSize = True + Me.lblDateRange.Location = New System.Drawing.Point(310, 9) + Me.lblDateRange.Name = "lblDateRange" + Me.lblDateRange.Size = New System.Drawing.Size(68, 13) + Me.lblDateRange.TabIndex = 9 + Me.lblDateRange.Text = "Date Range:" ' 'frmSessions ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.ClientSize = New System.Drawing.Size(784, 561) + Me.Controls.Add(Me.lblDateRange) + Me.Controls.Add(Me.btnClose) + Me.Controls.Add(Me.btnDelete) + Me.Controls.Add(Me.btnReset) + Me.Controls.Add(Me.lblTo) + Me.Controls.Add(Me.dtpEnd) + Me.Controls.Add(Me.dtpStart) Me.Controls.Add(Me.dgSessions) - Me.Controls.Add(Me.lblQuickFilter) + Me.Controls.Add(Me.lblFilter) Me.Controls.Add(Me.txtFilter) Me.Name = "frmSessions" Me.ShowIcon = False @@ -79,7 +155,14 @@ Partial Class frmSessions End Sub - Friend WithEvents lblQuickFilter As Label + Friend WithEvents lblFilter As Label Friend WithEvents txtFilter As TextBox Friend WithEvents dgSessions As DataGridView + Friend WithEvents dtpStart As DateTimePicker + Friend WithEvents dtpEnd As DateTimePicker + Friend WithEvents lblTo As Label + Friend WithEvents btnReset As Button + Friend WithEvents btnDelete As Button + Friend WithEvents btnClose As Button + Friend WithEvents lblDateRange As Label End Class diff --git a/GBM/Forms/frmSessions.vb b/GBM/Forms/frmSessions.vb index fa8425f..cbc14a2 100644 --- a/GBM/Forms/frmSessions.vb +++ b/GBM/Forms/frmSessions.vb @@ -1,13 +1,19 @@ Imports GBM.My.Resources +Imports System.Globalization Public Class frmSessions + Private bInitFinished As Boolean = False Private WithEvents tmFilterTimer As Timer Private Sub FormatGrid() + dgSessions.Columns.Add("MonitorID", frmSessions_ColumnMonitorID) dgSessions.Columns.Add("Name", frmSessions_ColumnGameName) dgSessions.Columns.Add("Start", frmSessions_ColumnStart) dgSessions.Columns.Add("End", frmSessions_ColumnEnd) + + 'Hide the ID + dgSessions.Columns("MonitorID").Visible = False End Sub Private Sub LoadData() @@ -15,16 +21,16 @@ Public Class frmSessions Dim sFilter As String If txtFilter.Text = String.Empty Then - oData = mgrSessions.GetSessions + oData = mgrSessions.GetSessionRange(dtpStart.Value, dtpEnd.Value) Else sFilter = txtFilter.Text.ToLower - oData = mgrSessions.GetSessionsByGameName(sFilter) + oData = mgrSessions.GetSessionsByGameNameAndRange(sFilter, dtpStart.Value, dtpEnd.Value) End If dgSessions.Rows.Clear() For Each dr As DataRow In oData.Tables(0).Rows - dgSessions.Rows.Add(New Object() {dr("Name"), mgrCommon.UnixToDate(dr("Start")), mgrCommon.UnixToDate(dr("End"))}) + dgSessions.Rows.Add(New Object() {dr("MonitorID"), dr("Name"), mgrCommon.UnixToDate(dr("Start")), mgrCommon.UnixToDate(dr("End"))}) Next dgSessions.AutoResizeColumns() @@ -33,10 +39,79 @@ Public Class frmSessions Private Sub SetForm() Me.Text = frmSessions_Name + 'Init Labels + lblFilter.Text = frmSessions_lblFilter + lblDateRange.Text = frmSessions_lblDateRange + btnDelete.Text = frmSessions_btnDelete + btnReset.Text = frmSessions_btnReset + btnClose.Text = frmSessions_btnClose + 'Init Filter Timer tmFilterTimer = New Timer() tmFilterTimer.Interval = 1000 tmFilterTimer.Enabled = False + + + End Sub + + Private Sub ResetFilterFields() + Dim dtMinDate As DateTime = mgrSessions.GetMinimumDateTime + Dim dtMaxDate As DateTime = mgrSessions.GetMaximumDateTime + Dim sDateTimeFormat = CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern & " " & CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern + + bInitFinished = False + + 'Init Date Fields + dtpStart.Format = DateTimePickerFormat.Custom + dtpEnd.Format = DateTimePickerFormat.Custom + dtpStart.CustomFormat = sDateTimeFormat + dtpEnd.CustomFormat = sDateTimeFormat + dtpStart.MinDate = dtMinDate + dtpStart.MaxDate = dtMaxDate + dtpEnd.MinDate = dtMinDate + dtpEnd.MaxDate = dtMaxDate + dtpStart.Value = dtMinDate + dtpEnd.Value = dtMaxDate + + 'Init Text Filter + txtFilter.Text = String.Empty + + bInitFinished = True + End Sub + + Private Sub Reset() + ResetFilterFields() + LoadData() + End Sub + + Private Sub DeleteSession() + Dim oSession As clsSession + Dim oSessions As New List(Of clsSession) + + For Each dgvRow As DataGridViewRow In dgSessions.SelectedRows + oSession = New clsSession + oSession.MonitorID = dgvRow.Cells(0).Value + oSession.SessionStart = dgvRow.Cells(2).Value + oSession.SessionEnd = dgvRow.Cells(3).Value + oSessions.Add(oSession) + Next + + If oSessions.Count > 0 Then + mgrSessions.DeleteSession(oSessions) + End If + End Sub + + Private Sub frmSession_Load(sender As Object, e As EventArgs) Handles MyBase.Load + SetForm() + ResetFilterFields() + FormatGrid() + LoadData() + End Sub + + Private Sub tmFilterTimer_Tick(sender As Object, ByVal e As EventArgs) Handles tmFilterTimer.Tick + LoadData() + tmFilterTimer.Stop() + tmFilterTimer.Enabled = False End Sub Private Sub txtFilter_TextChanged(sender As Object, e As EventArgs) Handles txtFilter.TextChanged @@ -46,16 +121,28 @@ Public Class frmSessions End If End Sub - Private Sub tmFilterTimer_Tick(sender As Object, ByVal e As EventArgs) Handles tmFilterTimer.Tick - LoadData() - tmFilterTimer.Stop() - tmFilterTimer.Enabled = False + Private Sub dtpStart_ValueChanged(sender As Object, e As EventArgs) Handles dtpStart.ValueChanged + If bInitFinished Then LoadData() End Sub - Private Sub frmSession_Load(sender As Object, e As EventArgs) Handles MyBase.Load - SetForm() - FormatGrid() - LoadData() + Private Sub dtpEnd_ValueChanged(sender As Object, e As EventArgs) Handles dtpEnd.ValueChanged + If bInitFinished Then LoadData() End Sub + Private Sub btnReset_Click(sender As Object, e As EventArgs) Handles btnReset.Click + Reset() + End Sub + + Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click + Me.Close() + End Sub + + Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles btnDelete.Click + If dgSessions.SelectedRows.Count > 0 Then + If mgrCommon.ShowMessage(frmSessions_ConfirmDelete, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + DeleteSession() + Reset() + End If + End If + End Sub End Class \ No newline at end of file diff --git a/GBM/Managers/mgrSQLite.vb b/GBM/Managers/mgrSQLite.vb index d2837c4..795b083 100644 --- a/GBM/Managers/mgrSQLite.vb +++ b/GBM/Managers/mgrSQLite.vb @@ -261,6 +261,27 @@ Public Class mgrSQLite Return oData End Function + Public Function ReadSingleValue(ByVal sSQL As String, ByVal hshParams As Hashtable) As Object + + Dim command As SqliteCommand + Dim oResult As New Object + + Connect() + Command = New SqliteCommand(sSQL, db) + BuildParams(command, hshParams) + + Try + oResult = command.ExecuteScalar() + Catch ex As Exception + mgrCommon.ShowMessage(mgrSQLite_ErrorQueryFailure, New String() {sSQL, ex.Message}, MsgBoxStyle.Information) + Finally + command.Dispose() + Disconnect() + End Try + + Return oResult + End Function + Private Function GetDatabaseVersion() As Integer Dim sSQL As String Dim iVer As Integer diff --git a/GBM/Managers/mgrSessions.vb b/GBM/Managers/mgrSessions.vb index 9eac59e..ab68b43 100644 --- a/GBM/Managers/mgrSessions.vb +++ b/GBM/Managers/mgrSessions.vb @@ -37,21 +37,90 @@ Dim sSQL As String Dim hshParams As New Hashtable - sSQL = "SELECT Name, Start, End FROM sessions NATURAL JOIN monitorlist;" + sSQL = "SELECT sessions.MonitorID, monitorlist.Name, Start, End FROM sessions NATURAL JOIN monitorlist;" Return oDatabase.ReadParamData(sSQL, hshParams) End Function - Public Shared Function GetSessionsByGameName(ByVal sGameName As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DataSet + Public Shared Function GetSessionRange(ByVal dtStart As DateTime, ByVal dtEnd As DateTime, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DataSet Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String Dim hshParams As New Hashtable - sSQL = "SELECT Name, Start, End FROM sessions NATURAL JOIN monitorlist WHERE monitorlist.Name LIKE @Name;" + sSQL = "SELECT sessions.MonitorID, monitorlist.Name, Start, End FROM sessions NATURAL JOIN monitorlist WHERE Start >= @Start AND End <= @End;" - hshParams.Add("Name", "%" & sGameName & "%") + hshParams.Add("Start", mgrCommon.DateToUnix(dtStart)) + hshParams.Add("End", mgrCommon.DateToUnix(dtEnd)) Return oDatabase.ReadParamData(sSQL, hshParams) End Function + Public Shared Function GetSessionsByGameNameAndRange(ByVal sGameName As String, ByVal dtStart As DateTime, ByVal dtEnd As DateTime, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DataSet + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + + sSQL = "SELECT sessions.MonitorID, monitorlist.Name, Start, End FROM sessions NATURAL JOIN monitorlist WHERE monitorlist.Name LIKE @Name AND (Start >= @Start AND End <= @End);" + + hshParams.Add("Name", "%" & sGameName & "%") + hshParams.Add("Start", mgrCommon.DateToUnix(dtStart)) + hshParams.Add("End", mgrCommon.DateToUnix(dtEnd)) + + Return oDatabase.ReadParamData(sSQL, hshParams) + End Function + + Public Shared Sub DeleteSession(ByVal oSessions As List(Of clsSession), Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As Hashtable + Dim oParamList As New List(Of Hashtable) + + sSQL = "DELETE FROM sessions WHERE MonitorID = @MonitorID AND Start = @Start;" + + For Each oSession As clsSession In oSessions + hshParams = New Hashtable + hshParams.Add("MonitorID", oSession.MonitorID) + hshParams.Add("Start", mgrCommon.DateToUnix(oSession.SessionStart)) + oParamList.Add(hshParams) + Next + + oDatabase.RunMassParamQuery(sSQL, oParamList) + End Sub + + Public Shared Function GetMinimumDateTime(Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DateTime + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + Dim iUnixDate As Int64 + + sSQL = "SELECT Start FROM sessions ORDER BY Start ASC LIMIT 1" + + iUnixDate = CInt(oDatabase.ReadSingleValue(sSQL, hshParams)) + Return mgrCommon.UnixToDate(iUnixDate) + End Function + + Public Shared Function GetMaximumDateTime(Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As DateTime + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + Dim iUnixDate As Int64 + + sSQL = "SELECT End FROM sessions ORDER BY Start DESC LIMIT 1" + + iUnixDate = CInt(oDatabase.ReadSingleValue(sSQL, hshParams)) + Return mgrCommon.UnixToDate(iUnixDate) + End Function + + Public Shared Function CountRows(Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As Integer + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + Dim iRowCount As Integer + + sSQL = "SELECT COUNT(MonitorID) FROM sessions;" + + iRowCount = CInt(oDatabase.ReadSingleValue(sSQL, hshParams)) + + Return iRowCount + End Function End Class \ No newline at end of file diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 090a8d6..a7a69e7 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -2949,6 +2949,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to There is currently no session data to display.. + ''' + Friend ReadOnly Property frmMain_ErrorNoSessions() As String + Get + Return ResourceManager.GetString("frmMain_ErrorNoSessions", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to [PARAM] uses a relative path and has never been detected on this computer.. ''' @@ -3606,6 +3615,33 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to &Close. + ''' + Friend ReadOnly Property frmSessions_btnClose() As String + Get + Return ResourceManager.GetString("frmSessions_btnClose", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to &Delete Session. + ''' + Friend ReadOnly Property frmSessions_btnDelete() As String + Get + Return ResourceManager.GetString("frmSessions_btnDelete", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to &Reset Filters. + ''' + Friend ReadOnly Property frmSessions_btnReset() As String + Get + Return ResourceManager.GetString("frmSessions_btnReset", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to End. ''' @@ -3624,6 +3660,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to MonitorID. + ''' + Friend ReadOnly Property frmSessions_ColumnMonitorID() As String + Get + Return ResourceManager.GetString("frmSessions_ColumnMonitorID", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Start. ''' @@ -3633,6 +3678,33 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Are you sure you want to delete the selected session(s)? This cannot be undone.. + ''' + Friend ReadOnly Property frmSessions_ConfirmDelete() As String + Get + Return ResourceManager.GetString("frmSessions_ConfirmDelete", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Date Range:. + ''' + Friend ReadOnly Property frmSessions_lblDateRange() As String + Get + Return ResourceManager.GetString("frmSessions_lblDateRange", resourceCulture) + End Get + End Property + + ''' + ''' Looks up a localized string similar to Game Filter:. + ''' + Friend ReadOnly Property frmSessions_lblFilter() As String + Get + Return ResourceManager.GetString("frmSessions_lblFilter", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Session Viewer. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 8f06d19..61695a2 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1915,4 +1915,28 @@ Session Viewer + + There is currently no session data to display. + + + &Close + + + &Delete Session + + + &Reset Filters + + + MonitorID + + + Are you sure you want to delete the selected session(s)? This cannot be undone. + + + Date Range: + + + Game Filter: + \ No newline at end of file From 08e8ed58d97a837d7ebfee1a9783295237b864fc Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Thu, 7 Dec 2017 21:46:16 -0600 Subject: [PATCH 13/21] Added setting for session tracking --- GBM/Forms/frmMain.vb | 15 +++++++------- GBM/Forms/frmSettings.Designer.vb | 31 ++++++++++++++++++++-------- GBM/Forms/frmSettings.vb | 3 +++ GBM/Managers/mgrSQLite.vb | 3 ++- GBM/Managers/mgrSettings.vb | 14 ++++++++++++- GBM/My Project/Resources.Designer.vb | 18 ++++++++++++++++ GBM/My Project/Resources.resx | 6 ++++++ 7 files changed, 71 insertions(+), 19 deletions(-) diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 05240a2..95b698d 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -881,6 +881,9 @@ Public Class frmMain Private Sub OpenSessions() Dim frm As New frmSessions PauseScan() + If oSettings.SessionTracking = False Then + mgrCommon.ShowMessage(frmMain_WarningSessionsDisabled, MsgBoxStyle.Exclamation) + End If If mgrSessions.CountRows > 0 Then frm.ShowDialog() Else @@ -1791,10 +1794,8 @@ Public Class frmMain LoadGameSettings() Else bContinue = False - If oSettings.TimeTracking Then - HandleTimeSpent() - HandleSession() - End If + If oSettings.TimeTracking Then HandleTimeSpent() + If oSettings.SessionTracking Then HandleSession() UpdateLog(mgrCommon.FormatString(frmMain_ErrorBackupUnknownPath, oProcess.GameInfo.Name), False) oProcess.GameInfo = Nothing ResetGameInfo() @@ -1805,10 +1806,8 @@ Public Class frmMain If bContinue Then If DoMultiGameCheck() Then UpdateLog(mgrCommon.FormatString(frmMain_GameEnded, oProcess.GameInfo.Name), False) - If oSettings.TimeTracking Then - HandleTimeSpent() - HandleSession() - End If + If oSettings.TimeTracking Then HandleTimeSpent() + If oSettings.SessionTracking Then HandleSession() RunBackup() Else UpdateLog(frmMain_UnknownGameEnded, False) diff --git a/GBM/Forms/frmSettings.Designer.vb b/GBM/Forms/frmSettings.Designer.vb index 74b7a54..4234be1 100644 --- a/GBM/Forms/frmSettings.Designer.vb +++ b/GBM/Forms/frmSettings.Designer.vb @@ -65,6 +65,7 @@ Partial Class frmSettings Me.pnlGeneral = New System.Windows.Forms.Panel() Me.grpGameData = New System.Windows.Forms.GroupBox() Me.lstSettings = New System.Windows.Forms.ListBox() + Me.chkSessionTracking = New System.Windows.Forms.CheckBox() Me.grpStartup.SuspendLayout() Me.grpFolderOptions.SuspendLayout() Me.grp7zGeneral.SuspendLayout() @@ -123,7 +124,7 @@ Partial Class frmSettings 'chkAutoSaveLog ' Me.chkAutoSaveLog.AutoSize = True - Me.chkAutoSaveLog.Location = New System.Drawing.Point(6, 204) + Me.chkAutoSaveLog.Location = New System.Drawing.Point(12, 228) Me.chkAutoSaveLog.Name = "chkAutoSaveLog" Me.chkAutoSaveLog.Size = New System.Drawing.Size(231, 17) Me.chkAutoSaveLog.TabIndex = 3 @@ -132,7 +133,7 @@ Partial Class frmSettings ' 'btnOptionalFields ' - Me.btnOptionalFields.Location = New System.Drawing.Point(110, 38) + Me.btnOptionalFields.Location = New System.Drawing.Point(103, 61) Me.btnOptionalFields.Name = "btnOptionalFields" Me.btnOptionalFields.Size = New System.Drawing.Size(134, 23) Me.btnOptionalFields.TabIndex = 2 @@ -152,7 +153,7 @@ Partial Class frmSettings 'chkSync ' Me.chkSync.AutoSize = True - Me.chkSync.Location = New System.Drawing.Point(6, 42) + Me.chkSync.Location = New System.Drawing.Point(6, 65) Me.chkSync.Name = "chkSync" Me.chkSync.Size = New System.Drawing.Size(98, 17) Me.chkSync.TabIndex = 1 @@ -162,7 +163,7 @@ Partial Class frmSettings 'chkShowDetectionTips ' Me.chkShowDetectionTips.AutoSize = True - Me.chkShowDetectionTips.Location = New System.Drawing.Point(6, 181) + Me.chkShowDetectionTips.Location = New System.Drawing.Point(12, 205) Me.chkShowDetectionTips.Name = "chkShowDetectionTips" Me.chkShowDetectionTips.Size = New System.Drawing.Size(159, 17) Me.chkShowDetectionTips.TabIndex = 2 @@ -401,9 +402,9 @@ Partial Class frmSettings Me.grpBackupHandling.Controls.Add(Me.chkRestoreNotify) Me.grpBackupHandling.Controls.Add(Me.chkAutoMark) Me.grpBackupHandling.Location = New System.Drawing.Point(6, 88) - Me.grpBackupHandling.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) + Me.grpBackupHandling.Margin = New System.Windows.Forms.Padding(2) Me.grpBackupHandling.Name = "grpBackupHandling" - Me.grpBackupHandling.Padding = New System.Windows.Forms.Padding(2, 2, 2, 2) + Me.grpBackupHandling.Padding = New System.Windows.Forms.Padding(2) Me.grpBackupHandling.Size = New System.Drawing.Size(354, 87) Me.grpBackupHandling.TabIndex = 1 Me.grpBackupHandling.TabStop = False @@ -413,7 +414,7 @@ Partial Class frmSettings ' Me.chkAutoRestore.AutoSize = True Me.chkAutoRestore.Location = New System.Drawing.Point(8, 41) - Me.chkAutoRestore.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) + Me.chkAutoRestore.Margin = New System.Windows.Forms.Padding(2) Me.chkAutoRestore.Name = "chkAutoRestore" Me.chkAutoRestore.Size = New System.Drawing.Size(190, 17) Me.chkAutoRestore.TabIndex = 1 @@ -424,7 +425,7 @@ Partial Class frmSettings ' Me.chkRestoreNotify.AutoSize = True Me.chkRestoreNotify.Location = New System.Drawing.Point(8, 19) - Me.chkRestoreNotify.Margin = New System.Windows.Forms.Padding(2, 2, 2, 2) + Me.chkRestoreNotify.Margin = New System.Windows.Forms.Padding(2) Me.chkRestoreNotify.Name = "chkRestoreNotify" Me.chkRestoreNotify.Size = New System.Drawing.Size(216, 17) Me.chkRestoreNotify.TabIndex = 0 @@ -489,12 +490,13 @@ Partial Class frmSettings ' 'grpGameData ' + Me.grpGameData.Controls.Add(Me.chkSessionTracking) Me.grpGameData.Controls.Add(Me.chkTimeTracking) Me.grpGameData.Controls.Add(Me.chkSync) Me.grpGameData.Controls.Add(Me.btnOptionalFields) Me.grpGameData.Location = New System.Drawing.Point(6, 106) Me.grpGameData.Name = "grpGameData" - Me.grpGameData.Size = New System.Drawing.Size(354, 69) + Me.grpGameData.Size = New System.Drawing.Size(354, 92) Me.grpGameData.TabIndex = 1 Me.grpGameData.TabStop = False Me.grpGameData.Text = "Game Data" @@ -507,6 +509,16 @@ Partial Class frmSettings Me.lstSettings.Size = New System.Drawing.Size(162, 303) Me.lstSettings.TabIndex = 0 ' + 'chkSessionTracking + ' + Me.chkSessionTracking.AutoSize = True + Me.chkSessionTracking.Location = New System.Drawing.Point(6, 42) + Me.chkSessionTracking.Name = "chkSessionTracking" + Me.chkSessionTracking.Size = New System.Drawing.Size(138, 17) + Me.chkSessionTracking.TabIndex = 3 + Me.chkSessionTracking.Text = "Enable session tracking" + Me.chkSessionTracking.UseVisualStyleBackColor = True + ' 'frmSettings ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -592,4 +604,5 @@ Partial Class frmSettings Friend WithEvents chkAutoMark As CheckBox Friend WithEvents chkAutoRestore As CheckBox Friend WithEvents chkRestoreNotify As CheckBox + Friend WithEvents chkSessionTracking As CheckBox End Class diff --git a/GBM/Forms/frmSettings.vb b/GBM/Forms/frmSettings.vb index a2ff9b3..42fa217 100644 --- a/GBM/Forms/frmSettings.vb +++ b/GBM/Forms/frmSettings.vb @@ -51,6 +51,7 @@ Public Class frmSettings oSettings.AutoRestore = chkAutoRestore.Checked oSettings.AutoMark = chkAutoMark.Checked oSettings.TimeTracking = chkTimeTracking.Checked + oSettings.SessionTracking = chkSessionTracking.Checked oSettings.SupressBackup = chkSupressBackup.Checked oSettings.SupressBackupThreshold = nudSupressBackupThreshold.Value oSettings.CompressionLevel = cboCompression.SelectedValue @@ -177,6 +178,7 @@ Public Class frmSettings txtBackupFolder.Text = oSettings.BackupFolder chkSync.Checked = oSettings.Sync chkTimeTracking.Checked = oSettings.TimeTracking + chkSessionTracking.Checked = oSettings.SessionTracking chkSupressBackup.Checked = oSettings.SupressBackup nudSupressBackupThreshold.Value = oSettings.SupressBackupThreshold nudSupressBackupThreshold.Enabled = chkSupressBackup.Checked @@ -289,6 +291,7 @@ Public Class frmSettings grpStartup.Text = frmSettings_grpStartup grpGameData.Text = frmSettings_grpGameData chkTimeTracking.Text = frmSettings_chkTimeTracking + chkSessionTracking.Text = frmSettings_chkSessionTracking chkStartWindows.Text = frmSettings_chkStartWindows chkSync.Text = frmSettings_chkSync chkShowDetectionTips.Text = frmSettings_chkShowDetectionTips diff --git a/GBM/Managers/mgrSQLite.vb b/GBM/Managers/mgrSQLite.vb index 795b083..bb6b928 100644 --- a/GBM/Managers/mgrSQLite.vb +++ b/GBM/Managers/mgrSQLite.vb @@ -74,7 +74,7 @@ Public Class mgrSQLite "DisableConfirmation BOOLEAN NOT NULL, CreateSubFolder BOOLEAN NOT NULL, ShowOverwriteWarning BOOLEAN NOT NULL, RestoreOnLaunch BOOLEAN NOT NULL, " & "BackupFolder TEXT NOT NULL, Sync BOOLEAN NOT NULL, StartWithWindows BOOLEAN NOT NULL, TimeTracking BOOLEAN NOT NULL, " & "SupressBackup BOOLEAN NOT NULL, SupressBackupThreshold INTEGER NOT NULL, CompressionLevel INTEGER NOT NULL, Custom7zArguments TEXT, " & - "Custom7zLocation TEXT, SyncFields INTEGER NOT NULL, AutoSaveLog BOOLEAN NOT NULL, AutoRestore BOOLEAN NOT NULL, AutoMark BOOLEAN NOT NULL);" + "Custom7zLocation TEXT, SyncFields INTEGER NOT NULL, AutoSaveLog BOOLEAN NOT NULL, AutoRestore BOOLEAN NOT NULL, AutoMark BOOLEAN NOT NULL, SessionTracking BOOLEAN NOT NULL);" 'Add Tables (SavedPath) sSql &= "CREATE TABLE savedpath (PathName TEXT NOT NULL PRIMARY KEY, Path TEXT NOT NULL);" @@ -715,6 +715,7 @@ Public Class mgrSQLite 'Add new field(s) sSQL &= "ALTER TABLE monitorlist ADD COLUMN Comments TEXT;" + sSQL &= "ALTER TABLE settings ADD COLUMN SessionTracking BOOLEAN DEFAULT 0;" sSQL &= "PRAGMA user_version=105" diff --git a/GBM/Managers/mgrSettings.vb b/GBM/Managers/mgrSettings.vb index 73da1f9..b2c17f8 100644 --- a/GBM/Managers/mgrSettings.vb +++ b/GBM/Managers/mgrSettings.vb @@ -13,6 +13,7 @@ Public Class mgrSettings Private bAutoMark As Boolean = False Private bSync As Boolean = True Private bTimeTracking As Boolean = True + Private bSessionTracking As Boolean = True Private bSupressBackup As Boolean = False Private iSupressBackupThreshold As Integer = 10 Private iCompressionLevel As Integer = 5 @@ -130,6 +131,15 @@ Public Class mgrSettings End Set End Property + Property SessionTracking As Boolean + Get + Return bSessionTracking + End Get + Set(value As Boolean) + bSessionTracking = value + End Set + End Property + Property SupressBackup As Boolean Get Return bSupressBackup @@ -261,7 +271,7 @@ Public Class mgrSettings sSQL = "INSERT INTO settings VALUES (1, @MonitorOnStartup, @StartToTray, @ShowDetectionToolTips, @DisableConfirmation, " sSQL &= "@CreateSubFolder, @ShowOverwriteWarning, @RestoreOnLaunch, @BackupFolder, @Sync, @StartWithWindows, " sSQL &= "@TimeTracking, @SupressBackup, @SupressBackupThreshold, @CompressionLevel, @Custom7zArguments, @Custom7zLocation, " - sSQL &= "@SyncFields, @AutoSaveLog, @AutoRestore, @AutoMark)" + sSQL &= "@SyncFields, @AutoSaveLog, @AutoRestore, @AutoMark, @SessionTracking)" hshParams.Add("MonitorOnStartup", MonitorOnStartup) hshParams.Add("StartToTray", StartToTray) @@ -283,6 +293,7 @@ Public Class mgrSettings hshParams.Add("AutoSaveLog", AutoSaveLog) hshParams.Add("AutoRestore", AutoRestore) hshParams.Add("AutoMark", AutoMark) + hshParams.Add("SessionTracking", SessionTracking) oDatabase.RunParamQuery(sSQL, hshParams) End Sub @@ -317,6 +328,7 @@ Public Class mgrSettings AutoSaveLog = CBool(dr("AutoSaveLog")) AutoRestore = CBool(dr("AutoRestore")) AutoMark = CBool(dr("AutoMark")) + SessionTracking = CBool(dr("SessionTracking")) Next oDatabase.Disconnect() diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index a7a69e7..05b6ea4 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -3615,6 +3615,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Session tracking is currently disabled.[BR][BR]Enable session tracking in Settings if you'd like to track data for individual gaming sessions.. + ''' + Friend ReadOnly Property frmMain_WarningSessionsDisabled() As String + Get + Return ResourceManager.GetString("frmMain_WarningSessionsDisabled", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to &Close. ''' @@ -3912,6 +3921,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Enable session tracking. + ''' + Friend ReadOnly Property frmSettings_chkSessionTracking() As String + Get + Return ResourceManager.GetString("frmSettings_chkSessionTracking", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to Show detection notifications. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 61695a2..b68b8d0 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1939,4 +1939,10 @@ Game Filter: + + Session tracking is currently disabled.[BR][BR]Enable session tracking in Settings if you'd like to track data for individual gaming sessions. + + + Enable session tracking + \ No newline at end of file From c55875e31ae96b96dbfb9e9cfb7a633e7adc67a3 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Thu, 7 Dec 2017 21:59:19 -0600 Subject: [PATCH 14/21] Fixed date control crash in Linux --- GBM/Forms/frmSessions.vb | 13 +++++++++---- GBM/Managers/mgrSettings.vb | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/GBM/Forms/frmSessions.vb b/GBM/Forms/frmSessions.vb index cbc14a2..df6af55 100644 --- a/GBM/Forms/frmSessions.vb +++ b/GBM/Forms/frmSessions.vb @@ -66,10 +66,15 @@ Public Class frmSessions dtpEnd.Format = DateTimePickerFormat.Custom dtpStart.CustomFormat = sDateTimeFormat dtpEnd.CustomFormat = sDateTimeFormat - dtpStart.MinDate = dtMinDate - dtpStart.MaxDate = dtMaxDate - dtpEnd.MinDate = dtMinDate - dtpEnd.MaxDate = dtMaxDate + + 'Setting max or min dates breaks the control in Mono + If Not mgrCommon.IsUnix Then + dtpStart.MinDate = dtMinDate + dtpStart.MaxDate = dtMaxDate + dtpEnd.MinDate = dtMinDate + dtpEnd.MaxDate = dtMaxDate + End If + dtpStart.Value = dtMinDate dtpEnd.Value = dtMaxDate diff --git a/GBM/Managers/mgrSettings.vb b/GBM/Managers/mgrSettings.vb index b2c17f8..2d79a46 100644 --- a/GBM/Managers/mgrSettings.vb +++ b/GBM/Managers/mgrSettings.vb @@ -13,7 +13,7 @@ Public Class mgrSettings Private bAutoMark As Boolean = False Private bSync As Boolean = True Private bTimeTracking As Boolean = True - Private bSessionTracking As Boolean = True + Private bSessionTracking As Boolean = False Private bSupressBackup As Boolean = False Private iSupressBackupThreshold As Integer = 10 Private iCompressionLevel As Integer = 5 From 5165ae27e7aea7f434710548cb425b1754eddc46 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Thu, 7 Dec 2017 22:23:42 -0600 Subject: [PATCH 15/21] Fixed some resize issues with session viewer --- GBM/Forms/frmSessions.Designer.vb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/GBM/Forms/frmSessions.Designer.vb b/GBM/Forms/frmSessions.Designer.vb index 1cb7e83..9c758f3 100644 --- a/GBM/Forms/frmSessions.Designer.vb +++ b/GBM/Forms/frmSessions.Designer.vb @@ -70,6 +70,7 @@ Partial Class frmSessions ' 'dtpStart ' + Me.dtpStart.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.dtpStart.Location = New System.Drawing.Point(384, 6) Me.dtpStart.Name = "dtpStart" Me.dtpStart.Size = New System.Drawing.Size(175, 20) @@ -77,6 +78,7 @@ Partial Class frmSessions ' 'dtpEnd ' + Me.dtpEnd.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.dtpEnd.Location = New System.Drawing.Point(597, 6) Me.dtpEnd.Name = "dtpEnd" Me.dtpEnd.Size = New System.Drawing.Size(175, 20) @@ -84,6 +86,7 @@ Partial Class frmSessions ' 'lblTo ' + Me.lblTo.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.lblTo.Location = New System.Drawing.Point(565, 9) Me.lblTo.Name = "lblTo" Me.lblTo.Size = New System.Drawing.Size(26, 17) @@ -123,6 +126,7 @@ Partial Class frmSessions ' 'lblDateRange ' + Me.lblDateRange.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles) Me.lblDateRange.AutoSize = True Me.lblDateRange.Location = New System.Drawing.Point(310, 9) Me.lblDateRange.Name = "lblDateRange" @@ -147,6 +151,7 @@ Partial Class frmSessions Me.Controls.Add(Me.txtFilter) Me.Name = "frmSessions" Me.ShowIcon = False + Me.SizeGripStyle = System.Windows.Forms.SizeGripStyle.Hide Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen Me.Text = "Session Viewer" CType(Me.dgSessions, System.ComponentModel.ISupportInitialize).EndInit() From ff0f3b9dd4cdfe13cb6d6fd996c5dafbd3fe6d4f Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Fri, 8 Dec 2017 09:48:58 -0600 Subject: [PATCH 16/21] Fix for issue #112 --- GBM/Forms/frmMain.vb | 58 +++++++++++++++++----------- GBM/My Project/Resources.Designer.vb | 9 +++++ GBM/My Project/Resources.resx | 3 ++ 3 files changed, 48 insertions(+), 22 deletions(-) diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 95b698d..129e739 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -1826,36 +1826,50 @@ Public Class frmMain End Sub Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load + Dim oMutex As New System.Threading.Mutex + Dim bNewInstance As Boolean + 'Init Try - SetForm() - VerifyGameDataPath() - LoadAndVerify() - If Not bInitFail Then - VerifyCustomPathVariables() + oMutex = New System.Threading.Mutex(True, "GameBackupMonitor", bNewInstance) - If oSettings.StartToTray And Not mgrCommon.IsUnix Then - bShowToggle = False - Me.Visible = False - Me.ShowInTaskbar = False - End If + 'Ensure only one instance is running + If Not bNewInstance Then + mgrCommon.ShowMessage(frmMain_ErrorAlreadyRunning, MsgBoxStyle.Exclamation) + ShutdownApp(False) + Else + SetForm() + VerifyGameDataPath() + LoadAndVerify() + If Not bInitFail Then + VerifyCustomPathVariables() - If oSettings.MonitorOnStartup Then - eCurrentStatus = eStatus.Stopped - Else - eCurrentStatus = eStatus.Running - End If + If oSettings.StartToTray And Not mgrCommon.IsUnix Then + bShowToggle = False + Me.Visible = False + Me.ShowInTaskbar = False + End If - HandleScan() - CheckForNewBackups() + If oSettings.MonitorOnStartup Then + eCurrentStatus = eStatus.Stopped + Else + eCurrentStatus = eStatus.Running + End If - 'Unix Handler - If mgrCommon.IsUnix Then - Me.MinimizeBox = True - Else - Me.gMonTray.Visible = True + HandleScan() + CheckForNewBackups() + + 'Unix Handler + If mgrCommon.IsUnix Then + Me.MinimizeBox = True + Else + Me.gMonTray.Visible = True + End If + + GC.KeepAlive(oMutex) End If End If + Catch ex As Exception If mgrCommon.ShowMessage(frmMain_ErrorInitFailure, ex.Message, MsgBoxStyle.YesNo) = MsgBoxResult.No Then bInitFail = True diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 05b6ea4..7c91d1e 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -2832,6 +2832,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to An instance of Game Backup Monitor is already running.. + ''' + Friend ReadOnly Property frmMain_ErrorAlreadyRunning() As String + Get + Return ResourceManager.GetString("frmMain_ErrorAlreadyRunning", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to GBM is running from a new location, the Windows startup entry has been updated.. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index b68b8d0..8ed7679 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1945,4 +1945,7 @@ Enable session tracking + + An instance of Game Backup Monitor is already running. + \ No newline at end of file From 8a41566b5ff1944c450a84b3b171c09c40b45f43 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Fri, 8 Dec 2017 11:48:58 -0600 Subject: [PATCH 17/21] Updated readme for v1.0.5 --- GBM/readme.txt | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/GBM/readme.txt b/GBM/readme.txt index 77c1e33..8f7d1c4 100644 --- a/GBM/readme.txt +++ b/GBM/readme.txt @@ -1,20 +1,27 @@ -Game Backup Monitor v1.04 Readme +Game Backup Monitor v1.0.5 Readme http://mikemaximus.github.io/gbm-web/ gamebackupmonitor@gmail.com -September 26, 2017 +December 8, 2017 -New in 1.04 +New in 1.0.5 -- (All) The import feature now detects most saved games currently on your PC and automatically selects configurations for you. -- (All) The Game Manager's "Custom Filter" feature has received a major overhaul: - - More fields are now available for use. - - Added the ability to combine different filters. - - Added the ability to set a sort field and order. - - The current filter is now saved when the Custom Filter window is closed and re-opened. -- (All) The "Monitor Only" feature has been updated. This feature allows tracking play time for games that do not require a backup, such as MMOs or CCGs. - - The Game Manager now disables and ignores validation on fields that aren't needed for a Monitor Only configuration. - - Monitor Only is now included in the XML Import / Export. - - Monitor Only configurations may now be included in the official game lists. +All Platforms: + +- You can now add Comments to a game configuration. +- You can now exclude tags and use negative filters on the Game Manager. +- Fixed a bug causing backup size calculations to be incorrect when including sub-folders in a configuration. +- Fixed a bug causing GBM to calculate the backup size of an incorrect location when using a relative path configuration. This could cause very long delays when a backup was running. +- XML export files now contain the date, version and amount of configurations. The Import window will now display the date of the XML file in the title bar if applicable. +- Fixed a bug causing games not to be detected if more than one copy of the process was running. +- GBM can now save statistical data from each detected gaming sesion: + - This feature records the start and end time of each detected gaming session. In future versions more data may be available. + - You can view session data using the new "Session Viewer" available in the Tools menu. + - This feature is disabled by default. It can be enabled on the Setting screen. + - Session data is stored locally, it is currently not synced with the backup folder. + +Windows Only: + +- Only one instance of GBM can now be running at once. The entire version history of GBM releases is available at http://mikemaximus.github.io/gbm-web/versionhistory.html \ No newline at end of file From b7b3d053c745798f97f912d6b4863e4355d88636 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Fri, 8 Dec 2017 15:19:17 -0600 Subject: [PATCH 18/21] Fixed readme errors --- GBM/readme.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GBM/readme.txt b/GBM/readme.txt index 8f7d1c4..900b69a 100644 --- a/GBM/readme.txt +++ b/GBM/readme.txt @@ -14,7 +14,7 @@ All Platforms: - Fixed a bug causing GBM to calculate the backup size of an incorrect location when using a relative path configuration. This could cause very long delays when a backup was running. - XML export files now contain the date, version and amount of configurations. The Import window will now display the date of the XML file in the title bar if applicable. - Fixed a bug causing games not to be detected if more than one copy of the process was running. -- GBM can now save statistical data from each detected gaming sesion: +- GBM can now save statistical data from each detected gaming session: - This feature records the start and end time of each detected gaming session. In future versions more data may be available. - You can view session data using the new "Session Viewer" available in the Tools menu. - This feature is disabled by default. It can be enabled on the Setting screen. @@ -22,6 +22,6 @@ All Platforms: Windows Only: -- Only one instance of GBM can now be running at once. +- Only one instance of GBM can now be running. The entire version history of GBM releases is available at http://mikemaximus.github.io/gbm-web/versionhistory.html \ No newline at end of file From 476ec70fe50410126b0fc1508fc0b0878a477f66 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Fri, 8 Dec 2017 15:38:06 -0600 Subject: [PATCH 19/21] Added missing Linux changes to readme --- GBM/readme.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/GBM/readme.txt b/GBM/readme.txt index 900b69a..0502c48 100644 --- a/GBM/readme.txt +++ b/GBM/readme.txt @@ -23,5 +23,9 @@ All Platforms: Windows Only: - Only one instance of GBM can now be running. + +Linux Only: + +- Added makefile for easy Linux installation. Thanks basxto! The entire version history of GBM releases is available at http://mikemaximus.github.io/gbm-web/versionhistory.html \ No newline at end of file From 7330c5bcba3d0e8635ab7fb6bd48429f193ab67c Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Fri, 8 Dec 2017 22:09:08 -0600 Subject: [PATCH 20/21] Fixes for issue #109 and #112 --- .../XML Serialize Classes/ExportData.vb | 51 +++++++++++++++---- .../ExportInformation.vb | 44 ---------------- GBM/Forms/frmAdvancedImport.vb | 10 ++-- GBM/Forms/frmMain.vb | 18 ++++--- GBM/Game Backup Monitor.vbproj | 1 - GBM/Managers/mgrMonitorList.vb | 24 ++++++++- GBM/Managers/mgrXML.vb | 11 ++-- 7 files changed, 84 insertions(+), 75 deletions(-) delete mode 100644 GBM/Classes/XML Serialize Classes/ExportInformation.vb diff --git a/GBM/Classes/XML Serialize Classes/ExportData.vb b/GBM/Classes/XML Serialize Classes/ExportData.vb index 306516e..3113b27 100644 --- a/GBM/Classes/XML Serialize Classes/ExportData.vb +++ b/GBM/Classes/XML Serialize Classes/ExportData.vb @@ -1,16 +1,43 @@ -Public Class ExportData - Dim oExportInformation As ExportInformation - Dim oConfigs As List(Of Game) +Imports System.Xml.Serialization - Property Information As ExportInformation - Set(value As ExportInformation) - oExportInformation = value + +Public Class ExportData + Dim oConfigs As List(Of Game) + Private dExported As Int64 + Private iTotalConfigs As Integer + Private iAppVer As Integer + + + Property Exported As Int64 + Set(value As Int64) + dExported = value End Set Get - Return oExportInformation + Return dExported End Get End Property + + Property TotalConfigurations As Integer + Set(value As Integer) + iTotalConfigs = value + End Set + Get + Return iTotalConfigs + End Get + End Property + + + Property AppVer As Integer + Set(value As Integer) + iAppVer = value + End Set + Get + Return iAppVer + End Get + End Property + + Property Configurations As List(Of Game) Set(value As List(Of Game)) oConfigs = value @@ -21,12 +48,16 @@ End Property Public Sub New() - oExportInformation = New ExportInformation() + dExported = 0 + iTotalConfigs = 0 + iAppVer = 0 oConfigs = New List(Of Game) End Sub - Public Sub New(ByVal oInitExportInformation As ExportInformation, ByVal oInitConfigs As List(Of Game)) - oExportInformation = oInitExportInformation + Public Sub New(ByVal dInitExported As Int64, ByVal iInitTotalConfigs As Integer, ByVal iInitAppVer As Integer, ByVal oInitConfigs As List(Of Game)) + dExported = dInitExported + iTotalConfigs = iInitTotalConfigs + iAppVer = iInitAppVer oConfigs = oInitConfigs End Sub End Class diff --git a/GBM/Classes/XML Serialize Classes/ExportInformation.vb b/GBM/Classes/XML Serialize Classes/ExportInformation.vb deleted file mode 100644 index 602aef6..0000000 --- a/GBM/Classes/XML Serialize Classes/ExportInformation.vb +++ /dev/null @@ -1,44 +0,0 @@ -Public Class ExportInformation - Private dExported As Int64 - Private iTotalConfigs As Integer - Private iAppVer As Integer - - Property Exported As Int64 - Set(value As Int64) - dExported = value - End Set - Get - Return dExported - End Get - End Property - - Property TotalConfigurations As Integer - Set(value As Integer) - iTotalConfigs = value - End Set - Get - Return iTotalConfigs - End Get - End Property - - Property AppVer As Integer - Set(value As Integer) - iAppVer = value - End Set - Get - Return iAppVer - End Get - End Property - - Public Sub New() - dExported = 0 - iTotalConfigs = 0 - iAppVer = 0 - End Sub - - Public Sub New(ByVal dInitExported As Int64, ByVal iInitTotalConfigs As Integer, ByVal iInitAppVer As Integer) - dExported = dInitExported - iTotalConfigs = iInitTotalConfigs - iAppVer = iInitAppVer - End Sub -End Class diff --git a/GBM/Forms/frmAdvancedImport.vb b/GBM/Forms/frmAdvancedImport.vb index f2260b3..f71dec8 100644 --- a/GBM/Forms/frmAdvancedImport.vb +++ b/GBM/Forms/frmAdvancedImport.vb @@ -3,7 +3,7 @@ Imports System.IO Public Class frmAdvancedImport - Private oImportInfo As ExportInformation + Private oImportData As ExportData Private hshImportData As Hashtable Private hshFinalData As New Hashtable Private bSelectAll As Boolean = True @@ -11,12 +11,12 @@ Public Class frmAdvancedImport Private iCurrentSort As Integer = 0 Private WithEvents tmFilterTimer As Timer - Public Property ImportInfo As ExportInformation - Set(value As ExportInformation) - oImportInfo = value + Public Property ImportInfo As ExportData + Set(value As ExportData) + oImportData = value End Set Get - Return oImportInfo + Return oImportData End Get End Property diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 129e739..8fa0238 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -1825,16 +1825,20 @@ Public Class frmMain oProcess.StartTime = Now : oProcess.EndTime = Now End Sub - Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load - Dim oMutex As New System.Threading.Mutex - Dim bNewInstance As Boolean + Private Function IsGBMRunning() As Boolean + Dim prsList() As Process = Process.GetProcessesByName("GBM") + If prsList.Length > 1 Then + Return True + Else + Return False + End If + End Function + Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'Init Try - oMutex = New System.Threading.Mutex(True, "GameBackupMonitor", bNewInstance) - 'Ensure only one instance is running - If Not bNewInstance Then + If IsGBMRunning() Then mgrCommon.ShowMessage(frmMain_ErrorAlreadyRunning, MsgBoxStyle.Exclamation) ShutdownApp(False) Else @@ -1865,8 +1869,6 @@ Public Class frmMain Else Me.gMonTray.Visible = True End If - - GC.KeepAlive(oMutex) End If End If diff --git a/GBM/Game Backup Monitor.vbproj b/GBM/Game Backup Monitor.vbproj index dc616fb..5804d33 100644 --- a/GBM/Game Backup Monitor.vbproj +++ b/GBM/Game Backup Monitor.vbproj @@ -127,7 +127,6 @@ - diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index 24d3474..263aece 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -158,6 +158,10 @@ Public Class mgrMonitorList sSQL = "DELETE FROM gametags " sSQL &= "WHERE MonitorID = @MonitorID;" + If iSelectDB = mgrSQLite.Database.Local Then + sSQL &= "DELETE FROM sessions " + sSQL &= "WHERE MonitorID = @MonitorID;" + End If sSQL &= "DELETE FROM monitorlist " sSQL &= "WHERE MonitorID = @MonitorID;" @@ -185,6 +189,20 @@ Public Class mgrMonitorList sSQL = sSQL.TrimEnd(",") sSQL &= ");" + If iSelectDB = mgrSQLite.Database.Local Then + sSQL &= "DELETE FROM sessions " + sSQL &= "WHERE MonitorID IN (" + + For Each s As String In sMonitorIDs + sSQL &= "@MonitorID" & iCounter & "," + hshParams.Add("MonitorID" & iCounter, s) + iCounter += 1 + Next + + sSQL = sSQL.TrimEnd(",") + sSQL &= ");" + End If + sSQL &= "DELETE FROM monitorlist " sSQL &= "WHERE MonitorID IN (" @@ -407,6 +425,10 @@ Public Class mgrMonitorList sSQL = "DELETE FROM gametags " sSQL &= "WHERE MonitorID = @MonitorID;" + If iSelectDB = mgrSQLite.Database.Local Then + sSQL &= "DELETE FROM sessions " + sSQL &= "WHERE MonitorID = @MonitorID;" + End If sSQL &= "DELETE FROM monitorlist " sSQL &= "WHERE Name = @Name AND Process= @Process;" @@ -735,7 +757,7 @@ Public Class mgrMonitorList Dim hshSyncItems As Hashtable Dim oFromItem As clsGame Dim oToItem As clsGame - Dim oExportInfo As New ExportInformation + Dim oExportInfo As New ExportData Cursor.Current = Cursors.WaitCursor diff --git a/GBM/Managers/mgrXML.vb b/GBM/Managers/mgrXML.vb index b8829bb..5f48229 100644 --- a/GBM/Managers/mgrXML.vb +++ b/GBM/Managers/mgrXML.vb @@ -6,7 +6,7 @@ Imports System.Net Public Class mgrXML - Public Shared Function ReadMonitorList(ByVal sLocation As String, ByRef oExportInfo As ExportInformation, Optional ByVal bWebRead As Boolean = False) As Hashtable + Public Shared Function ReadMonitorList(ByVal sLocation As String, ByRef oExportInfo As ExportData, Optional ByVal bWebRead As Boolean = False) As Hashtable Dim oList As List(Of Game) Dim hshList As New Hashtable Dim hshDupeList As New Hashtable @@ -21,7 +21,7 @@ Public Class mgrXML oExportData = ImportandDeserialize(sLocation, bWebRead) oList = oExportData.Configurations - oExportInfo = oExportData.Information + oExportInfo = oExportData For Each g As Game In oList oGame = New clsGame @@ -76,7 +76,7 @@ Public Class mgrXML oReader.Close() 'Compatability Mode - If oExportData.Information.AppVer = 0 Then + If oExportData.AppVer = 0 Then oReader = ReadImportData(sLocation, bWebRead) oSerializer = New XmlSerializer(GetType(List(Of Game)), New XmlRootAttribute("gbm")) oExportData.Configurations = oSerializer.Deserialize(oReader) @@ -93,12 +93,11 @@ Public Class mgrXML Public Shared Function SerializeAndExport(ByVal oList As List(Of Game), ByVal sLocation As String) As Boolean Dim oSerializer As XmlSerializer Dim oWriter As StreamWriter - Dim oExportInformation = New ExportInformation(mgrCommon.DateToUnix(Now), oList.Count, mgrCommon.AppVersion) Dim oExportData As ExportData Try - oExportData = New ExportData(oExportInformation, oList) - oSerializer = New XmlSerializer(oExportData.GetType(), New XmlRootAttribute("gbm")) + oExportData = New ExportData(mgrCommon.DateToUnix(Now), oList.Count, mgrCommon.AppVersion, oList) + oSerializer = New XmlSerializer(oExportData.GetType()) oWriter = New StreamWriter(sLocation) oSerializer.Serialize(oWriter.BaseStream, oExportData) oWriter.Flush() From 89079332852d275d0138acd8b7ecfa4b3fe57863 Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Sat, 9 Dec 2017 10:09:01 -0600 Subject: [PATCH 21/21] Switched to VB method of single instance --- GBM/Forms/frmMain.vb | 60 ++++++++++---------------- GBM/My Project/Application.Designer.vb | 2 +- GBM/My Project/Application.myapp | 2 +- GBM/My Project/Resources.Designer.vb | 9 ---- GBM/My Project/Resources.resx | 3 -- 5 files changed, 24 insertions(+), 52 deletions(-) diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index 8fa0238..95b698d 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -1825,53 +1825,37 @@ Public Class frmMain oProcess.StartTime = Now : oProcess.EndTime = Now End Sub - Private Function IsGBMRunning() As Boolean - Dim prsList() As Process = Process.GetProcessesByName("GBM") - If prsList.Length > 1 Then - Return True - Else - Return False - End If - End Function - Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'Init Try - 'Ensure only one instance is running - If IsGBMRunning() Then - mgrCommon.ShowMessage(frmMain_ErrorAlreadyRunning, MsgBoxStyle.Exclamation) - ShutdownApp(False) - Else - SetForm() - VerifyGameDataPath() - LoadAndVerify() - If Not bInitFail Then - VerifyCustomPathVariables() + SetForm() + VerifyGameDataPath() + LoadAndVerify() + If Not bInitFail Then + VerifyCustomPathVariables() - If oSettings.StartToTray And Not mgrCommon.IsUnix Then - bShowToggle = False - Me.Visible = False - Me.ShowInTaskbar = False - End If + If oSettings.StartToTray And Not mgrCommon.IsUnix Then + bShowToggle = False + Me.Visible = False + Me.ShowInTaskbar = False + End If - If oSettings.MonitorOnStartup Then - eCurrentStatus = eStatus.Stopped - Else - eCurrentStatus = eStatus.Running - End If + If oSettings.MonitorOnStartup Then + eCurrentStatus = eStatus.Stopped + Else + eCurrentStatus = eStatus.Running + End If - HandleScan() - CheckForNewBackups() + HandleScan() + CheckForNewBackups() - 'Unix Handler - If mgrCommon.IsUnix Then - Me.MinimizeBox = True - Else - Me.gMonTray.Visible = True - End If + 'Unix Handler + If mgrCommon.IsUnix Then + Me.MinimizeBox = True + Else + Me.gMonTray.Visible = True End If End If - Catch ex As Exception If mgrCommon.ShowMessage(frmMain_ErrorInitFailure, ex.Message, MsgBoxStyle.YesNo) = MsgBoxResult.No Then bInitFail = True diff --git a/GBM/My Project/Application.Designer.vb b/GBM/My Project/Application.Designer.vb index cce8b29..c3dd7aa 100644 --- a/GBM/My Project/Application.Designer.vb +++ b/GBM/My Project/Application.Designer.vb @@ -24,7 +24,7 @@ Namespace My _ Public Sub New() MyBase.New(Global.Microsoft.VisualBasic.ApplicationServices.AuthenticationMode.Windows) - Me.IsSingleInstance = false + Me.IsSingleInstance = true Me.EnableVisualStyles = true Me.SaveMySettingsOnExit = false Me.ShutDownStyle = Global.Microsoft.VisualBasic.ApplicationServices.ShutdownMode.AfterMainFormCloses diff --git a/GBM/My Project/Application.myapp b/GBM/My Project/Application.myapp index 20701f6..6060cf8 100644 --- a/GBM/My Project/Application.myapp +++ b/GBM/My Project/Application.myapp @@ -2,7 +2,7 @@ true frmMain - false + true 0 true 0 diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 7c91d1e..05b6ea4 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -2832,15 +2832,6 @@ Namespace My.Resources End Get End Property - ''' - ''' Looks up a localized string similar to An instance of Game Backup Monitor is already running.. - ''' - Friend ReadOnly Property frmMain_ErrorAlreadyRunning() As String - Get - Return ResourceManager.GetString("frmMain_ErrorAlreadyRunning", resourceCulture) - End Get - End Property - ''' ''' Looks up a localized string similar to GBM is running from a new location, the Windows startup entry has been updated.. ''' diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 8ed7679..b68b8d0 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -1945,7 +1945,4 @@ Enable session tracking - - An instance of Game Backup Monitor is already running. - \ No newline at end of file