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
Dim oExportInformation As ExportInformation
Dim oConfigs As List(Of Game)
Imports System.Xml.Serialization
Property Information As ExportInformation
Set(value As ExportInformation)
oExportInformation = value
<XmlRoot("gbm")>
Public Class ExportData
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
Get
Return oExportInformation
Return dExported
End Get
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)
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
@@ -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
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
+10 -8
View File
@@ -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
-1
View File
@@ -127,7 +127,6 @@
<Compile Include="Classes\clsSavedPath.vb" />
<Compile Include="Classes\clsSession.vb" />
<Compile Include="Classes\XML Serialize Classes\ExportData.vb" />
<Compile Include="Classes\XML Serialize Classes\ExportInformation.vb" />
<Compile Include="Classes\XML Serialize Classes\Tag.vb" />
<Compile Include="Classes\XML Serialize Classes\Game.vb" />
<Compile Include="Classes\clsGameTag.vb" />
+23 -1
View File
@@ -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
+5 -6
View File
@@ -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()