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()