diff --git a/GBM/Forms/frmAddWizard.vb b/GBM/Forms/frmAddWizard.vb
index eadf9c0..6066c0d 100644
--- a/GBM/Forms/frmAddWizard.vb
+++ b/GBM/Forms/frmAddWizard.vb
@@ -416,7 +416,7 @@ Public Class frmAddWizard
End If
sNewPath = mgrCommon.OpenFileBrowser("Wizard_Process_Path", frmAddWizard_ChooseProcess, "exe",
- frmAddWizard_Executable, sDefaultFolder, False, False)
+ frmAddWizard_Executable, sDefaultFolder, False)
If sNewPath <> String.Empty Then txtProcessPath.Text = sNewPath
End Sub
diff --git a/GBM/Forms/frmGameManager.Designer.vb b/GBM/Forms/frmGameManager.Designer.vb
index 0191fc4..a437865 100644
--- a/GBM/Forms/frmGameManager.Designer.vb
+++ b/GBM/Forms/frmGameManager.Designer.vb
@@ -104,6 +104,7 @@ Partial Class frmGameManager
Me.cmsDeleteAll = New System.Windows.Forms.ToolStripMenuItem()
Me.btnProcesses = New System.Windows.Forms.Button()
Me.ttFullPath = New System.Windows.Forms.ToolTip(Me.components)
+ Me.btnImportBackup = New System.Windows.Forms.Button()
Me.grpConfig.SuspendLayout()
CType(Me.nudLimit, System.ComponentModel.ISupportInitialize).BeginInit()
Me.grpExtra.SuspendLayout()
@@ -573,6 +574,7 @@ Partial Class frmGameManager
'grpStats
'
Me.grpStats.Anchor = CType((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
+ Me.grpStats.Controls.Add(Me.btnImportBackup)
Me.grpStats.Controls.Add(Me.cboRemoteBackup)
Me.grpStats.Controls.Add(Me.lblRestorePathData)
Me.grpStats.Controls.Add(Me.lblBackupFileData)
@@ -665,7 +667,7 @@ Partial Class frmGameManager
Me.btnDeleteBackup.Location = New System.Drawing.Point(129, 125)
Me.btnDeleteBackup.Name = "btnDeleteBackup"
Me.btnDeleteBackup.Size = New System.Drawing.Size(114, 23)
- Me.btnDeleteBackup.TabIndex = 8
+ Me.btnDeleteBackup.TabIndex = 9
Me.btnDeleteBackup.Text = "&Delete Backup"
Me.btnDeleteBackup.UseVisualStyleBackColor = True
'
@@ -899,6 +901,15 @@ Partial Class frmGameManager
Me.ttFullPath.InitialDelay = 300
Me.ttFullPath.ReshowDelay = 60
'
+ 'btnImportBackup
+ '
+ Me.btnImportBackup.Location = New System.Drawing.Point(9, 125)
+ Me.btnImportBackup.Name = "btnImportBackup"
+ Me.btnImportBackup.Size = New System.Drawing.Size(114, 23)
+ Me.btnImportBackup.TabIndex = 8
+ Me.btnImportBackup.Text = "Import B&ackup Files"
+ Me.btnImportBackup.UseVisualStyleBackColor = True
+ '
'frmGameManager
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@@ -1030,4 +1041,5 @@ Partial Class frmGameManager
Friend WithEvents btnGameID As Button
Friend WithEvents btnProcesses As Button
Friend WithEvents ttFullPath As ToolTip
+ Friend WithEvents btnImportBackup As Button
End Class
diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb
index 47389ba..dea6062 100644
--- a/GBM/Forms/frmGameManager.vb
+++ b/GBM/Forms/frmGameManager.vb
@@ -14,8 +14,10 @@ Public Class frmGameManager
Private bDisableExternalFunctions As Boolean = False
Private bTriggerBackup As Boolean = False
Private bTriggerRestore As Boolean = False
+ Private bTriggerImportBackup As Boolean = False
Private oBackupList As New List(Of clsGame)
Private oRestoreList As New Hashtable
+ Private oImportBackupList As New Hashtable
Private oGameData As OrderedDictionary
Private oLocalBackupData As SortedList
Private oRemoteBackupData As SortedList
@@ -121,6 +123,15 @@ Public Class frmGameManager
End Set
End Property
+ Property TriggerImportBackup As Boolean
+ Get
+ Return bTriggerImportBackup
+ End Get
+ Set(value As Boolean)
+ bTriggerImportBackup = value
+ End Set
+ End Property
+
Property BackupList As List(Of clsGame)
Get
Return oBackupList
@@ -139,6 +150,15 @@ Public Class frmGameManager
End Set
End Property
+ Property ImportBackupList As Hashtable
+ Get
+ Return oImportBackupList
+ End Get
+ Set(value As Hashtable)
+ oImportBackupList = value
+ End Set
+ End Property
+
Private Property IsDirty As Boolean
Get
Return bIsDirty
@@ -344,7 +364,7 @@ Public Class frmGameManager
End If
sNewPath = mgrCommon.OpenFileBrowser("GM_Process", frmGameManager_ChooseExe, "exe",
- frmGameManager_Executable, sDefaultFolder, False, False)
+ frmGameManager_Executable, sDefaultFolder, False)
If sNewPath <> String.Empty Then
txtAppPath.Text = Path.GetDirectoryName(sNewPath)
@@ -402,10 +422,10 @@ Public Class frmGameManager
'Unix Handler
If Not mgrCommon.IsUnix Then
sNewPath = mgrCommon.OpenFileBrowser("GM_Icon", frmGameManager_ChooseCustomIcon, "ico",
- frmGameManager_Icon, sDefaultFolder, False, False)
+ frmGameManager_Icon, sDefaultFolder, False)
Else
sNewPath = mgrCommon.OpenFileBrowser("GM_Icon", frmGameManager_ChooseCustomIcon, "png",
- "PNG", sDefaultFolder, False, False)
+ "PNG", sDefaultFolder, False)
End If
If sNewPath <> String.Empty Then
@@ -1524,6 +1544,31 @@ Public Class frmGameManager
End If
End Sub
+ Private Sub TriggerSelectedImportBackup()
+ Dim sDefaultFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
+ Dim oBackup As New mgrBackup
+ Dim sFile As String
+ Dim sFiles As String()
+
+ ImportBackupList.Clear()
+
+ sFiles = mgrCommon.OpenMultiFileBrowser("GM_ImportBackup", frmGameManager_Choose7zImport, "7z",
+ frmGameManager_7zBackup, sDefaultFolder, True)
+
+ If sFiles.Length > 0 Then
+ For Each sFile In sFiles
+ If Not ImportBackupList.Contains(sFile) Then
+ ImportBackupList.Add(sFile, oCurrentGame)
+ End If
+ Next
+
+ If mgrCommon.ShowMessage(frmGameManager_ConfirmBackupImport, oCurrentGame.CroppedName, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
+ Me.TriggerImportBackup = True
+ Me.Close()
+ End If
+ End If
+ End Sub
+
Private Sub TriggerSelectedBackup(Optional ByVal bPrompt As Boolean = True)
Dim oData As KeyValuePair(Of String, String)
Dim sMsg As String = String.Empty
@@ -1722,6 +1767,7 @@ Public Class frmGameManager
lblComments.Text = frmGameManager_lblComments
chkRegEx.Text = frmGameManager_chkRegEx
btnGameID.Text = frmGameManager_btnGameID
+ btnImportBackup.Text = frmGameManager_btnImportBackup
'Init Filter Timer
tmFilterTimer = New Timer()
@@ -1875,6 +1921,10 @@ Public Class frmGameManager
UpdateBuilderButtonLabel(txtExclude.Text, frmGameManager_ExcludeShortcut, btnExclude, (sExclude <> txtExclude.Text))
End Sub
+ Private Sub btnImportBackup_Click(sender As Object, e As EventArgs) Handles btnImportBackup.Click
+ TriggerSelectedImportBackup()
+ End Sub
+
Private Sub chkFolderSave_CheckedChanged(sender As Object, e As EventArgs) Handles chkFolderSave.CheckedChanged
FolderSaveModeChange()
End Sub
@@ -1947,5 +1997,4 @@ Public Class frmGameManager
Private Sub chkMonitorOnly_CheckedChanged(sender As Object, e As EventArgs) Handles chkMonitorOnly.CheckedChanged
MonitorOnlyModeChange()
End Sub
-
End Class
diff --git a/GBM/Forms/frmMain.vb b/GBM/Forms/frmMain.vb
index 05a056c..f839c58 100644
--- a/GBM/Forms/frmMain.vb
+++ b/GBM/Forms/frmMain.vb
@@ -258,6 +258,12 @@ Public Class frmMain
End Sub
+ Private Sub RunImportBackup(ByVal oImportBackupList As Hashtable)
+ PauseScan()
+ oBackup.ImportBackupFiles(oImportBackupList)
+ ResumeScan()
+ End Sub
+
Private Function DoMultiGameCheck() As Boolean
Dim oResult As DialogResult
@@ -889,6 +895,11 @@ Public Class frmMain
If frm.TriggerRestore Then
RunRestore(frm.RestoreList)
End If
+
+ 'Handle import backup trigger
+ If frm.TriggerImportBackup Then
+ RunImportBackup(frm.ImportBackupList)
+ End If
End Sub
Private Sub OpenSettings()
diff --git a/GBM/Forms/frmProcessManager.vb b/GBM/Forms/frmProcessManager.vb
index cc56904..60a6d75 100644
--- a/GBM/Forms/frmProcessManager.vb
+++ b/GBM/Forms/frmProcessManager.vb
@@ -56,7 +56,7 @@ Public Class frmProcessManager
End If
sNewPath = mgrCommon.OpenFileBrowser("PM_Process", frmProcessManager_ChooseProcess, "exe",
- frmProcessManager_Executable, sDefaultFolder, False, True)
+ frmProcessManager_Executable, sDefaultFolder, True)
If sNewPath <> String.Empty Then
txtPath.Text = sNewPath
diff --git a/GBM/Managers/mgrBackup.vb b/GBM/Managers/mgrBackup.vb
index 1163fcf..8d3eb30 100644
--- a/GBM/Managers/mgrBackup.vb
+++ b/GBM/Managers/mgrBackup.vb
@@ -42,7 +42,7 @@ Public Class mgrBackup
'Create manifest item
oItem.MonitorID = oGameInfo.ID
'Keep the path relative to the manifest location
- oItem.FileName = sBackupFile.Replace(Path.GetDirectoryName(mgrPath.RemoteDatabaseLocation) & Path.DirectorySeparatorChar, "")
+ oItem.FileName = sBackupFile.Replace(Settings.BackupFolder & Path.DirectorySeparatorChar, String.Empty)
oItem.DateUpdated = dTimeStamp
oItem.UpdatedBy = My.Computer.Name
oItem.CheckSum = sCheckSum
@@ -196,6 +196,60 @@ Public Class mgrBackup
End If
End Sub
+ Private Function BuildFileTimeStamp(ByVal dDate As Date) As String
+ Return " " & dDate.Month & "-" & dDate.Day & "-" & dDate.Year & "-" & dDate.Hour & "-" & dDate.Minute & "-" & dDate.Second
+ End Function
+
+ Private Function HandleSubFolder(ByVal oGame As clsGame, ByVal sPath As String) As Boolean
+ Try
+ If Not Directory.Exists(sPath) Then
+ Directory.CreateDirectory(sPath)
+ End If
+ Catch ex As Exception
+ RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorSubFolderCreate, New String() {oGame.Name, ex.Message}), False, ToolTipIcon.Error, True)
+ Return False
+ End Try
+
+ Return True
+ End Function
+
+ Public Sub ImportBackupFiles(ByVal hshImportList As Hashtable)
+ Dim oGame As clsGame
+ Dim bContinue As Boolean = True
+ Dim sFileToImport As String
+ Dim sBackupFile As String
+ Dim oBackup As clsBackup
+
+ For Each de As DictionaryEntry In hshImportList
+ sFileToImport = CStr(de.Key)
+ oGame = DirectCast(de.Value, clsGame)
+ If File.Exists(sFileToImport) Then
+
+ sBackupFile = oSettings.BackupFolder
+ If oSettings.CreateSubFolder Then
+ sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame)
+ bContinue = HandleSubFolder(oGame, sBackupFile)
+ End If
+
+ If bContinue Then
+ oBackup = New clsBackup
+ oBackup.MonitorID = oGame.ID
+ oBackup.DateUpdated = File.GetLastWriteTime(sFileToImport)
+ oBackup.UpdatedBy = mgrBackup_ImportedFile
+ sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame) & BuildFileTimeStamp(oBackup.DateUpdated) & ".7z"
+ oBackup.FileName = sBackupFile.Replace(Settings.BackupFolder & Path.DirectorySeparatorChar, String.Empty)
+ If mgrCommon.CopyFile(sFileToImport, sBackupFile, False) Then
+ oBackup.CheckSum = mgrHash.Generate_SHA256_Hash(sBackupFile)
+ mgrManifest.DoManifestAdd(oBackup, mgrSQLite.Database.Remote)
+ RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ImportSuccess, New String() {sFileToImport, oGame.Name}), False, ToolTipIcon.Error, True)
+ Else
+ RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorImportBackupCopy, sFileToImport), False, ToolTipIcon.Error, True)
+ End If
+ End If
+ End If
+ Next
+ End Sub
+
Public Sub DoBackup(ByVal oBackupList As List(Of clsGame))
Dim oGame As clsGame
Dim bDoBackup As Boolean
@@ -213,7 +267,7 @@ Public Class mgrBackup
sBackupFile = oSettings.BackupFolder
sSavePath = String.Empty
dTimeStamp = Date.Now
- sTimeStamp = " " & dTimeStamp.Month & "-" & dTimeStamp.Day & "-" & dTimeStamp.Year & "-" & dTimeStamp.Hour & "-" & dTimeStamp.Minute & "-" & dTimeStamp.Second
+ sTimeStamp = BuildFileTimeStamp(dTimeStamp)
sHash = String.Empty
bDoBackup = True
bBackupCompleted = False
@@ -222,14 +276,7 @@ Public Class mgrBackup
If oSettings.CreateSubFolder Then
sBackupFile = sBackupFile & Path.DirectorySeparatorChar & GetFileName(oGame)
- Try
- If Not Directory.Exists(sBackupFile) Then
- Directory.CreateDirectory(sBackupFile)
- End If
- Catch ex As Exception
- RaiseEvent UpdateLog(mgrCommon.FormatString(mgrBackup_ErrorSubFolderCreate, New String() {oGame.Name, ex.Message}), False, ToolTipIcon.Error, True)
- bDoBackup = False
- End Try
+ bDoBackup = HandleSubFolder(oGame, sBackupFile)
End If
If oGame.AppendTimeStamp Then
diff --git a/GBM/Managers/mgrCommon.vb b/GBM/Managers/mgrCommon.vb
index 74a533e..e49592d 100644
--- a/GBM/Managers/mgrCommon.vb
+++ b/GBM/Managers/mgrCommon.vb
@@ -144,9 +144,9 @@ Public Class mgrCommon
Return String.Empty
End Function
- Public Shared Function OpenFileBrowser(ByVal sName As String, ByVal sTitle As String, ByVal sExtension As String, ByVal sFileType As String, ByVal sDefaultFolder As String,
- ByVal bMulti As Boolean, Optional ByVal bSavedPath As Boolean = True) As String
- Dim fbBrowser As New OpenFileDialog
+ Private Shared Function BuildFileBrowser(ByVal sName As String, ByVal sTitle As String, ByVal sExtension As String, ByVal sFileType As String, ByVal sDefaultFolder As String,
+ ByVal bMulti As Boolean, ByRef fbBrowser As OpenFileDialog, Optional ByVal bSavedPath As Boolean = True) As Boolean
+
Dim oSavedPath As New clsSavedPath
fbBrowser.Title = sTitle
@@ -171,21 +171,40 @@ Public Class mgrCommon
mgrSavedPath.AddUpdatePath(oSavedPath)
End If
- If bMulti Then
- Dim sFileNames As String = String.Empty
- For Each sFileName As String In fbBrowser.FileNames
- sFileNames &= sFileName & "|"
- Next
- sFileNames = sFileNames.TrimEnd("|")
- Return sFileNames
- Else
- Return fbBrowser.FileName
- End If
+ Return True
+ End If
+
+ Return False
+ End Function
+
+ Public Shared Function OpenFileBrowser(ByVal sName As String, ByVal sTitle As String, ByVal sExtension As String, ByVal sFileType As String, ByVal sDefaultFolder As String,
+ Optional ByVal bSavedPath As Boolean = True) As String
+ Dim fbBrowser As New OpenFileDialog
+ Dim bResult As Boolean
+
+ bResult = BuildFileBrowser(sName, sTitle, sExtension, sFileType, sDefaultFolder, False, fbBrowser, bSavedPath)
+
+ If bResult Then
+ Return fbBrowser.FileName
End If
Return String.Empty
End Function
+ Public Shared Function OpenMultiFileBrowser(ByVal sName As String, ByVal sTitle As String, ByVal sExtension As String, ByVal sFileType As String, ByVal sDefaultFolder As String,
+ Optional ByVal bSavedPath As Boolean = True) As String()
+ Dim fbBrowser As New OpenFileDialog
+ Dim bResult As Boolean
+
+ bResult = BuildFileBrowser(sName, sTitle, sExtension, sFileType, sDefaultFolder, True, fbBrowser, bSavedPath)
+
+ If bResult Then
+ Return fbBrowser.FileNames
+ End If
+
+ Return New String() {}
+ End Function
+
Public Shared Function OpenFolderBrowser(ByVal sName As String, ByVal sTitle As String, ByVal sDefaultFolder As String, ByVal bEnableNewFolder As Boolean,
Optional ByVal bSavedPath As Boolean = True) As String
Dim fbBrowser As New FolderBrowserDialog
@@ -415,6 +434,21 @@ Public Class mgrCommon
End If
End Function
+ 'Copy a file
+ Public Shared Function CopyFile(ByVal sSourcePath As String, ByVal sDestinationPath As String, ByVal bOverWrite As Boolean) As Boolean
+ Try
+ If File.Exists(sSourcePath) Then
+ File.Copy(sSourcePath, sDestinationPath, bOverWrite)
+ Else
+ Return False
+ End If
+ Catch
+ Return False
+ End Try
+
+ Return True
+ End Function
+
'Delete file based on OS type
Public Shared Sub DeleteFile(ByVal sPath As String, Optional ByVal bRecycle As Boolean = True)
If File.Exists(sPath) Then
diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb
index 90b5240..3fa755c 100644
--- a/GBM/My Project/Resources.Designer.vb
+++ b/GBM/My Project/Resources.Designer.vb
@@ -1410,6 +1410,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to 7-Zip.
+ '''
+ Friend ReadOnly Property frmGameManager_7zBackup() As String
+ Get
+ Return ResourceManager.GetString("frmGameManager_7zBackup", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to [PARAM] ([PARAM]).
'''
@@ -1554,6 +1563,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to Import B&ackup Files.
+ '''
+ Friend ReadOnly Property frmGameManager_btnImportBackup() As String
+ Get
+ Return ResourceManager.GetString("frmGameManager_btnImportBackup", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to In&clude Items....
'''
@@ -1689,6 +1707,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to Choose compatible backup file(s).
+ '''
+ Friend ReadOnly Property frmGameManager_Choose7zImport() As String
+ Get
+ Return ResourceManager.GetString("frmGameManager_Choose7zImport", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to Choose a custom icon for the game.
'''
@@ -1824,6 +1851,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to Are you sure you want to import the selected file(s) for [PARAM]. This will close the form..
+ '''
+ Friend ReadOnly Property frmGameManager_ConfirmBackupImport() As String
+ Get
+ Return ResourceManager.GetString("frmGameManager_ConfirmBackupImport", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to Are you sure you want to delete [PARAM]? This cannot be undone.[BR][BR]This will not delete any backup files that already exist for this game..
'''
@@ -5727,6 +5763,15 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to Failed to import [PARAM], the file could not be copied..
+ '''
+ Friend ReadOnly Property mgrBackup_ErrorImportBackupCopy() As String
+ Get
+ Return ResourceManager.GetString("mgrBackup_ErrorImportBackupCopy", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to Backup aborted by user due to manifest conflict..
'''
@@ -5773,7 +5818,7 @@ Namespace My.Resources
End Property
'''
- ''' Looks up a localized string similar to Backup aborted. A failure occured while creating a backup sub-folder for [PARAM].[BR][PARAM].
+ ''' Looks up a localized string similar to A failure occured while creating a backup sub-folder for [PARAM].[BR][PARAM].
'''
Friend ReadOnly Property mgrBackup_ErrorSubFolderCreate() As String
Get
@@ -5790,6 +5835,24 @@ Namespace My.Resources
End Get
End Property
+ '''
+ ''' Looks up a localized string similar to Imported Backup.
+ '''
+ Friend ReadOnly Property mgrBackup_ImportedFile() As String
+ Get
+ Return ResourceManager.GetString("mgrBackup_ImportedFile", resourceCulture)
+ End Get
+ End Property
+
+ '''
+ ''' Looks up a localized string similar to Imported backup file [PARAM] for [PARAM]..
+ '''
+ Friend ReadOnly Property mgrBackup_ImportSuccess() As String
+ Get
+ Return ResourceManager.GetString("mgrBackup_ImportSuccess", resourceCulture)
+ End Get
+ End Property
+
'''
''' Looks up a localized string similar to Available Disk Space: [PARAM].
'''
diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx
index f3a1ed0..9eaed84 100644
--- a/GBM/My Project/Resources.resx
+++ b/GBM/My Project/Resources.resx
@@ -1307,7 +1307,7 @@
[PARAM] backup aborted by user due to overwrite.
- Backup aborted. A failure occured while creating a backup sub-folder for [PARAM].[BR][PARAM]
+ A failure occured while creating a backup sub-folder for [PARAM].[BR][PARAM]
Generating SHA-256 hash for [PARAM] backup file.
@@ -2224,4 +2224,25 @@
Show resolved save paths
+
+ 7-Zip
+
+
+ Import B&ackup Files
+
+
+ Choose compatible backup file(s)
+
+
+ Are you sure you want to import the selected file(s) for [PARAM]. This will close the form.
+
+
+ Failed to import [PARAM], the file could not be copied.
+
+
+ Imported Backup
+
+
+ Imported backup file [PARAM] for [PARAM].
+
\ No newline at end of file