From a7728c7bb1d547b9fb2e77c2e4bd979507b801f0 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Fri, 8 Feb 2019 10:16:12 -0600 Subject: [PATCH] Refined how configs are updated after detection and backup --- GBM/Forms/frmMain.vb | 4 ++-- GBM/Managers/mgrBackup.vb | 2 +- GBM/Managers/mgrMonitorList.vb | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb index bed7bcf..f18f1ec 100644 --- a/GBM/Forms/frmMain.vb +++ b/GBM/Forms/frmMain.vb @@ -735,7 +735,7 @@ Public Class frmMain DirectCast(hshScanList.Item(oProcess.GameInfo.ID), clsGame).Hours = oProcess.GameInfo.Hours End If - mgrMonitorList.DoListUpdate(oProcess.GameInfo) + mgrMonitorList.DoListFieldUpdate("Hours", oProcess.GameInfo.Hours, oProcess.GameInfo.ID) mgrMonitorList.SyncMonitorLists(oSettings) UpdateTimeSpent(dCurrentHours, oProcess.TimeSpent.TotalHours) @@ -2013,7 +2013,7 @@ Public Class frmMain oProcess.GameInfo.ProcessPath = mgrPath.ProcessPathSearch(oProcess.GameInfo.Name, oProcess.GameInfo.ProcessName, sPathDetectionError) If oProcess.GameInfo.ProcessPath <> String.Empty Then 'Update and reload - mgrMonitorList.DoListUpdate(oProcess.GameInfo) + mgrMonitorList.DoListFieldUpdate("ProcessPath", oProcess.GameInfo.ProcessPath, oProcess.GameInfo.ID) LoadGameSettings() Else bContinue = False diff --git a/GBM/Managers/mgrBackup.vb b/GBM/Managers/mgrBackup.vb index 6576c45..fcfeff9 100644 --- a/GBM/Managers/mgrBackup.vb +++ b/GBM/Managers/mgrBackup.vb @@ -403,7 +403,7 @@ Public Class mgrBackup 'Write the process path if we have it If oGame.AbsolutePath = False Then - mgrMonitorList.DoListUpdate(oGame) + mgrMonitorList.DoListFieldUpdate("ProcessPath", oGame.ProcessPath, oGame.ID) End If End If Catch ex As Exception diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index b91db5d..3f8c10c 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -144,6 +144,20 @@ Public Class mgrMonitorList oDatabase.RunParamQuery(sSQL, hshParams) End Sub + 'Do NOT change MonitorID with this function + Public Shared Sub DoListFieldUpdate(ByVal sFieldName As String, ByVal oValue As Object, ByVal sQueryID As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + + sSQL = "UPDATE monitorlist SET " & sFieldName & "=@" & sFieldName & " WHERE MonitorID=@QueryID;" + + 'Parameters + hshParams.Add(sFieldName, oValue) + hshParams.Add("QueryID", sQueryID) + oDatabase.RunParamQuery(sSQL, hshParams) + End Sub + Public Shared Sub DoListUpdateMulti(ByVal sMonitorIDs As List(Of String), ByVal oGame As clsGame, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String