From 77b5efbe025325504735d00fa7daceb50aa38ba5 Mon Sep 17 00:00:00 2001 From: "Michael J. Seiferling" Date: Tue, 23 Aug 2016 10:14:12 -0600 Subject: [PATCH] Manifest Re-write (Clean-up, Pass 3) --- GBM/Forms/frmAddWizard.Designer.vb | 57 +- GBM/Forms/frmAddWizard.vb | 33 +- GBM/Forms/frmGameManager.vb | 3 +- GBM/Managers/mgrManifest.vb | 2 + GBM/Managers/mgrMonitorList.vb | 783 +++++++++++++-------------- GBM/Managers/mgrTags.vb | 42 +- GBM/Managers/mgrVariables.vb | 47 +- GBM/My Project/Resources.Designer.vb | 17 +- GBM/My Project/Resources.resx | 11 +- 9 files changed, 520 insertions(+), 475 deletions(-) diff --git a/GBM/Forms/frmAddWizard.Designer.vb b/GBM/Forms/frmAddWizard.Designer.vb index 61affdd..e17bada 100644 --- a/GBM/Forms/frmAddWizard.Designer.vb +++ b/GBM/Forms/frmAddWizard.Designer.vb @@ -66,6 +66,8 @@ Partial Class frmAddWizard Me.btnCancel = New System.Windows.Forms.Button() Me.btnNext = New System.Windows.Forms.Button() Me.btnBack = New System.Windows.Forms.Button() + Me.lblLimit = New System.Windows.Forms.Label() + Me.nudLimit = New System.Windows.Forms.NumericUpDown() Me.tabWizard.SuspendLayout() Me.tbPage1.SuspendLayout() Me.tbPage2.SuspendLayout() @@ -73,6 +75,7 @@ Partial Class frmAddWizard Me.tbPage3a.SuspendLayout() Me.tbPage4.SuspendLayout() Me.tbPage5.SuspendLayout() + CType(Me.nudLimit, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'tabWizard @@ -121,8 +124,8 @@ Partial Class frmAddWizard Me.lblStep1Instructions.Name = "lblStep1Instructions" Me.lblStep1Instructions.Size = New System.Drawing.Size(303, 85) Me.lblStep1Instructions.TabIndex = 6 - Me.lblStep1Instructions.Text = "The name will be automatically filtered for length and invalid characters. You m" & _ - "ay drag and drop a shortcut here to complete this step, only Windows shortcuts a" & _ + Me.lblStep1Instructions.Text = "The name will be automatically filtered for length and invalid characters. You m" & + "ay drag and drop a shortcut here to complete this step, only Windows shortcuts a" & "re currently supported." ' 'txtName @@ -205,6 +208,8 @@ Partial Class frmAddWizard 'tbPage3 ' Me.tbPage3.BackColor = System.Drawing.SystemColors.Control + Me.tbPage3.Controls.Add(Me.lblLimit) + Me.tbPage3.Controls.Add(Me.nudLimit) Me.tbPage3.Controls.Add(Me.lblStep3Title) Me.tbPage3.Controls.Add(Me.lblStep3Instructions) Me.tbPage3.Controls.Add(Me.chkTimeStamp) @@ -230,32 +235,32 @@ Partial Class frmAddWizard ' 'lblStep3Instructions ' - Me.lblStep3Instructions.Location = New System.Drawing.Point(14, 116) + Me.lblStep3Instructions.Location = New System.Drawing.Point(14, 139) Me.lblStep3Instructions.Name = "lblStep3Instructions" Me.lblStep3Instructions.Size = New System.Drawing.Size(303, 42) Me.lblStep3Instructions.TabIndex = 9 - Me.lblStep3Instructions.Text = "If you're unsure of exactly which files to backup, make sure Save Entire Folder " & _ - "is checked. You can also time stamp your backup files to make incremental backu" & _ - "ps." + Me.lblStep3Instructions.Text = "If you're unsure of exactly which files to backup, make sure Save entire folder " & + "is checked. You can also choose to save multiple backups and set a limit on how" & + " many to keep." ' 'chkTimeStamp ' Me.chkTimeStamp.AutoSize = True - Me.chkTimeStamp.Location = New System.Drawing.Point(139, 87) + Me.chkTimeStamp.Location = New System.Drawing.Point(18, 108) Me.chkTimeStamp.Name = "chkTimeStamp" - Me.chkTimeStamp.Size = New System.Drawing.Size(122, 17) + Me.chkTimeStamp.Size = New System.Drawing.Size(133, 17) Me.chkTimeStamp.TabIndex = 8 - Me.chkTimeStamp.Text = "Time Stamp Backup" + Me.chkTimeStamp.Text = "Save multiple backups" Me.chkTimeStamp.UseVisualStyleBackColor = True ' 'chkFolderSave ' Me.chkFolderSave.AutoSize = True - Me.chkFolderSave.Location = New System.Drawing.Point(17, 87) + Me.chkFolderSave.Location = New System.Drawing.Point(18, 87) Me.chkFolderSave.Name = "chkFolderSave" - Me.chkFolderSave.Size = New System.Drawing.Size(113, 17) + Me.chkFolderSave.Size = New System.Drawing.Size(109, 17) Me.chkFolderSave.TabIndex = 7 - Me.chkFolderSave.Text = "Save Entire Folder" + Me.chkFolderSave.Text = "Save entire folder" Me.chkFolderSave.UseVisualStyleBackColor = True ' 'btnSaveBrowse @@ -352,7 +357,7 @@ Partial Class frmAddWizard Me.lblStep3aInstructions.Name = "lblStep3aInstructions" Me.lblStep3aInstructions.Size = New System.Drawing.Size(303, 56) Me.lblStep3aInstructions.TabIndex = 5 - Me.lblStep3aInstructions.Text = "Choose any file types, specific files or folders you wish to include in the back" & _ + Me.lblStep3aInstructions.Text = "Choose any file types, specific files or folders you wish to include in the back" & "up. If you're unsure, go back a step and choose to save the entire folder. " ' 'txtFileTypes @@ -434,7 +439,7 @@ Partial Class frmAddWizard Me.lblStep4Instructions.Name = "lblStep4Instructions" Me.lblStep4Instructions.Size = New System.Drawing.Size(303, 59) Me.lblStep4Instructions.TabIndex = 5 - Me.lblStep4Instructions.Text = "Choose any file types, specific files or folders you wish to exclude from the ba" & _ + Me.lblStep4Instructions.Text = "Choose any file types, specific files or folders you wish to exclude from the ba" & "ckup. You may choose multiple items to exclude. This step can be skipped." ' 'txtExcludeList @@ -516,6 +521,27 @@ Partial Class frmAddWizard Me.btnBack.Text = "&Back" Me.btnBack.UseVisualStyleBackColor = True ' + 'lblLimit + ' + Me.lblLimit.AutoSize = True + Me.lblLimit.Location = New System.Drawing.Point(203, 109) + Me.lblLimit.Name = "lblLimit" + Me.lblLimit.Size = New System.Drawing.Size(68, 13) + Me.lblLimit.TabIndex = 15 + Me.lblLimit.Text = "Backup Limit" + Me.lblLimit.Visible = False + ' + 'nudLimit + ' + Me.nudLimit.Location = New System.Drawing.Point(157, 107) + Me.nudLimit.Minimum = New Decimal(New Integer() {2, 0, 0, 0}) + Me.nudLimit.Name = "nudLimit" + Me.nudLimit.Size = New System.Drawing.Size(40, 20) + Me.nudLimit.TabIndex = 14 + Me.nudLimit.TextAlign = System.Windows.Forms.HorizontalAlignment.Right + Me.nudLimit.Value = New Decimal(New Integer() {2, 0, 0, 0}) + Me.nudLimit.Visible = False + ' 'frmAddWizard ' Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) @@ -545,6 +571,7 @@ Partial Class frmAddWizard Me.tbPage4.PerformLayout() Me.tbPage5.ResumeLayout(False) Me.tbPage5.PerformLayout() + CType(Me.nudLimit, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub @@ -591,4 +618,6 @@ Partial Class frmAddWizard Friend WithEvents lblExcludePath As Label Friend WithEvents lblIncludePathTitle As Label Friend WithEvents lblExcludePathTitle As Label + Friend WithEvents lblLimit As Label + Friend WithEvents nudLimit As NumericUpDown End Class diff --git a/GBM/Forms/frmAddWizard.vb b/GBM/Forms/frmAddWizard.vb index a0ae70d..3cd6c95 100644 --- a/GBM/Forms/frmAddWizard.vb +++ b/GBM/Forms/frmAddWizard.vb @@ -46,6 +46,7 @@ Public Class frmAddWizard lblStep3Instructions.Text = frmAddWizard_lblStep3Instructions chkTimeStamp.Text = frmAddWizard_chkTimeStamp chkFolderSave.Text = frmAddWizard_chkFolderSave + lblLimit.Text = frmAddWizard_lblLimit btnSaveBrowse.Text = frmAddWizard_btnSaveBrowse lblStep3Intro.Text = frmAddWizard_lblStep3Intro lblIncludePathTitle.Text = frmAddWizard_lblIncludePathTitle @@ -68,6 +69,28 @@ Public Class frmAddWizard StepHandler() End Sub + Private Sub ShowHideLimit() + If chkTimeStamp.Checked Then + nudLimit.Visible = True + lblLimit.Visible = True + nudLimit.Value = 5 + Else + nudLimit.Visible = False + nudLimit.Value = nudLimit.Minimum + lblLimit.Visible = False + End If + End Sub + + Private Function ShowSummaryLimit(ByVal bTimeStamp As Boolean, ByVal iLimit As Integer) As String + Dim sLimit As String = String.Empty + + If bTimeStamp Then + Return mgrCommon.BooleanYesNo(bTimeStamp) & " (" & iLimit & ")" + Else + Return mgrCommon.BooleanYesNo(bTimeStamp) + End If + End Function + Private Function StringEmptyText(ByVal sString As String) As String If sString = String.Empty Then Return frmAddWizard_None @@ -86,6 +109,7 @@ Public Class frmAddWizard Dim bIsAbsolute As Boolean = mgrPath.IsAbsolute(sSavePath) Dim bFolderBackup As Boolean = chkFolderSave.Checked Dim bTimeStamp As Boolean = chkTimeStamp.Checked + Dim iLimit As Integer = nudLimit.Value Dim sFileType As String = txtFileTypes.Text Dim sExcludeList As String = txtExcludeList.Text Dim sProcess As String @@ -117,7 +141,7 @@ Public Class frmAddWizard lstSummary.Columns(1).Width = 210 sItems = {frmAddWizard_Summary_Name, frmAddWizard_Summary_Process, frmAddWizard_Summary_AbsolutePath, frmAddWizard_Summary_SavePath, frmAddWizard_Summary_FolderSave, frmAddWizard_Summary_Timestamp, frmAddWizard_Summary_Include, frmAddWizard_Summary_Exclude} - sValues = {sName, sProcessSummaryText, mgrCommon.BooleanYesNo(bIsAbsolute), sSavePath, mgrCommon.BooleanYesNo(bFolderBackup), mgrCommon.BooleanYesNo(bTimeStamp), StringEmptyText(sFileType), StringEmptyText(sExcludeList)} + sValues = {sName, sProcessSummaryText, mgrCommon.BooleanYesNo(bIsAbsolute), sSavePath, mgrCommon.BooleanYesNo(bFolderBackup), ShowSummaryLimit(bTimeStamp, iLimit), StringEmptyText(sFileType), StringEmptyText(sExcludeList)} For i = 0 To sItems.Length - 1 sItem = {sItems(i), sValues(i)} @@ -133,6 +157,7 @@ Public Class frmAddWizard oGame.FolderSave = bFolderBackup oGame.FileType = sFileType oGame.AppendTimeStamp = bTimeStamp + oGame.BackupLimit = iLimit oGame.ExcludeList = sExcludeList Return oGame @@ -501,6 +526,10 @@ Public Class frmAddWizard txtFileTypes.Clear() End Sub + Private Sub chkTimeStamp_CheckedChanged(sender As Object, e As EventArgs) Handles chkTimeStamp.CheckedChanged + ShowHideLimit() + End Sub + Private Sub btnInclude_Click(sender As Object, e As EventArgs) Handles btnInclude.Click OpenBuilder(frmAddWizard_Include, txtFileTypes) UpdateBuilderLabel(txtFileTypes.Text, lblFileTypes) @@ -510,4 +539,6 @@ Public Class frmAddWizard OpenBuilder(frmAddWizard_Exclude, txtExcludeList) UpdateBuilderLabel(txtExcludeList.Text, lblExclude) End Sub + + End Class \ No newline at end of file diff --git a/GBM/Forms/frmGameManager.vb b/GBM/Forms/frmGameManager.vb index 667bdee..d3c4aa4 100644 --- a/GBM/Forms/frmGameManager.vb +++ b/GBM/Forms/frmGameManager.vb @@ -171,7 +171,7 @@ Public Class frmGameManager 'Local If mgrManifest.DoManifestNameCheck(oOriginalApp.Name, mgrSQLite.Database.Local) Then oBackupItems = mgrManifest.DoManifestGetByName(oOriginalApp.Name, mgrSQLite.Database.Local) - + 'The local manifest will only have one entry per game, therefore this runs only once For Each oBackupItem As clsBackup In oBackupItems 'Rename Current Backup File & Folder sFileName = BackupFolder & oBackupItem.FileName @@ -1013,6 +1013,7 @@ Public Class frmGameManager If chkTimeStamp.Checked Then nudLimit.Visible = True lblLimit.Visible = True + nudLimit.Value = 5 Else nudLimit.Visible = False nudLimit.Value = nudLimit.Minimum diff --git a/GBM/Managers/mgrManifest.vb b/GBM/Managers/mgrManifest.vb index 4952af5..f9d182c 100644 --- a/GBM/Managers/mgrManifest.vb +++ b/GBM/Managers/mgrManifest.vb @@ -115,6 +115,7 @@ Return oBackupItem End Function + 'This should only be used to update specific entries in the remote manifest Public Shared Function DoSpecificManifestCheck(ByRef oItem As clsBackup, ByVal iSelectDB As mgrSQLite.Database) As Boolean Dim oDatabase As New mgrSQLite(iSelectDB) Dim oData As DataSet @@ -140,6 +141,7 @@ End Function + 'This should only be used to update entries in the local manifest Public Shared Function DoGlobalManifestCheck(ByVal sName As String, ByVal iSelectDB As mgrSQLite.Database) As Boolean Dim oDatabase As New mgrSQLite(iSelectDB) Dim oData As DataSet diff --git a/GBM/Managers/mgrMonitorList.vb b/GBM/Managers/mgrMonitorList.vb index a4c5633..8bfcaa9 100644 --- a/GBM/Managers/mgrMonitorList.vb +++ b/GBM/Managers/mgrMonitorList.vb @@ -10,57 +10,261 @@ Public Class mgrMonitorList Public Shared Event UpdateLog(sLogUpdate As String, bTrayUpdate As Boolean, objIcon As System.Windows.Forms.ToolTipIcon, bTimeStamp As Boolean) - Public Shared Sub HandleBackupLocationChange(ByVal oSettings As mgrSettings) - Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Remote) - Dim iGameCount As Integer + Private Shared Function MapToObject(ByVal dr As DataRow) As clsGame + Dim oGame As New clsGame - 'Check if a remote database already exists in the new backup location - If oDatabase.CheckDB() Then - 'Make sure database is the latest version - oDatabase.DatabaseUpgrade() + oGame.ID = CStr(dr("MonitorID")) + oGame.Name = CStr(dr("Name")) + oGame.ProcessName = CStr(dr("Process")) + If Not IsDBNull(dr("Path")) Then oGame.Path = CStr(dr("Path")) + oGame.AbsolutePath = CBool(dr("AbsolutePath")) + oGame.FolderSave = CBool(dr("FolderSave")) + If Not IsDBNull(dr("FileType")) Then oGame.FileType = CStr(dr("FileType")) + oGame.AppendTimeStamp = CBool(dr("TimeStamp")) + If Not IsDBNull(dr("ExcludeList")) Then oGame.ExcludeList = CStr(dr("ExcludeList")) + If Not IsDBNull(dr("ProcessPath")) Then oGame.ProcessPath = CStr(dr("ProcessPath")) + If Not IsDBNull(dr("Icon")) Then oGame.Icon = CStr(dr("Icon")) + oGame.Hours = CDbl(dr("Hours")) + If Not IsDBNull(dr("Version")) Then oGame.Version = CStr(dr("Version")) + If Not IsDBNull(dr("Company")) Then oGame.Company = CStr(dr("Company")) + oGame.Enabled = CBool(dr("Enabled")) + oGame.MonitorOnly = CBool(dr("MonitorOnly")) + oGame.BackupLimit = CInt(dr("BackupLimit")) - 'See if the remote database is empty - iGameCount = mgrMonitorList.ReadList(eListTypes.FullList, mgrSQLite.Database.Remote).Count + Return oGame + End Function - 'If the remote database actually contains a list, then ask what to do - If iGameCount > 0 Then - If mgrCommon.ShowMessage(mgrMonitorList_ConfirmExistingData, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) - Else - mgrMonitorList.SyncMonitorLists(oSettings.SyncFields, False) - End If - Else - mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) - End If + Private Shared Function SetCoreParameters(ByVal oGame As clsGame) As Hashtable + Dim hshParams As New Hashtable + + hshParams.Add("ID", oGame.ID) + hshParams.Add("Name", oGame.Name) + hshParams.Add("Process", oGame.TrueProcess) + hshParams.Add("Path", oGame.TruePath) + hshParams.Add("AbsolutePath", oGame.AbsolutePath) + hshParams.Add("FolderSave", oGame.FolderSave) + hshParams.Add("FileType", oGame.FileType) + hshParams.Add("TimeStamp", oGame.AppendTimeStamp) + hshParams.Add("ExcludeList", oGame.ExcludeList) + hshParams.Add("ProcessPath", oGame.ProcessPath) + hshParams.Add("Icon", oGame.Icon) + hshParams.Add("Hours", oGame.Hours) + hshParams.Add("Version", oGame.Version) + hshParams.Add("Company", oGame.Company) + hshParams.Add("Enabled", oGame.Enabled) + hshParams.Add("MonitorOnly", oGame.MonitorOnly) + hshParams.Add("BackupLimit", oGame.BackupLimit) + + Return hshParams + End Function + + Public Shared Function ReadList(ByVal eListType As eListTypes, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As Hashtable + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim oData As DataSet + Dim sSQL As String + Dim hshList As New Hashtable + Dim hshDupeList As New Hashtable + Dim oGame As clsGame + + sSQL = "Select * from monitorlist ORDER BY Name Asc" + oData = oDatabase.ReadParamData(sSQL, New Hashtable) + + For Each dr As DataRow In oData.Tables(0).Rows + oGame = MapToObject(dr) + Select Case eListType + Case eListTypes.FullList + 'Don't wrap this, if it fails there's a problem with the database + hshList.Add(oGame.ProcessName & ":" & oGame.Name, oGame) + Case eListTypes.ScanList + If hshList.Contains(oGame.ProcessName) Then + DirectCast(hshList.Item(oGame.ProcessName), clsGame).Duplicate = True + oGame.ProcessName = oGame.ProcessName & ":" & oGame.Name + oGame.Duplicate = True + End If + If oGame.Enabled Then hshList.Add(oGame.ProcessName, oGame) + End Select + Next + + Return hshList + End Function + + Public Shared Sub DoListAdd(ByVal oGame As clsGame, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As Hashtable + + sSQL = "INSERT INTO monitorlist VALUES (@ID, @Name, @Process, @Path, @AbsolutePath, @FolderSave, @FileType, @TimeStamp, " + sSQL &= "@ExcludeList, @ProcessPath, @Icon, @Hours, @Version, @Company, @Enabled, @MonitorOnly, @BackupLimit)" + + 'Parameters + hshParams = SetCoreParameters(oGame) + + oDatabase.RunParamQuery(sSQL, hshParams) + + End Sub + + Public Shared Sub DoListUpdate(ByVal oGame As clsGame, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As Hashtable + + sSQL = "UPDATE monitorlist SET Name=@Name, Process=@Process, Path=@Path, AbsolutePath=@AbsolutePath, FolderSave=@FolderSave, " + sSQL &= "FileType=@FileType, TimeStamp=@TimeStamp, ExcludeList=@ExcludeList, ProcessPath=@ProcessPath, Icon=@Icon, " + sSQL &= "Hours=@Hours, Version=@Version, Company=@Company, Enabled=@Enabled, MonitorOnly=@MonitorOnly, BackupLimit=@BackupLimit WHERE MonitorID=@ID" + + 'Parameters + hshParams = SetCoreParameters(oGame) + + oDatabase.RunParamQuery(sSQL, hshParams) + + 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) + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + Dim iCounter As Integer + + sSQL = "UPDATE monitorlist SET Enabled=@Enabled, MonitorOnly=@MonitorOnly WHERE MonitorID IN (" + + 'Parameters + hshParams.Add("Enabled", oGame.Enabled) + hshParams.Add("MonitorOnly", oGame.MonitorOnly) + + For Each s As String In sMonitorIDs + sSQL &= "@MonitorID" & iCounter & "," + hshParams.Add("MonitorID" & iCounter, s) + iCounter += 1 + Next + + sSQL = sSQL.TrimEnd(",") + sSQL &= ")" + + oDatabase.RunParamQuery(sSQL, hshParams) + + End Sub + + Public Shared Sub DoListDelete(ByVal sMonitorID As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + + sSQL = "DELETE FROM gametags " + sSQL &= "WHERE MonitorID = @MonitorID;" + sSQL &= "DELETE FROM monitorlist " + sSQL &= "WHERE MonitorID = @MonitorID;" + + hshParams.Add("MonitorID", sMonitorID) + + oDatabase.RunParamQuery(sSQL, hshParams) + + End Sub + + Public Shared Sub DoListDeleteMulti(ByVal sMonitorIDs As List(Of String), Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim hshParams As New Hashtable + Dim iCounter As Integer + + sSQL = "DELETE FROM gametags " + 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 &= ");" + + sSQL &= "DELETE FROM monitorlist " + 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 &= ");" + + oDatabase.RunParamQuery(sSQL, hshParams) + End Sub + + Public Shared Function DoListGetbyID(ByVal iMonitorID As Integer, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As clsGame + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim oData As DataSet + Dim oGame As New clsGame + Dim hshParams As New Hashtable + + sSQL = "SELECT * from monitorlist " + sSQL &= "WHERE MonitorID = @MonitorID" + + hshParams.Add("MonitorID", iMonitorID) + + oData = oDatabase.ReadParamData(sSQL, hshParams) + + For Each dr As DataRow In oData.Tables(0).Rows + oGame = MapToObject(dr) + Next + + Return oGame + End Function + + Public Shared Function DoListGetbyName(ByVal sName As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As Hashtable + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim oData As DataSet + Dim oGame As New clsGame + Dim hshGames As New Hashtable + Dim hshParams As New Hashtable + Dim iCounter As Integer = 0 + + sSQL = "SELECT * from monitorlist " + sSQL &= "WHERE Name = @Name" + + hshParams.Add("Name", sName) + + oData = oDatabase.ReadParamData(sSQL, hshParams) + + For Each dr As DataRow In oData.Tables(0).Rows + oGame = MapToObject(dr) + hshGames.Add(iCounter, oGame) + iCounter += 1 + Next + + Return hshGames + End Function + + Public Shared Function DoDuplicateListCheck(ByVal sName As String, ByVal sProcess As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local, Optional ByVal sExcludeID As String = "") As Boolean + Dim oDatabase As New mgrSQLite(iSelectDB) + Dim sSQL As String + Dim oData As DataSet + Dim hshParams As New Hashtable + + sSQL = "SELECT * FROM monitorlist WHERE Name = @Name AND Process= @Process" + + hshParams.Add("Name", sName) + hshParams.Add("Process", sProcess) + + If sExcludeID <> String.Empty Then + sSQL &= " AND MonitorID <> @MonitorID" + hshParams.Add("MonitorID", sExcludeID) + End If + + oData = oDatabase.ReadParamData(sSQL, hshParams) + + If oData.Tables(0).Rows.Count > 0 Then + Return True Else - mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) + Return False End If - End Sub - - Public Shared Sub ExportMonitorList(ByVal sLocation As String) - Dim oList As List(Of Game) - Dim bSuccess As Boolean = False - Dim oTagFilters As New List(Of clsTag) - Dim oStringFilters As New Hashtable - Dim eCurrentFilter As frmFilter.eFilterType = frmFilter.eFilterType.NoFilter - - If mgrCommon.ShowMessage(mgrMonitorList_ConfirmApplyFilter, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then - Dim frm As New frmFilter - frm.ShowDialog() - oTagFilters = frm.TagFilters - oStringFilters = frm.StringFilters - eCurrentFilter = frm.FilterType - End If - - oList = ReadListForExport(oTagFilters, oStringFilters, eCurrentFilter) - - bSuccess = mgrXML.SerializeAndExport(oList, sLocation) - - If bSuccess Then - mgrCommon.ShowMessage(mgrMonitorList_ExportComplete, oList.Count, MsgBoxStyle.Information) - End If - End Sub + End Function + 'Sync Functions Public Shared Sub DoListAddUpdateSync(ByVal hshGames As Hashtable, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local, Optional ByVal eSyncFields As clsGame.eOptionalSyncFields = clsGame.eOptionalSyncFields.None) Dim oDatabase As New mgrSQLite(iSelectDB) @@ -260,73 +464,7 @@ Public Class mgrMonitorList Application.DoEvents() End Sub - Private Shared Sub ImportMonitorList(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) - Dim hshCompareFrom As Hashtable - Dim hshCompareTo As Hashtable - Dim hshSyncItems As Hashtable - Dim oFromItem As clsGame - Dim oToItem As clsGame - - Cursor.Current = Cursors.WaitCursor - - 'Add / Update Sync - hshCompareFrom = mgrXML.ReadMonitorList(sLocation, bWebRead) - hshCompareTo = ReadList(eListTypes.FullList, mgrSQLite.Database.Local) - - hshSyncItems = hshCompareFrom.Clone - - For Each oFromItem In hshCompareFrom.Values - If hshCompareTo.Contains(oFromItem.CompoundKey) Then - oToItem = DirectCast(hshCompareTo(oFromItem.CompoundKey), clsGame) - If oFromItem.CoreEquals(oToItem) Then - hshSyncItems.Remove(oFromItem.CompoundKey) - End If - End If - Next - - Cursor.Current = Cursors.Default - - If hshSyncItems.Count > 0 Then - Dim frm As New frmAdvancedImport - frm.ImportData = hshSyncItems - If frm.ShowDialog() = DialogResult.OK Then - Cursor.Current = Cursors.WaitCursor - - DoListAddUpdateSync(frm.FinalData) - mgrTags.DoTagAddImport(frm.FinalData) - - Cursor.Current = Cursors.Default - mgrCommon.ShowMessage(mgrMonitorList_ImportComplete, MsgBoxStyle.Information) - End If - Else - mgrCommon.ShowMessage(mgrMonitorList_ImportNothing, MsgBoxStyle.Information) - End If - - Application.DoEvents() - End Sub - - Public Shared Function DoImport(ByVal sPath As String) As Boolean - If (sPath.IndexOf("http://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Or _ - (sPath.IndexOf("https://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Then - If mgrCommon.CheckAddress(sPath) Then - ImportMonitorList(sPath, True) - Return True - Else - mgrCommon.ShowMessage(mgrMonitorList_WebNoReponse, sPath, MsgBoxStyle.Exclamation) - Return False - End If - Else - If File.Exists(sPath) Then - ImportMonitorList(sPath) - Return True - Else - mgrCommon.ShowMessage(mgrMonitorList_FileNotFound, sPath, MsgBoxStyle.Exclamation) - Return False - End If - End If - Return True - End Function - + 'Filter Functions Private Shared Function BuildFilterQuery(ByVal oTagFilters As List(Of clsTag), ByVal hshStringFilters As Hashtable, eFilterType As frmFilter.eFilterType, ByRef hshParams As Hashtable) As String Dim sSQL As String = String.Empty Dim iCounter As Integer = 0 @@ -403,24 +541,7 @@ Public Class mgrMonitorList oData = oDatabase.ReadParamData(sSQL, hshParams) For Each dr As DataRow In oData.Tables(0).Rows - oGame = New clsGame - oGame.ID = CStr(dr("MonitorID")) - oGame.Name = CStr(dr("Name")) - oGame.ProcessName = CStr(dr("Process")) - If Not IsDBNull(dr("Path")) Then oGame.Path = CStr(dr("Path")) - oGame.AbsolutePath = CBool(dr("AbsolutePath")) - oGame.FolderSave = CBool(dr("FolderSave")) - If Not IsDBNull(dr("FileType")) Then oGame.FileType = CStr(dr("FileType")) - oGame.AppendTimeStamp = CBool(dr("TimeStamp")) - If Not IsDBNull(dr("ExcludeList")) Then oGame.ExcludeList = CStr(dr("ExcludeList")) - If Not IsDBNull(dr("ProcessPath")) Then oGame.ProcessPath = CStr(dr("ProcessPath")) - If Not IsDBNull(dr("Icon")) Then oGame.Icon = CStr(dr("Icon")) - oGame.Hours = CDbl(dr("Hours")) - If Not IsDBNull(dr("Version")) Then oGame.Version = CStr(dr("Version")) - If Not IsDBNull(dr("Company")) Then oGame.Company = CStr(dr("Company")) - oGame.Enabled = CBool(dr("Enabled")) - oGame.MonitorOnly = CBool(dr("MonitorOnly")) - oGame.BackupLimit = CInt(dr("BackupLimit")) + oGame = MapToObject(dr) hshList.Add(oGame.ID, oGame) Next @@ -428,6 +549,8 @@ Public Class mgrMonitorList Return hshList End Function + + 'Import / Export Functions Public Shared Function ReadListForExport(ByVal oTagFilters As List(Of clsTag), ByVal hshStringFilters As Hashtable, ByVal eFilterType As frmFilter.eFilterType, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As List(Of Game) Dim oDatabase As New mgrSQLite(iSelectDB) Dim oData As DataSet @@ -458,294 +581,122 @@ Public Class mgrMonitorList Return oList End Function - Public Shared Function ReadList(ByVal eListType As eListTypes, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As Hashtable - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim oData As DataSet - Dim sSQL As String - Dim hshList As New Hashtable - Dim hshDupeList As New Hashtable - Dim oGame As clsGame - - sSQL = "Select * from monitorlist ORDER BY Name Asc" - oData = oDatabase.ReadParamData(sSQL, New Hashtable) - - For Each dr As DataRow In oData.Tables(0).Rows - oGame = New clsGame - oGame.ID = CStr(dr("MonitorID")) - oGame.Name = CStr(dr("Name")) - oGame.ProcessName = CStr(dr("Process")) - If Not IsDBNull(dr("Path")) Then oGame.Path = CStr(dr("Path")) - oGame.AbsolutePath = CBool(dr("AbsolutePath")) - oGame.FolderSave = CBool(dr("FolderSave")) - If Not IsDBNull(dr("FileType")) Then oGame.FileType = CStr(dr("FileType")) - oGame.AppendTimeStamp = CBool(dr("TimeStamp")) - If Not IsDBNull(dr("ExcludeList")) Then oGame.ExcludeList = CStr(dr("ExcludeList")) - If Not IsDBNull(dr("ProcessPath")) Then oGame.ProcessPath = CStr(dr("ProcessPath")) - If Not IsDBNull(dr("Icon")) Then oGame.Icon = CStr(dr("Icon")) - oGame.Hours = CDbl(dr("Hours")) - If Not IsDBNull(dr("Version")) Then oGame.Version = CStr(dr("Version")) - If Not IsDBNull(dr("Company")) Then oGame.Company = CStr(dr("Company")) - oGame.Enabled = CBool(dr("Enabled")) - oGame.MonitorOnly = CBool(dr("MonitorOnly")) - oGame.BackupLimit = CInt(dr("BackupLimit")) - - Select Case eListType - Case eListTypes.FullList - 'Don't wrap this, if it fails there's a problem with the database - hshList.Add(oGame.ProcessName & ":" & oGame.Name, oGame) - Case eListTypes.ScanList - If hshList.Contains(oGame.ProcessName) Then - DirectCast(hshList.Item(oGame.ProcessName), clsGame).Duplicate = True - oGame.ProcessName = oGame.ProcessName & ":" & oGame.Name - oGame.Duplicate = True - End If - If oGame.Enabled Then hshList.Add(oGame.ProcessName, oGame) - End Select - Next - - Return hshList - End Function - - Public Shared Sub DoListAdd(ByVal oGame As clsGame, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim sSQL As String - Dim hshParams As New Hashtable - - sSQL = "INSERT INTO monitorlist VALUES (@ID, @Name, @Process, @Path, @AbsolutePath, @FolderSave, @FileType, @TimeStamp, " - sSQL &= "@ExcludeList, @ProcessPath, @Icon, @Hours, @Version, @Company, @Enabled, @MonitorOnly, @BackupLimit)" - - 'Parameters - hshParams.Add("ID", oGame.ID) - hshParams.Add("Name", oGame.Name) - hshParams.Add("Process", oGame.TrueProcess) - hshParams.Add("Path", oGame.TruePath) - hshParams.Add("AbsolutePath", oGame.AbsolutePath) - hshParams.Add("FolderSave", oGame.FolderSave) - hshParams.Add("FileType", oGame.FileType) - hshParams.Add("TimeStamp", oGame.AppendTimeStamp) - hshParams.Add("ExcludeList", oGame.ExcludeList) - hshParams.Add("ProcessPath", oGame.ProcessPath) - hshParams.Add("Icon", oGame.Icon) - hshParams.Add("Hours", oGame.Hours) - hshParams.Add("Version", oGame.Version) - hshParams.Add("Company", oGame.Company) - hshParams.Add("Enabled", oGame.Enabled) - hshParams.Add("MonitorOnly", oGame.MonitorOnly) - hshParams.Add("BackupLimit", oGame.BackupLimit) - - oDatabase.RunParamQuery(sSQL, hshParams) - - End Sub - - Public Shared Sub DoListUpdate(ByVal oGame As clsGame, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim sSQL As String - Dim hshParams As New Hashtable - - sSQL = "UPDATE monitorlist SET Name=@Name, Process=@Process, Path=@Path, AbsolutePath=@AbsolutePath, FolderSave=@FolderSave, " - sSQL &= "FileType=@FileType, TimeStamp=@TimeStamp, ExcludeList=@ExcludeList, ProcessPath=@ProcessPath, Icon=@Icon, " - sSQL &= "Hours=@Hours, Version=@Version, Company=@Company, Enabled=@Enabled, MonitorOnly=@MonitorOnly, BackupLimit=@BackupLimit WHERE MonitorID=@ID" - - 'Parameters - hshParams.Add("Name", oGame.Name) - hshParams.Add("Process", oGame.TrueProcess) - hshParams.Add("Path", oGame.TruePath) - hshParams.Add("AbsolutePath", oGame.AbsolutePath) - hshParams.Add("FolderSave", oGame.FolderSave) - hshParams.Add("FileType", oGame.FileType) - hshParams.Add("TimeStamp", oGame.AppendTimeStamp) - hshParams.Add("ExcludeList", oGame.ExcludeList) - hshParams.Add("ProcessPath", oGame.ProcessPath) - hshParams.Add("Icon", oGame.Icon) - hshParams.Add("Hours", oGame.Hours) - hshParams.Add("Version", oGame.Version) - hshParams.Add("Company", oGame.Company) - hshParams.Add("Enabled", oGame.Enabled) - hshParams.Add("MonitorOnly", oGame.MonitorOnly) - hshParams.Add("ID", oGame.ID) - hshParams.Add("BackupLimit", oGame.BackupLimit) - - oDatabase.RunParamQuery(sSQL, hshParams) - - 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) - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim sSQL As String - Dim hshParams As New Hashtable - Dim iCounter As Integer - - sSQL = "UPDATE monitorlist SET Enabled=@Enabled, MonitorOnly=@MonitorOnly WHERE MonitorID IN (" - - 'Parameters - hshParams.Add("Enabled", oGame.Enabled) - hshParams.Add("MonitorOnly", oGame.MonitorOnly) - - For Each s As String In sMonitorIDs - sSQL &= "@MonitorID" & iCounter & "," - hshParams.Add("MonitorID" & iCounter, s) - iCounter += 1 - Next - - sSQL = sSQL.TrimEnd(",") - sSQL &= ")" - - oDatabase.RunParamQuery(sSQL, hshParams) - - End Sub - - Public Shared Sub DoListDelete(ByVal sMonitorID As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim sSQL As String - Dim hshParams As New Hashtable - - sSQL = "DELETE FROM gametags " - sSQL &= "WHERE MonitorID = @MonitorID;" - sSQL &= "DELETE FROM monitorlist " - sSQL &= "WHERE MonitorID = @MonitorID;" - - hshParams.Add("MonitorID", sMonitorID) - - oDatabase.RunParamQuery(sSQL, hshParams) - - End Sub - - Public Shared Sub DoListDeleteMulti(ByVal sMonitorIDs As List(Of String), Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim sSQL As String - Dim hshParams As New Hashtable - Dim iCounter As Integer - - sSQL = "DELETE FROM gametags " - 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 &= ");" - - sSQL &= "DELETE FROM monitorlist " - 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 &= ");" - - oDatabase.RunParamQuery(sSQL, hshParams) - End Sub - - Public Shared Function DoListGetbyID(ByVal iMonitorID As Integer, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As clsGame - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim sSQL As String - Dim oData As DataSet - Dim oGame As New clsGame - Dim hshParams As New Hashtable - - sSQL = "SELECT * from monitorlist " - sSQL &= "WHERE MonitorID = @MonitorID" - - hshParams.Add("MonitorID", iMonitorID) - - oData = oDatabase.ReadParamData(sSQL, hshParams) - - For Each dr As DataRow In oData.Tables(0).Rows - oGame = New clsGame - oGame.ID = CStr(dr("MonitorID")) - oGame.Name = CStr(dr("Name")) - oGame.ProcessName = CStr(dr("Process")) - If Not IsDBNull(dr("Path")) Then oGame.Path = CStr(dr("Path")) - oGame.AbsolutePath = CBool(dr("AbsolutePath")) - oGame.FolderSave = CBool(dr("FolderSave")) - If Not IsDBNull(dr("FileType")) Then oGame.FileType = CStr(dr("FileType")) - oGame.AppendTimeStamp = CBool(dr("TimeStamp")) - If Not IsDBNull(dr("ExcludeList")) Then oGame.ExcludeList = CStr(dr("ExcludeList")) - If Not IsDBNull(dr("ProcessPath")) Then oGame.ProcessPath = CStr(dr("ProcessPath")) - If Not IsDBNull(dr("Icon")) Then oGame.Icon = CStr(dr("Icon")) - oGame.Hours = CDbl(dr("Hours")) - If Not IsDBNull(dr("Version")) Then oGame.Version = CStr(dr("Version")) - If Not IsDBNull(dr("Company")) Then oGame.Company = CStr(dr("Company")) - oGame.Enabled = CBool(dr("Enabled")) - oGame.MonitorOnly = CBool(dr("MonitorOnly")) - oGame.BackupLimit = CInt(dr("BackupLimit")) - Next - - Return oGame - End Function - - Public Shared Function DoListGetbyName(ByVal sName As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) As Hashtable - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim sSQL As String - Dim oData As DataSet - Dim oGame As New clsGame - Dim hshGames As New Hashtable - Dim hshParams As New Hashtable - Dim iCounter As Integer = 0 - - sSQL = "SELECT * from monitorlist " - sSQL &= "WHERE Name = @Name" - - hshParams.Add("Name", sName) - - oData = oDatabase.ReadParamData(sSQL, hshParams) - - For Each dr As DataRow In oData.Tables(0).Rows - oGame = New clsGame - oGame.ID = CStr(dr("MonitorID")) - oGame.Name = CStr(dr("Name")) - oGame.ProcessName = CStr(dr("Process")) - If Not IsDBNull(dr("Path")) Then oGame.Path = CStr(dr("Path")) - oGame.AbsolutePath = CBool(dr("AbsolutePath")) - oGame.FolderSave = CBool(dr("FolderSave")) - If Not IsDBNull(dr("FileType")) Then oGame.FileType = CStr(dr("FileType")) - oGame.AppendTimeStamp = CBool(dr("TimeStamp")) - If Not IsDBNull(dr("ExcludeList")) Then oGame.ExcludeList = CStr(dr("ExcludeList")) - If Not IsDBNull(dr("ProcessPath")) Then oGame.ProcessPath = CStr(dr("ProcessPath")) - If Not IsDBNull(dr("Icon")) Then oGame.Icon = CStr(dr("Icon")) - oGame.Hours = CDbl(dr("Hours")) - If Not IsDBNull(dr("Version")) Then oGame.Version = CStr(dr("Version")) - If Not IsDBNull(dr("Company")) Then oGame.Company = CStr(dr("Company")) - oGame.Enabled = CBool(dr("Enabled")) - oGame.MonitorOnly = CBool(dr("MonitorOnly")) - oGame.BackupLimit = CInt(dr("BackupLimit")) - hshGames.Add(iCounter, oGame) - iCounter += 1 - Next - - Return hshGames - End Function - - Public Shared Function DoDuplicateListCheck(ByVal sName As String, ByVal sProcess As String, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local, Optional ByVal sExcludeID As String = "") As Boolean - Dim oDatabase As New mgrSQLite(iSelectDB) - Dim sSQL As String - Dim oData As DataSet - Dim hshParams As New Hashtable - - sSQL = "SELECT * FROM monitorlist WHERE Name = @Name AND Process= @Process" - - hshParams.Add("Name", sName) - hshParams.Add("Process", sProcess) - - If sExcludeID <> String.Empty Then - sSQL &= " AND MonitorID <> @MonitorID" - hshParams.Add("MonitorID", sExcludeID) - End If - - oData = oDatabase.ReadParamData(sSQL, hshParams) - - If oData.Tables(0).Rows.Count > 0 Then - Return True + Public Shared Function DoImport(ByVal sPath As String) As Boolean + If (sPath.IndexOf("http://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Or + (sPath.IndexOf("https://", 0, StringComparison.CurrentCultureIgnoreCase) > -1) Then + If mgrCommon.CheckAddress(sPath) Then + ImportMonitorList(sPath, True) + Return True + Else + mgrCommon.ShowMessage(mgrMonitorList_WebNoReponse, sPath, MsgBoxStyle.Exclamation) + Return False + End If Else - Return False + If File.Exists(sPath) Then + ImportMonitorList(sPath) + Return True + Else + mgrCommon.ShowMessage(mgrMonitorList_FileNotFound, sPath, MsgBoxStyle.Exclamation) + Return False + End If End If + Return True End Function + Private Shared Sub ImportMonitorList(ByVal sLocation As String, Optional ByVal bWebRead As Boolean = False) + Dim hshCompareFrom As Hashtable + Dim hshCompareTo As Hashtable + Dim hshSyncItems As Hashtable + Dim oFromItem As clsGame + Dim oToItem As clsGame + + Cursor.Current = Cursors.WaitCursor + + 'Add / Update Sync + hshCompareFrom = mgrXML.ReadMonitorList(sLocation, bWebRead) + hshCompareTo = ReadList(eListTypes.FullList, mgrSQLite.Database.Local) + + hshSyncItems = hshCompareFrom.Clone + + For Each oFromItem In hshCompareFrom.Values + If hshCompareTo.Contains(oFromItem.CompoundKey) Then + oToItem = DirectCast(hshCompareTo(oFromItem.CompoundKey), clsGame) + If oFromItem.CoreEquals(oToItem) Then + hshSyncItems.Remove(oFromItem.CompoundKey) + End If + End If + Next + + Cursor.Current = Cursors.Default + + If hshSyncItems.Count > 0 Then + Dim frm As New frmAdvancedImport + frm.ImportData = hshSyncItems + If frm.ShowDialog() = DialogResult.OK Then + Cursor.Current = Cursors.WaitCursor + + DoListAddUpdateSync(frm.FinalData) + mgrTags.DoTagAddImport(frm.FinalData) + + Cursor.Current = Cursors.Default + mgrCommon.ShowMessage(mgrMonitorList_ImportComplete, MsgBoxStyle.Information) + End If + Else + mgrCommon.ShowMessage(mgrMonitorList_ImportNothing, MsgBoxStyle.Information) + End If + + Application.DoEvents() + End Sub + + Public Shared Sub ExportMonitorList(ByVal sLocation As String) + Dim oList As List(Of Game) + Dim bSuccess As Boolean = False + Dim oTagFilters As New List(Of clsTag) + Dim oStringFilters As New Hashtable + Dim eCurrentFilter As frmFilter.eFilterType = frmFilter.eFilterType.NoFilter + + If mgrCommon.ShowMessage(mgrMonitorList_ConfirmApplyFilter, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + Dim frm As New frmFilter + frm.ShowDialog() + oTagFilters = frm.TagFilters + oStringFilters = frm.StringFilters + eCurrentFilter = frm.FilterType + End If + + oList = ReadListForExport(oTagFilters, oStringFilters, eCurrentFilter) + + bSuccess = mgrXML.SerializeAndExport(oList, sLocation) + + If bSuccess Then + mgrCommon.ShowMessage(mgrMonitorList_ExportComplete, oList.Count, MsgBoxStyle.Information) + End If + End Sub + + 'Other Functions + Public Shared Sub HandleBackupLocationChange(ByVal oSettings As mgrSettings) + Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Remote) + Dim iGameCount As Integer + + 'Check if a remote database already exists in the new backup location + If oDatabase.CheckDB() Then + 'Make sure database is the latest version + oDatabase.DatabaseUpgrade() + + 'See if the remote database is empty + iGameCount = mgrMonitorList.ReadList(eListTypes.FullList, mgrSQLite.Database.Remote).Count + + 'If the remote database actually contains a list, then ask what to do + If iGameCount > 0 Then + If mgrCommon.ShowMessage(mgrMonitorList_ConfirmExistingData, MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) + Else + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields, False) + End If + Else + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) + End If + Else + mgrMonitorList.SyncMonitorLists(oSettings.SyncFields) + End If + End Sub End Class diff --git a/GBM/Managers/mgrTags.vb b/GBM/Managers/mgrTags.vb index ff38d32..95c84fa 100644 --- a/GBM/Managers/mgrTags.vb +++ b/GBM/Managers/mgrTags.vb @@ -1,26 +1,44 @@ Public Class mgrTags + Private Shared Function MapToObject(ByVal dr As DataRow) As clsTag + Dim oTag As New clsTag + + oTag.ID = CStr(dr("TagID")) + oTag.Name = CStr(dr("Name")) + + Return oTag + End Function + + Private Shared Function SetCoreParameters(ByVal oTag As clsTag) As Hashtable + Dim hshParams As New Hashtable + + hshParams.Add("ID", oTag.ID) + hshParams.Add("Name", oTag.Name) + + Return hshParams + End Function + Public Shared Sub DoTagAdd(ByVal oTag As clsTag, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String - Dim hshParams As New Hashtable + Dim hshParams As Hashtable sSQL = "INSERT INTO tags VALUES (@ID, @Name)" - hshParams.Add("ID", oTag.ID) - hshParams.Add("Name", oTag.Name) + + hshParams = SetCoreParameters(oTag) + oDatabase.RunParamQuery(sSQL, hshParams) End Sub Public Shared Sub DoTagUpdate(ByVal oTag As clsTag, Optional ByVal iSelectDB As mgrSQLite.Database = mgrSQLite.Database.Local) Dim oDatabase As New mgrSQLite(iSelectDB) Dim sSQL As String - Dim hshParams As New Hashtable + Dim hshParams As Hashtable sSQL = "UPDATE tags SET Name=@Name " sSQL &= "WHERE TagID = @ID" - hshParams.Add("Name", oTag.Name) - hshParams.Add("ID", oTag.ID) + hshParams = SetCoreParameters(oTag) oDatabase.RunParamQuery(sSQL, hshParams) @@ -57,9 +75,7 @@ oData = oDatabase.ReadParamData(sSQL, hshParams) For Each dr As DataRow In oData.Tables(0).Rows - oTag = New clsTag - oTag.ID = CStr(dr("TagID")) - oTag.Name = CStr(dr("Name")) + oTag = MapToObject(dr) Next Return oTag @@ -80,9 +96,7 @@ oData = oDatabase.ReadParamData(sSQL, hshParams) For Each dr As DataRow In oData.Tables(0).Rows - oTag = New clsTag - oTag.ID = CStr(dr("TagID")) - oTag.Name = CStr(dr("Name")) + oTag = MapToObject(dr) Next Return oTag @@ -124,9 +138,7 @@ oData = oDatabase.ReadParamData(sSQL, New Hashtable) For Each dr As DataRow In oData.Tables(0).Rows - oTag = New clsTag - oTag.ID = CStr(dr("TagID")) - oTag.Name = CStr(dr("Name")) + oTag = MapToObject(dr) hshList.Add(oTag.Name, oTag) Next diff --git a/GBM/Managers/mgrVariables.vb b/GBM/Managers/mgrVariables.vb index 16f0968..04613a9 100644 --- a/GBM/Managers/mgrVariables.vb +++ b/GBM/Managers/mgrVariables.vb @@ -1,5 +1,25 @@ Public Class mgrVariables + Private Shared Function MapToObject(ByVal dr As DataRow) As clsPathVariable + Dim oCustomVariable As New clsPathVariable + + oCustomVariable.ID = CStr(dr("VariableID")) + oCustomVariable.Name = CStr(dr("Name")) + oCustomVariable.Path = CStr(dr("Path")) + + Return oCustomVariable + End Function + + Private Shared Function SetCoreParameters(ByVal oCustomVariable As clsPathVariable) As Hashtable + Dim hshParams As New Hashtable + + hshParams.Add("ID", oCustomVariable.ID) + hshParams.Add("Name", oCustomVariable.Name) + hshParams.Add("Path", oCustomVariable.Path) + + Return hshParams + End Function + Public Shared Sub DoPathUpdate(ByVal sOld As String, ByVal sNew As String) Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Local) Dim sSQL As String @@ -15,26 +35,22 @@ Public Shared Sub DoVariableAdd(ByVal oCustomVariable As clsPathVariable) Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Local) Dim sSQL As String - Dim hshParams As New Hashtable + Dim hshParams As Hashtable sSQL = "INSERT INTO variables VALUES (@ID, @Name, @Path)" - hshParams.Add("ID", oCustomVariable.ID) - hshParams.Add("Name", oCustomVariable.Name) - hshParams.Add("Path", oCustomVariable.Path) + hshParams = SetCoreParameters(oCustomVariable) oDatabase.RunParamQuery(sSQL, hshParams) End Sub Public Shared Sub DoVariableUpdate(ByVal oCustomVariable As clsPathVariable) Dim oDatabase As New mgrSQLite(mgrSQLite.Database.Local) Dim sSQL As String - Dim hshParams As New Hashtable + Dim hshParams As Hashtable sSQL = "UPDATE variables SET Name=@Name, Path = @Path " sSQL &= "WHERE VariableID = @ID" - hshParams.Add("Name", oCustomVariable.Name) - hshParams.Add("Path", oCustomVariable.Path) - hshParams.Add("ID", oCustomVariable.ID) + hshParams = SetCoreParameters(oCustomVariable) oDatabase.RunParamQuery(sSQL, hshParams) @@ -69,10 +85,7 @@ oData = oDatabase.ReadParamData(sSQL, hshParams) For Each dr As DataRow In oData.Tables(0).Rows - oCustomVariable = New clsPathVariable - oCustomVariable.ID = CStr(dr("VariableID")) - oCustomVariable.Name = CStr(dr("Name")) - oCustomVariable.Path = CStr(dr("Path")) + oCustomVariable = MapToObject(dr) Next Return oCustomVariable @@ -93,10 +106,7 @@ oData = oDatabase.ReadParamData(sSQL, hshParams) For Each dr As DataRow In oData.Tables(0).Rows - oCustomVariable = New clsPathVariable - oCustomVariable.ID = CStr(dr("VariableID")) - oCustomVariable.Name = CStr(dr("Name")) - oCustomVariable.Path = CStr(dr("Path")) + oCustomVariable = MapToObject(dr) Next Return oCustomVariable @@ -138,10 +148,7 @@ oData = oDatabase.ReadParamData(sSQL, New Hashtable) For Each dr As DataRow In oData.Tables(0).Rows - oCustomVariable = New clsPathVariable - oCustomVariable.ID = CStr(dr("VariableID")) - oCustomVariable.Name = CStr(dr("Name")) - oCustomVariable.Path = CStr(dr("Path")) + oCustomVariable = MapToObject(dr) hshList.Add(oCustomVariable.Name, oCustomVariable) Next diff --git a/GBM/My Project/Resources.Designer.vb b/GBM/My Project/Resources.Designer.vb index c553bbb..1e362f6 100644 --- a/GBM/My Project/Resources.Designer.vb +++ b/GBM/My Project/Resources.Designer.vb @@ -259,7 +259,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to Save Entire Folder. + ''' Looks up a localized string similar to Save entire folder. ''' Friend ReadOnly Property frmAddWizard_chkFolderSave() As String Get @@ -268,7 +268,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to Time Stamp Backup. + ''' Looks up a localized string similar to Save multiple backups. ''' Friend ReadOnly Property frmAddWizard_chkTimeStamp() As String Get @@ -501,6 +501,15 @@ Namespace My.Resources End Get End Property + ''' + ''' Looks up a localized string similar to Backup Limit. + ''' + Friend ReadOnly Property frmAddWizard_lblLimit() As String + Get + Return ResourceManager.GetString("frmAddWizard_lblLimit", resourceCulture) + End Get + End Property + ''' ''' Looks up a localized string similar to The name will be automatically filtered for length and invalid characters. You may drag and drop a shortcut here to complete this step, only Windows shortcuts are currently supported.. ''' @@ -574,7 +583,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to If you're unsure of exactly which files to backup, make sure Save Entire Folder is checked. You can also time stamp your backup files to make incremental backups.. + ''' Looks up a localized string similar to If you're unsure of exactly which files to backup, make sure Save entire folder is checked. You can also choose to save multiple backups and set a limit on how many to keep.. ''' Friend ReadOnly Property frmAddWizard_lblStep3Instructions() As String Get @@ -709,7 +718,7 @@ Namespace My.Resources End Property ''' - ''' Looks up a localized string similar to Timestamp. + ''' Looks up a localized string similar to Multiple Backups. ''' Friend ReadOnly Property frmAddWizard_Summary_Timestamp() As String Get diff --git a/GBM/My Project/Resources.resx b/GBM/My Project/Resources.resx index 4993a9d..a5d7a7a 100644 --- a/GBM/My Project/Resources.resx +++ b/GBM/My Project/Resources.resx @@ -701,10 +701,10 @@ ... - Save Entire Folder + Save entire folder - Time Stamp Backup + Save multiple backups Choose exe file that starts the game @@ -806,7 +806,7 @@ Choose Files to Backup - If you're unsure of exactly which files to backup, make sure Save Entire Folder is checked. You can also time stamp your backup files to make incremental backups. + If you're unsure of exactly which files to backup, make sure Save entire folder is checked. You can also choose to save multiple backups and set a limit on how many to keep. Choose the location of your game's save files: @@ -851,7 +851,7 @@ Save Path - Timestamp + Multiple Backups &Cancel @@ -1726,4 +1726,7 @@ This will delete all backup files for [PARAM]. This cannot be undone. [BR][BR]Do you want to continue? + + Backup Limit + \ No newline at end of file