From 6461c80ae0be276fa8c653d16b9154d782ea1dfc Mon Sep 17 00:00:00 2001 From: MikeMaximus Date: Thu, 8 Mar 2018 09:04:48 -0600 Subject: [PATCH] Updated import/id sync error handling and messaging --- GBM/Managers/mgrMonitorList.vb | 12 ++++++++---- GBM/Managers/mgrXML.vb | 21 +++++++++++---------- GBM/My Project/Resources.Designer.vb | 6 +++--- GBM/My Project/Resources.resx | 6 +++--- 4 files changed, 25 insertions(+), 20 deletions(-) diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index 353f2fc..eb17a5b 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -818,7 +818,7 @@ Public Class mgrMonitorList End Function Private Shared Sub ImportMonitorList(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) - Dim hshCompareFrom As Hashtable + Dim hshCompareFrom As New Hashtable Dim hshCompareTo As Hashtable Dim hshSyncItems As Hashtable Dim oFromItem As clsGame @@ -827,7 +827,9 @@ Public Class mgrMonitorList Cursor.Current = Cursors.WaitCursor - hshCompareFrom = mgrXML.ReadMonitorList(sLocation, oExportInfo, bWebRead) + If Not mgrXML.ReadMonitorList(sLocation, oExportInfo, hshCompareFrom, bWebRead) Then + Exit Sub + End If If oExportInfo.AppVer < 110 Then If mgrCommon.ShowMessage(mgrMonitorList_ImportVersionWarning, MsgBoxStyle.YesNo) = MsgBoxResult.No Then @@ -884,7 +886,7 @@ Public Class mgrMonitorList Dim sSQL As String Dim hshParams As Hashtable Dim oParamList As New List(Of Hashtable) - Dim hshCompareFrom As Hashtable + Dim hshCompareFrom As New Hashtable Dim hshCompareTo As Hashtable Dim hshSyncIDs As New Hashtable Dim oFromItem As clsGame @@ -893,7 +895,9 @@ Public Class mgrMonitorList Cursor.Current = Cursors.WaitCursor - hshCompareFrom = mgrXML.ReadMonitorList(sLocation, oExportInfo, bWebRead) + If Not mgrXML.ReadMonitorList(sLocation, oExportInfo, hshCompareFrom, bWebRead) Then + Exit Sub + End If If oExportInfo.AppVer < 110 Then mgrCommon.ShowMessage(mgrMonitorList_ErrorGameIDVerFailure, MsgBoxStyle.Exclamation) diff --git a/GBM/Managers/mgrXML.vb b/GBM/Managers/mgrXML.vb index 5b1e91e..69b7a6a 100644 --- a/GBM/Managers/mgrXML.vb +++ b/GBM/Managers/mgrXML.vb @@ -6,20 +6,22 @@ Imports System.Net Public Class mgrXML - Public Shared Function ReadMonitorList(ByVal sLocation As String, ByRef oExportInfo As ExportData, Optional ByVal bWebRead As Boolean = False) As Hashtable + Public Shared Function ReadMonitorList(ByVal sLocation As String, ByRef oExportInfo As ExportData, ByRef hshList As Hashtable, Optional ByVal bWebRead As Boolean = False) As Boolean Dim oList As List(Of Game) - Dim hshList As New Hashtable Dim hshDupeList As New Hashtable - Dim oExportData As ExportData + Dim oExportData As New ExportData Dim oGame As clsGame 'If the file doesn't exist return an empty list If Not File.Exists(sLocation) And Not bWebRead Then - Return hshList + Return False + End If + + If Not ImportandDeserialize(sLocation, oExportData, bWebRead) Then + Return False End If - oExportData = ImportandDeserialize(sLocation, bWebRead) oList = oExportData.Configurations oExportInfo = oExportData @@ -49,7 +51,7 @@ Public Class mgrXML End Try Next - Return hshList + Return True End Function Private Shared Function ReadImportData(ByVal sLocation As String, ByVal bWebRead As Boolean) @@ -66,10 +68,9 @@ Public Class mgrXML Return oReader End Function - Public Shared Function ImportandDeserialize(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) As ExportData + Public Shared Function ImportandDeserialize(ByVal sLocation As String, ByRef oExportData As ExportData, Optional ByVal bWebRead As Boolean = False) As Boolean Dim oReader As StreamReader Dim oSerializer As XmlSerializer - Dim oExportData As New ExportData Try oReader = ReadImportData(sLocation, bWebRead) @@ -84,12 +85,12 @@ Public Class mgrXML oExportData.Configurations = oSerializer.Deserialize(oReader) oReader.Close() End If - + Return True Catch ex As Exception mgrCommon.ShowMessage(mgrXML_ErrorImportFailure, ex.Message, MsgBoxStyle.Exclamation) + Return False End Try - Return oExportData End Function Public Shared Function SerializeAndExport(ByVal oList As List(Of Game), ByVal sLocation As String) As Boolean diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index 77f5fb0..d1f6800 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -5512,7 +5512,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to Do you want to sync your identifiers with this export file?[BR][BR]You should only do this if you're managing your own game configurations.. + ''' Looks up a localized string similar to Do you want to sync your game identifiers with this export file?[BR][BR]You should only do this if you're managing your own game configurations. Please see the online manual for more information.. ''' Friend ReadOnly Property mgrMonitorList_ConfirmFileGameIDSync() As String Get @@ -5521,7 +5521,7 @@ Namespace My.Resources End Property ''' - ''' 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 should use the same identifiers.[BR][BR]Do you want to sync your identifiers with the official list?[BR][BR]This warning will only be displayed once, but the option is available anytime from the "Tools" menu.. + ''' Looks up a localized string similar to GBM now uses a unique identifier for each game. For the import feature to recognize game configurations from a prior version, they need to use the same identifiers.[BR][BR]Do you want to sync your game identifiers with the official list?[BR][BR]This question will only be displayed once, but the option is available anytime from the "Tools" menu. Please see the online manual for more information.. ''' Friend ReadOnly Property mgrMonitorList_ConfirmInitialOfficialGameIDSync() As String Get @@ -5530,7 +5530,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to Do you want to sync your identifiers with the official game list?. + ''' Looks up a localized string similar to Do you want to sync your game identifiers with the official game list?[BR][BR]This allows the import feature to recognize game configurations from a prior version. Please see the online manual for more information.. ''' Friend ReadOnly Property mgrMonitorList_ConfirmOfficialGameIDSync() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 23a0358..5f53281 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -2024,7 +2024,7 @@ Game ID - GBM now uses a unique identifier for each game. For the import feature to work as intended, your existing game configurations should use the same identifiers.[BR][BR]Do you want to sync your identifiers with the official list?[BR][BR]This warning will only be displayed once, but the option is available anytime from the "Tools" menu. + GBM now uses a unique identifier for each game. For the import feature to recognize game configurations from a prior version, they need to use the same identifiers.[BR][BR]Do you want to sync your game identifiers with the official list?[BR][BR]This question will only be displayed once, but the option is available anytime from the "Tools" menu. Please see the online manual for more information. This file cannot be used to sync game indentifiers. It was created with an older version of GBM. @@ -2033,7 +2033,7 @@ 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) - Do you want to sync your identifiers with this export file?[BR][BR]You should only do this if you're managing your own game configurations. + Do you want to sync your game identifiers with this export file?[BR][BR]You should only do this if you're managing your own game configurations. Please see the online manual for more information. S&ync Game IDs @@ -2045,7 +2045,7 @@ &Official List... - Do you want to sync your identifiers with the official game list? + Do you want to sync your game identifiers with the official game list?[BR][BR]This allows the import feature to recognize game configurations from a prior version. Please see the online manual for more information. &Reset Warnings