Fixes for issue #109 and #112

This commit is contained in:
MikeMaximus
2017-12-08 22:09:08 -06:00
parent 476ec70fe5
commit 7330c5bcba
7 changed files with 84 additions and 75 deletions
+41 -10
View File
@@ -1,16 +1,43 @@
Public Class ExportData Imports System.Xml.Serialization
Dim oExportInformation As ExportInformation
Dim oConfigs As List(Of Game)
Property Information As ExportInformation <XmlRoot("gbm")>
Set(value As ExportInformation) Public Class ExportData
oExportInformation = value Dim oConfigs As List(Of Game)
Private dExported As Int64
Private iTotalConfigs As Integer
Private iAppVer As Integer
<XmlAttribute("Exported")>
Property Exported As Int64
Set(value As Int64)
dExported = value
End Set End Set
Get Get
Return oExportInformation Return dExported
End Get End Get
End Property End Property
<XmlAttribute("TotalConfigurations")>
Property TotalConfigurations As Integer
Set(value As Integer)
iTotalConfigs = value
End Set
Get
Return iTotalConfigs
End Get
End Property
<XmlAttribute("AppVer")>
Property AppVer As Integer
Set(value As Integer)
iAppVer = value
End Set
Get
Return iAppVer
End Get
End Property
<XmlElement("Game")>
Property Configurations As List(Of Game) Property Configurations As List(Of Game)
Set(value As List(Of Game)) Set(value As List(Of Game))
oConfigs = value oConfigs = value
@@ -21,12 +48,16 @@
End Property End Property
Public Sub New() Public Sub New()
oExportInformation = New ExportInformation() dExported = 0
iTotalConfigs = 0
iAppVer = 0
oConfigs = New List(Of Game) oConfigs = New List(Of Game)
End Sub End Sub
Public Sub New(ByVal oInitExportInformation As ExportInformation, ByVal oInitConfigs As List(Of Game)) Public Sub New(ByVal dInitExported As Int64, ByVal iInitTotalConfigs As Integer, ByVal iInitAppVer As Integer, ByVal oInitConfigs As List(Of Game))
oExportInformation = oInitExportInformation dExported = dInitExported
iTotalConfigs = iInitTotalConfigs
iAppVer = iInitAppVer
oConfigs = oInitConfigs oConfigs = oInitConfigs
End Sub End Sub
End Class End Class
@@ -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
+5 -5
View File
@@ -3,7 +3,7 @@ Imports System.IO
Public Class frmAdvancedImport Public Class frmAdvancedImport
Private oImportInfo As ExportInformation Private oImportData As ExportData
Private hshImportData As Hashtable Private hshImportData As Hashtable
Private hshFinalData As New Hashtable Private hshFinalData As New Hashtable
Private bSelectAll As Boolean = True Private bSelectAll As Boolean = True
@@ -11,12 +11,12 @@ Public Class frmAdvancedImport
Private iCurrentSort As Integer = 0 Private iCurrentSort As Integer = 0
Private WithEvents tmFilterTimer As Timer Private WithEvents tmFilterTimer As Timer
Public Property ImportInfo As ExportInformation Public Property ImportInfo As ExportData
Set(value As ExportInformation) Set(value As ExportData)
oImportInfo = value oImportData = value
End Set End Set
Get Get
Return oImportInfo Return oImportData
End Get End Get
End Property End Property
+10 -8
View File
@@ -1825,16 +1825,20 @@ Public Class frmMain
oProcess.StartTime = Now : oProcess.EndTime = Now oProcess.StartTime = Now : oProcess.EndTime = Now
End Sub End Sub
Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Private Function IsGBMRunning() As Boolean
Dim oMutex As New System.Threading.Mutex Dim prsList() As Process = Process.GetProcessesByName("GBM")
Dim bNewInstance As Boolean 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 'Init
Try Try
oMutex = New System.Threading.Mutex(True, "GameBackupMonitor", bNewInstance)
'Ensure only one instance is running 'Ensure only one instance is running
If Not bNewInstance Then If IsGBMRunning() Then
mgrCommon.ShowMessage(frmMain_ErrorAlreadyRunning, MsgBoxStyle.Exclamation) mgrCommon.ShowMessage(frmMain_ErrorAlreadyRunning, MsgBoxStyle.Exclamation)
ShutdownApp(False) ShutdownApp(False)
Else Else
@@ -1865,8 +1869,6 @@ Public Class frmMain
Else Else
Me.gMonTray.Visible = True Me.gMonTray.Visible = True
End If End If
GC.KeepAlive(oMutex)
End If End If
End If End If
-1
View File
@@ -127,7 +127,6 @@
<Compile Include="Classes\clsSavedPath.vb" /> <Compile Include="Classes\clsSavedPath.vb" />
<Compile Include="Classes\clsSession.vb" /> <Compile Include="Classes\clsSession.vb" />
<Compile Include="Classes\XML Serialize Classes\ExportData.vb" /> <Compile Include="Classes\XML Serialize Classes\ExportData.vb" />
<Compile Include="Classes\XML Serialize Classes\ExportInformation.vb" />
<Compile Include="Classes\XML Serialize Classes\Tag.vb" /> <Compile Include="Classes\XML Serialize Classes\Tag.vb" />
<Compile Include="Classes\XML Serialize Classes\Game.vb" /> <Compile Include="Classes\XML Serialize Classes\Game.vb" />
<Compile Include="Classes\clsGameTag.vb" /> <Compile Include="Classes\clsGameTag.vb" />
+23 -1
View File
@@ -158,6 +158,10 @@ Public Class mgrMonitorList
sSQL = "DELETE FROM gametags " sSQL = "DELETE FROM gametags "
sSQL &= "WHERE MonitorID = @MonitorID;" 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 &= "DELETE FROM monitorlist "
sSQL &= "WHERE MonitorID = @MonitorID;" sSQL &= "WHERE MonitorID = @MonitorID;"
@@ -185,6 +189,20 @@ Public Class mgrMonitorList
sSQL = sSQL.TrimEnd(",") sSQL = sSQL.TrimEnd(",")
sSQL &= ");" 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 &= "DELETE FROM monitorlist "
sSQL &= "WHERE MonitorID IN (" sSQL &= "WHERE MonitorID IN ("
@@ -407,6 +425,10 @@ Public Class mgrMonitorList
sSQL = "DELETE FROM gametags " sSQL = "DELETE FROM gametags "
sSQL &= "WHERE MonitorID = @MonitorID;" 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 &= "DELETE FROM monitorlist "
sSQL &= "WHERE Name = @Name AND Process= @Process;" sSQL &= "WHERE Name = @Name AND Process= @Process;"
@@ -735,7 +757,7 @@ Public Class mgrMonitorList
Dim hshSyncItems As Hashtable Dim hshSyncItems As Hashtable
Dim oFromItem As clsGame Dim oFromItem As clsGame
Dim oToItem As clsGame Dim oToItem As clsGame
Dim oExportInfo As New ExportInformation Dim oExportInfo As New ExportData
Cursor.Current = Cursors.WaitCursor Cursor.Current = Cursors.WaitCursor
+5 -6
View File
@@ -6,7 +6,7 @@ Imports System.Net
Public Class mgrXML 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 oList As List(Of Game)
Dim hshList As New Hashtable Dim hshList As New Hashtable
Dim hshDupeList As New Hashtable Dim hshDupeList As New Hashtable
@@ -21,7 +21,7 @@ Public Class mgrXML
oExportData = ImportandDeserialize(sLocation, bWebRead) oExportData = ImportandDeserialize(sLocation, bWebRead)
oList = oExportData.Configurations oList = oExportData.Configurations
oExportInfo = oExportData.Information oExportInfo = oExportData
For Each g As Game In oList For Each g As Game In oList
oGame = New clsGame oGame = New clsGame
@@ -76,7 +76,7 @@ Public Class mgrXML
oReader.Close() oReader.Close()
'Compatability Mode 'Compatability Mode
If oExportData.Information.AppVer = 0 Then If oExportData.AppVer = 0 Then
oReader = ReadImportData(sLocation, bWebRead) oReader = ReadImportData(sLocation, bWebRead)
oSerializer = New XmlSerializer(GetType(List(Of Game)), New XmlRootAttribute("gbm")) oSerializer = New XmlSerializer(GetType(List(Of Game)), New XmlRootAttribute("gbm"))
oExportData.Configurations = oSerializer.Deserialize(oReader) 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 Public Shared Function SerializeAndExport(ByVal oList As List(Of Game), ByVal sLocation As String) As Boolean
Dim oSerializer As XmlSerializer Dim oSerializer As XmlSerializer
Dim oWriter As StreamWriter Dim oWriter As StreamWriter
Dim oExportInformation = New ExportInformation(mgrCommon.DateToUnix(Now), oList.Count, mgrCommon.AppVersion)
Dim oExportData As ExportData Dim oExportData As ExportData
Try Try
oExportData = New ExportData(oExportInformation, oList) oExportData = New ExportData(mgrCommon.DateToUnix(Now), oList.Count, mgrCommon.AppVersion, oList)
oSerializer = New XmlSerializer(oExportData.GetType(), New XmlRootAttribute("gbm")) oSerializer = New XmlSerializer(oExportData.GetType())
oWriter = New StreamWriter(sLocation) oWriter = New StreamWriter(sLocation)
oSerializer.Serialize(oWriter.BaseStream, oExportData) oSerializer.Serialize(oWriter.BaseStream, oExportData)
oWriter.Flush() oWriter.Flush()