Added game id sync to import

This commit is contained in:
MikeMaximus
2018-03-04 21:23:01 -06:00
parent 2e5fa70f58
commit ddee737222
5 changed files with 119 additions and 5 deletions
+4
View File
@@ -1497,7 +1497,9 @@ Public Class frmGameManager
If sLocation <> String.Empty Then If sLocation <> String.Empty Then
If mgrMonitorList.DoImport(sLocation) Then If mgrMonitorList.DoImport(sLocation) Then
mgrMonitorList.SyncMonitorLists(Settings.SyncFields)
LoadData() LoadData()
LoadBackupData()
End If End If
End If End If
@@ -1525,7 +1527,9 @@ Public Class frmGameManager
If mgrCommon.ShowMessage(frmGameManager_ConfirmOfficialImport, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then If mgrCommon.ShowMessage(frmGameManager_ConfirmOfficialImport, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
If mgrMonitorList.DoImport(sImportURL) Then If mgrMonitorList.DoImport(sImportURL) Then
mgrMonitorList.SyncMonitorLists(Settings.SyncFields)
LoadData() LoadData()
LoadBackupData()
End If End If
End If End If
End Sub End Sub
+76 -2
View File
@@ -163,7 +163,6 @@ Public Class mgrMonitorList
End If End If
oDatabase.RunParamQuery(sSQL, hshParams) oDatabase.RunParamQuery(sSQL, hshParams)
End Sub 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) Public Shared Sub DoListUpdateMulti(ByVal sMonitorIDs As List(Of String), ByVal oGame As clsGame, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local)
@@ -787,6 +786,9 @@ Public Class mgrMonitorList
If (sPath.IndexOf("http://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Or If (sPath.IndexOf("http://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Or
(sPath.IndexOf("https://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Then (sPath.IndexOf("https://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Then
If mgrCommon.CheckAddress(sPath) Then If mgrCommon.CheckAddress(sPath) Then
If mgrCommon.ShowMessage(mgrMonitorList_ConfirmGameIDSync, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
ImportSyncGameID(sPath, True)
End If
ImportMonitorList(sPath, True) ImportMonitorList(sPath, True)
Return True Return True
Else Else
@@ -795,6 +797,9 @@ Public Class mgrMonitorList
End If End If
Else Else
If File.Exists(sPath) Then If File.Exists(sPath) Then
If mgrCommon.ShowMessage(mgrMonitorList_ConfirmGameIDSync, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
ImportSyncGameID(sPath)
End If
ImportMonitorList(sPath) ImportMonitorList(sPath)
Return True Return True
Else Else
@@ -815,8 +820,14 @@ Public Class mgrMonitorList
Cursor.Current = Cursors.WaitCursor Cursor.Current = Cursors.WaitCursor
'Add / Update Sync
hshCompareFrom = mgrXML.ReadMonitorList(sLocation, oExportInfo, bWebRead) hshCompareFrom = mgrXML.ReadMonitorList(sLocation, oExportInfo, bWebRead)
If oExportInfo.AppVer < 110 Then
If mgrCommon.ShowMessage(mgrMonitorList_ImportVersionWarning, MsgBoxStyle.YesNo) = MsgBoxResult.No Then
Exit Sub
End If
End If
hshCompareTo = ReadList(eListTypes.FullList, mgrSQLite.Database.Local) hshCompareTo = ReadList(eListTypes.FullList, mgrSQLite.Database.Local)
hshSyncItems = hshCompareFrom.Clone hshSyncItems = hshCompareFrom.Clone
@@ -829,7 +840,11 @@ Public Class mgrMonitorList
hshSyncItems.Remove(oFromItem.ID) hshSyncItems.Remove(oFromItem.ID)
Else Else
DirectCast(hshSyncItems(oFromItem.ID), clsGame).ImportUpdate = True DirectCast(hshSyncItems(oFromItem.ID), clsGame).ImportUpdate = True
'These fields need to be set via the object or they will be lost when the configuration is updated
DirectCast(hshSyncItems(oFromItem.ID), clsGame).Hours = oToItem.Hours
DirectCast(hshSyncItems(oFromItem.ID), clsGame).CleanFolder = oToItem.CleanFolder
End If End If
End If End If
End If End If
Next Next
@@ -856,6 +871,65 @@ Public Class mgrMonitorList
Application.DoEvents() Application.DoEvents()
End Sub End Sub
Private Shared Sub ImportSyncGameID(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False)
Dim oLocalDatabase As New mgrSQLite(mgrSQLite.Database.Local)
Dim oRemoteDatabase As New mgrSQLite(mgrSQLite.Database.Remote)
Dim sSQL As String
Dim hshParams As Hashtable
Dim oParamList As New List(Of Hashtable)
Dim hshCompareFrom As Hashtable
Dim hshCompareTo As Hashtable
Dim hshSyncIDs As New Hashtable
Dim oFromItem As clsGame
Dim oToItem As clsGame
Dim oExportInfo As New ExportData
Cursor.Current = Cursors.WaitCursor
hshCompareFrom = mgrXML.ReadMonitorList(sLocation, oExportInfo, bWebRead)
If oExportInfo.AppVer < 110 Then
mgrCommon.ShowMessage(mgrMonitorList_ErrorGameIDVerFailure, MsgBoxStyle.Exclamation)
Exit Sub
End If
hshCompareTo = ReadList(eListTypes.FullList, mgrSQLite.Database.Local)
For Each oFromItem In hshCompareFrom.Values
If Not hshCompareTo.Contains(oFromItem.ID) Then
For Each oToItem In hshCompareTo.Values
'Strip all special characters and compare names
If Regex.Replace(oToItem.Name, "[^\w]+", "") = Regex.Replace(oFromItem.Name, "[^\w]+", "") Then
'Ignore games with duplicate names
If Not hshSyncIDs.Contains(oFromItem.ID) Then
hshSyncIDs.Add(oToItem.ID, oFromItem.ID)
End If
End If
Next
End If
Next
For Each de As DictionaryEntry In hshSyncIDs
hshParams = New Hashtable
hshParams.Add("MonitorID", CStr(de.Value))
hshParams.Add("QueryID", CStr(de.Key))
oParamList.Add(hshParams)
Next
sSQL = "UPDATE monitorlist SET MonitorID=@MonitorID WHERE MonitorID=@QueryID;"
sSQL &= "UPDATE gametags SET MonitorID=@MonitorID WHERE MonitorID=@QueryID;"
sSQL &= "UPDATE manifest SET MonitorID=@MonitorID WHERE MonitorID=@QueryID;"
oRemoteDatabase.RunMassParamQuery(sSQL, oParamList)
sSQL &= "UPDATE sessions SET MonitorID=@MonitorID WHERE MonitorID=@QueryID;"
oLocalDatabase.RunMassParamQuery(sSQL, oParamList)
Cursor.Current = Cursors.Default
End Sub
Public Shared Sub ExportMonitorList(ByVal sLocation As String) Public Shared Sub ExportMonitorList(ByVal sLocation As String)
Dim oList As List(Of Game) Dim oList As List(Of Game)
Dim bSuccess As Boolean = False Dim bSuccess As Boolean = False
+27
View File
@@ -5437,6 +5437,24 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to GBM now uses a unique identifier for each game. For the import feature to work as intended, your existing game configurations need to use the same identifiers.[BR][BR]Do you want to sync your game identifiers? (Recommened).
'''</summary>
Friend ReadOnly Property mgrMonitorList_ConfirmGameIDSync() As String
Get
Return ResourceManager.GetString("mgrMonitorList_ConfirmGameIDSync", resourceCulture)
End Get
End Property
'''<summary>
''' Looks up a localized string similar to This file cannot be used to sync game indentifiers. It was created with an older version of GBM..
'''</summary>
Friend ReadOnly Property mgrMonitorList_ErrorGameIDVerFailure() As String
Get
Return ResourceManager.GetString("mgrMonitorList_ErrorGameIDVerFailure", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to Export Complete. [PARAM] item(s) have been exported.. ''' Looks up a localized string similar to Export Complete. [PARAM] item(s) have been exported..
'''</summary> '''</summary>
@@ -5473,6 +5491,15 @@ Namespace My.Resources
End Get End Get
End Property End Property
'''<summary>
''' Looks up a localized string similar to This export file was created with a version of GBM prior to 1.1.0 and does not contain unique game identifiers.[BR][BR]Do you still want to import configurations from this file? (Not Recommended).
'''</summary>
Friend ReadOnly Property mgrMonitorList_ImportVersionWarning() As String
Get
Return ResourceManager.GetString("mgrMonitorList_ImportVersionWarning", resourceCulture)
End Get
End Property
'''<summary> '''<summary>
''' Looks up a localized string similar to [PARAM] change(s) synced.. ''' Looks up a localized string similar to [PARAM] change(s) synced..
'''</summary> '''</summary>
+9
View File
@@ -2026,4 +2026,13 @@
<data name="frmFilter_FieldGameID" xml:space="preserve"> <data name="frmFilter_FieldGameID" xml:space="preserve">
<value>Game ID</value> <value>Game ID</value>
</data> </data>
<data name="mgrMonitorList_ConfirmGameIDSync" xml:space="preserve">
<value>GBM now uses a unique identifier for each game. For the import feature to work as intended, your existing game configurations need to use the same identifiers.[BR][BR]Do you want to sync your game identifiers? (Recommened)</value>
</data>
<data name="mgrMonitorList_ErrorGameIDVerFailure" xml:space="preserve">
<value>This file cannot be used to sync game indentifiers. It was created with an older version of GBM.</value>
</data>
<data name="mgrMonitorList_ImportVersionWarning" xml:space="preserve">
<value>This export file was created with a version of GBM prior to 1.1.0 and does not contain unique game identifiers.[BR][BR]Do you still want to import configurations from this file? (Not Recommended)</value>
</data>
</root> </root>
+3 -3
View File
@@ -8,9 +8,9 @@ New in 1.1.0
Disclaimer: Disclaimer:
1. This is pre-release software intended for testing. Version 1.1.0 makes fundamental changes to how GBM works with game configurations and backup data. Please read the changes below carefully.
2. Database files from this version (gbm.s3db) may not be compatible with the full release. GBM makes automatic backups of your database files if you need to revert to a prior version.
3. Do not make external links to this release, it will be available for a limited time. I've done my best to make sure the upgrade process is seamless and allows everyone to continue using their existing data and configurations.
All Platforms: All Platforms: