Changes for issue #109
This commit is contained in:
@@ -0,0 +1,32 @@
|
|||||||
|
Public Class ExportData
|
||||||
|
Dim oExportInformation As ExportInformation
|
||||||
|
Dim oConfigs As List(Of Game)
|
||||||
|
|
||||||
|
Property Information As ExportInformation
|
||||||
|
Set(value As ExportInformation)
|
||||||
|
oExportInformation = value
|
||||||
|
End Set
|
||||||
|
Get
|
||||||
|
Return oExportInformation
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Property Configurations As List(Of Game)
|
||||||
|
Set(value As List(Of Game))
|
||||||
|
oConfigs = value
|
||||||
|
End Set
|
||||||
|
Get
|
||||||
|
Return oConfigs
|
||||||
|
End Get
|
||||||
|
End Property
|
||||||
|
|
||||||
|
Public Sub New()
|
||||||
|
oExportInformation = New ExportInformation()
|
||||||
|
oConfigs = New List(Of Game)
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub New(ByVal oInitExportInformation As ExportInformation, ByVal oInitConfigs As List(Of Game))
|
||||||
|
oExportInformation = oInitExportInformation
|
||||||
|
oConfigs = oInitConfigs
|
||||||
|
End Sub
|
||||||
|
End Class
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
Public Class ExportInformation
|
||||||
|
Private dExported As Int64
|
||||||
|
Private iAppVer As Integer
|
||||||
|
|
||||||
|
Property Exported As Int64
|
||||||
|
Set(value As Int64)
|
||||||
|
dExported = value
|
||||||
|
End Set
|
||||||
|
Get
|
||||||
|
Return dExported
|
||||||
|
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
|
||||||
|
iAppVer = 0
|
||||||
|
End Sub
|
||||||
|
|
||||||
|
Public Sub New(ByVal dInitExported As Int64, ByVal iInitAppVer As Integer)
|
||||||
|
dExported = dInitExported
|
||||||
|
iAppVer = iInitAppVer
|
||||||
|
End Sub
|
||||||
|
End Class
|
||||||
@@ -126,6 +126,8 @@
|
|||||||
<Compile Include="Classes\clsGameFilterField.vb" />
|
<Compile Include="Classes\clsGameFilterField.vb" />
|
||||||
<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\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" />
|
||||||
|
|||||||
+34
-12
@@ -46,38 +46,60 @@ Public Class mgrXML
|
|||||||
Return hshList
|
Return hshList
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Shared Function ImportandDeserialize(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) As List(Of Game)
|
Private Shared Function ReadImportData(ByVal sLocation As String, ByVal bWebRead As Boolean)
|
||||||
Dim oReader As StreamReader
|
Dim oReader As StreamReader
|
||||||
Dim oWebClient As WebClient
|
Dim oWebClient As WebClient
|
||||||
|
|
||||||
|
If bWebRead Then
|
||||||
|
oWebClient = New WebClient
|
||||||
|
oReader = New StreamReader(oWebClient.OpenRead(sLocation))
|
||||||
|
Else
|
||||||
|
oReader = New StreamReader(sLocation)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return oReader
|
||||||
|
End Function
|
||||||
|
|
||||||
|
Public Shared Function ImportandDeserialize(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) As List(Of Game)
|
||||||
|
Dim oReader As StreamReader
|
||||||
Dim oSerializer As XmlSerializer
|
Dim oSerializer As XmlSerializer
|
||||||
Dim oList As New List(Of Game)
|
Dim oExportData As New ExportData
|
||||||
|
Dim oConfigurations As New List(Of Game)
|
||||||
|
|
||||||
Try
|
Try
|
||||||
If bWebRead Then
|
oReader = ReadImportData(sLocation, bWebRead)
|
||||||
oWebClient = New WebClient
|
oSerializer = New XmlSerializer(oExportData.GetType(), New XmlRootAttribute("gbm"))
|
||||||
oReader = New StreamReader(oWebClient.OpenRead(sLocation))
|
oExportData = oSerializer.Deserialize(oReader)
|
||||||
|
oReader.Close()
|
||||||
|
|
||||||
|
'Compatability Mode
|
||||||
|
If oExportData.Information.AppVer = 0 Then
|
||||||
|
oReader = ReadImportData(sLocation, bWebRead)
|
||||||
|
oSerializer = New XmlSerializer(oConfigurations.GetType(), New XmlRootAttribute("gbm"))
|
||||||
|
oConfigurations = oSerializer.Deserialize(oReader)
|
||||||
|
oReader.Close()
|
||||||
Else
|
Else
|
||||||
oReader = New StreamReader(sLocation)
|
oConfigurations = oExportData.Configurations
|
||||||
End If
|
End If
|
||||||
|
|
||||||
oSerializer = New XmlSerializer(oList.GetType(), New XmlRootAttribute("gbm"))
|
|
||||||
oList = oSerializer.Deserialize(oReader)
|
|
||||||
oReader.Close()
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
mgrCommon.ShowMessage(mgrXML_ErrorImportFailure, ex.Message, MsgBoxStyle.Exclamation)
|
mgrCommon.ShowMessage(mgrXML_ErrorImportFailure, ex.Message, MsgBoxStyle.Exclamation)
|
||||||
End Try
|
End Try
|
||||||
|
|
||||||
Return oList
|
Return oConfigurations
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
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), mgrCommon.AppVersion)
|
||||||
|
Dim oExportData As ExportData
|
||||||
|
|
||||||
Try
|
Try
|
||||||
oSerializer = New XmlSerializer(oList.GetType(), New XmlRootAttribute("gbm"))
|
oExportData = New ExportData(oExportInformation, oList)
|
||||||
|
oSerializer = New XmlSerializer(oExportData.GetType(), New XmlRootAttribute("gbm"))
|
||||||
oWriter = New StreamWriter(sLocation)
|
oWriter = New StreamWriter(sLocation)
|
||||||
oSerializer.Serialize(oWriter.BaseStream, oList)
|
oSerializer.Serialize(oWriter.BaseStream, oExportData)
|
||||||
oWriter.Flush()
|
oWriter.Flush()
|
||||||
oWriter.Close()
|
oWriter.Close()
|
||||||
Return True
|
Return True
|
||||||
|
|||||||
Reference in New Issue
Block a user