Added backup threshold setting (Issue 19)

This commit is contained in:
Michael J. Seiferling
2015-12-05 10:42:55 -06:00
parent 1e68728930
commit 83135acb90
5 changed files with 121 additions and 30 deletions
+19
View File
@@ -267,6 +267,12 @@ Public Class frmMain
eCurrentOperation = eOperation.Backup eCurrentOperation = eOperation.Backup
OperationStarted(False) OperationStarted(False)
If SupressBackup() Then
bDoBackup = False
UpdateLog(oProcess.GameInfo.Name & " backup was cancelled due to session time.", False)
SetLastAction(oProcess.GameInfo.CroppedName & " backup was cancelled due to session time")
OperationEnded()
Else
If oProcess.GameInfo.MonitorOnly = False Then If oProcess.GameInfo.MonitorOnly = False Then
If oSettings.DisableConfirmation Then If oSettings.DisableConfirmation Then
bDoBackup = True bDoBackup = True
@@ -286,6 +292,7 @@ Public Class frmMain
SetLastAction(oProcess.GameInfo.CroppedName & " monitoring ended") SetLastAction(oProcess.GameInfo.CroppedName & " monitoring ended")
OperationEnded() OperationEnded()
End If End If
End If
If bDoBackup Then If bDoBackup Then
'Run the backup 'Run the backup
@@ -564,6 +571,18 @@ Public Class frmMain
oProcess.StartTime = Now : oProcess.EndTime = Now oProcess.StartTime = Now : oProcess.EndTime = Now
End Sub End Sub
Private Function SupressBackup() As Boolean
If oSettings.SupressBackup Then
If oProcess.TimeSpent.Minutes > oSettings.SupressBackupThreshold Then
Return False
Else
Return True
End If
Else
Return False
End If
End Function
'Functions handling the opening of other windows 'Functions handling the opening of other windows
Private Sub OpenAbout() Private Sub OpenAbout()
MsgBox("Game Backup Monitor" & vbCrLf & sVersion & vbCrLf & sRevision & vbCrLf & Chr(169) & sConstCopyright & vbCrLf & vbCrLf & MsgBox("Game Backup Monitor" & vbCrLf & sVersion & vbCrLf & sRevision & vbCrLf & Chr(169) & sConstCopyright & vbCrLf & vbCrLf &
+49 -11
View File
@@ -38,6 +38,9 @@ Partial Class frmSettings
Me.btnSave = New System.Windows.Forms.Button() Me.btnSave = New System.Windows.Forms.Button()
Me.btnCancel = New System.Windows.Forms.Button() Me.btnCancel = New System.Windows.Forms.Button()
Me.grpBackup = New System.Windows.Forms.GroupBox() Me.grpBackup = New System.Windows.Forms.GroupBox()
Me.Label1 = New System.Windows.Forms.Label()
Me.nudSupressBackupThreshold = New System.Windows.Forms.NumericUpDown()
Me.chkSupressBackup = New System.Windows.Forms.CheckBox()
Me.chkCheckSum = New System.Windows.Forms.CheckBox() Me.chkCheckSum = New System.Windows.Forms.CheckBox()
Me.chkRestoreOnLaunch = New System.Windows.Forms.CheckBox() Me.chkRestoreOnLaunch = New System.Windows.Forms.CheckBox()
Me.chkOverwriteWarning = New System.Windows.Forms.CheckBox() Me.chkOverwriteWarning = New System.Windows.Forms.CheckBox()
@@ -45,6 +48,7 @@ Partial Class frmSettings
Me.grpGeneral.SuspendLayout() Me.grpGeneral.SuspendLayout()
Me.grpPaths.SuspendLayout() Me.grpPaths.SuspendLayout()
Me.grpBackup.SuspendLayout() Me.grpBackup.SuspendLayout()
CType(Me.nudSupressBackupThreshold, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout() Me.SuspendLayout()
' '
'chkMonitorOnStartup 'chkMonitorOnStartup
@@ -60,10 +64,10 @@ Partial Class frmSettings
'chkBackupConfirm 'chkBackupConfirm
' '
Me.chkBackupConfirm.AutoSize = True Me.chkBackupConfirm.AutoSize = True
Me.chkBackupConfirm.Location = New System.Drawing.Point(6, 19) Me.chkBackupConfirm.Location = New System.Drawing.Point(6, 42)
Me.chkBackupConfirm.Name = "chkBackupConfirm" Me.chkBackupConfirm.Name = "chkBackupConfirm"
Me.chkBackupConfirm.Size = New System.Drawing.Size(160, 17) Me.chkBackupConfirm.Size = New System.Drawing.Size(160, 17)
Me.chkBackupConfirm.TabIndex = 0 Me.chkBackupConfirm.TabIndex = 1
Me.chkBackupConfirm.Text = "Disable backup confirmation" Me.chkBackupConfirm.Text = "Disable backup confirmation"
Me.chkBackupConfirm.UseVisualStyleBackColor = True Me.chkBackupConfirm.UseVisualStyleBackColor = True
' '
@@ -137,7 +141,7 @@ Partial Class frmSettings
Me.grpPaths.Controls.Add(Me.btnBackupFolder) Me.grpPaths.Controls.Add(Me.btnBackupFolder)
Me.grpPaths.Controls.Add(Me.lblBackupFolder) Me.grpPaths.Controls.Add(Me.lblBackupFolder)
Me.grpPaths.Controls.Add(Me.txtBackupFolder) Me.grpPaths.Controls.Add(Me.txtBackupFolder)
Me.grpPaths.Location = New System.Drawing.Point(12, 331) Me.grpPaths.Location = New System.Drawing.Point(12, 360)
Me.grpPaths.Name = "grpPaths" Me.grpPaths.Name = "grpPaths"
Me.grpPaths.Size = New System.Drawing.Size(360, 60) Me.grpPaths.Size = New System.Drawing.Size(360, 60)
Me.grpPaths.TabIndex = 2 Me.grpPaths.TabIndex = 2
@@ -172,7 +176,7 @@ Partial Class frmSettings
'btnSave 'btnSave
' '
Me.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK Me.btnSave.DialogResult = System.Windows.Forms.DialogResult.OK
Me.btnSave.Location = New System.Drawing.Point(216, 397) Me.btnSave.Location = New System.Drawing.Point(216, 426)
Me.btnSave.Name = "btnSave" Me.btnSave.Name = "btnSave"
Me.btnSave.Size = New System.Drawing.Size(75, 23) Me.btnSave.Size = New System.Drawing.Size(75, 23)
Me.btnSave.TabIndex = 3 Me.btnSave.TabIndex = 3
@@ -182,7 +186,7 @@ Partial Class frmSettings
'btnCancel 'btnCancel
' '
Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel Me.btnCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.btnCancel.Location = New System.Drawing.Point(297, 397) Me.btnCancel.Location = New System.Drawing.Point(297, 426)
Me.btnCancel.Name = "btnCancel" Me.btnCancel.Name = "btnCancel"
Me.btnCancel.Size = New System.Drawing.Size(75, 23) Me.btnCancel.Size = New System.Drawing.Size(75, 23)
Me.btnCancel.TabIndex = 4 Me.btnCancel.TabIndex = 4
@@ -191,6 +195,9 @@ Partial Class frmSettings
' '
'grpBackup 'grpBackup
' '
Me.grpBackup.Controls.Add(Me.Label1)
Me.grpBackup.Controls.Add(Me.nudSupressBackupThreshold)
Me.grpBackup.Controls.Add(Me.chkSupressBackup)
Me.grpBackup.Controls.Add(Me.chkCheckSum) Me.grpBackup.Controls.Add(Me.chkCheckSum)
Me.grpBackup.Controls.Add(Me.chkRestoreOnLaunch) Me.grpBackup.Controls.Add(Me.chkRestoreOnLaunch)
Me.grpBackup.Controls.Add(Me.chkOverwriteWarning) Me.grpBackup.Controls.Add(Me.chkOverwriteWarning)
@@ -198,11 +205,38 @@ Partial Class frmSettings
Me.grpBackup.Controls.Add(Me.chkBackupConfirm) Me.grpBackup.Controls.Add(Me.chkBackupConfirm)
Me.grpBackup.Location = New System.Drawing.Point(12, 183) Me.grpBackup.Location = New System.Drawing.Point(12, 183)
Me.grpBackup.Name = "grpBackup" Me.grpBackup.Name = "grpBackup"
Me.grpBackup.Size = New System.Drawing.Size(360, 142) Me.grpBackup.Size = New System.Drawing.Size(360, 171)
Me.grpBackup.TabIndex = 1 Me.grpBackup.TabIndex = 1
Me.grpBackup.TabStop = False Me.grpBackup.TabStop = False
Me.grpBackup.Text = "Backup and Restore Options" Me.grpBackup.Text = "Backup and Restore Options"
' '
'Label1
'
Me.Label1.AutoSize = True
Me.Label1.Location = New System.Drawing.Point(286, 135)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(43, 13)
Me.Label1.TabIndex = 7
Me.Label1.Text = "minutes"
'
'nudSupressBackupThreshold
'
Me.nudSupressBackupThreshold.Location = New System.Drawing.Point(229, 133)
Me.nudSupressBackupThreshold.Maximum = New Decimal(New Integer() {999, 0, 0, 0})
Me.nudSupressBackupThreshold.Name = "nudSupressBackupThreshold"
Me.nudSupressBackupThreshold.Size = New System.Drawing.Size(51, 20)
Me.nudSupressBackupThreshold.TabIndex = 6
'
'chkSupressBackup
'
Me.chkSupressBackup.AutoSize = True
Me.chkSupressBackup.Location = New System.Drawing.Point(6, 134)
Me.chkSupressBackup.Name = "chkSupressBackup"
Me.chkSupressBackup.Size = New System.Drawing.Size(217, 17)
Me.chkSupressBackup.TabIndex = 5
Me.chkSupressBackup.Text = "Backup only when session time exceeds"
Me.chkSupressBackup.UseVisualStyleBackColor = True
'
'chkCheckSum 'chkCheckSum
' '
Me.chkCheckSum.AutoSize = True Me.chkCheckSum.AutoSize = True
@@ -236,18 +270,18 @@ Partial Class frmSettings
'chkCreateFolder 'chkCreateFolder
' '
Me.chkCreateFolder.AutoSize = True Me.chkCreateFolder.AutoSize = True
Me.chkCreateFolder.Location = New System.Drawing.Point(6, 42) Me.chkCreateFolder.Location = New System.Drawing.Point(6, 19)
Me.chkCreateFolder.Name = "chkCreateFolder" Me.chkCreateFolder.Name = "chkCreateFolder"
Me.chkCreateFolder.Size = New System.Drawing.Size(211, 17) Me.chkCreateFolder.Size = New System.Drawing.Size(186, 17)
Me.chkCreateFolder.TabIndex = 1 Me.chkCreateFolder.TabIndex = 0
Me.chkCreateFolder.Text = "Create a sub-folder for each application" Me.chkCreateFolder.Text = "Create a sub-folder for each game"
Me.chkCreateFolder.UseVisualStyleBackColor = True Me.chkCreateFolder.UseVisualStyleBackColor = True
' '
'frmSettings 'frmSettings
' '
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!) Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(384, 431) Me.ClientSize = New System.Drawing.Size(384, 461)
Me.Controls.Add(Me.grpBackup) Me.Controls.Add(Me.grpBackup)
Me.Controls.Add(Me.btnCancel) Me.Controls.Add(Me.btnCancel)
Me.Controls.Add(Me.btnSave) Me.Controls.Add(Me.btnSave)
@@ -267,6 +301,7 @@ Partial Class frmSettings
Me.grpPaths.PerformLayout() Me.grpPaths.PerformLayout()
Me.grpBackup.ResumeLayout(False) Me.grpBackup.ResumeLayout(False)
Me.grpBackup.PerformLayout() Me.grpBackup.PerformLayout()
CType(Me.nudSupressBackupThreshold, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False) Me.ResumeLayout(False)
End Sub End Sub
@@ -290,4 +325,7 @@ Partial Class frmSettings
Friend WithEvents chkCheckSum As System.Windows.Forms.CheckBox Friend WithEvents chkCheckSum As System.Windows.Forms.CheckBox
Friend WithEvents chkStartWindows As System.Windows.Forms.CheckBox Friend WithEvents chkStartWindows As System.Windows.Forms.CheckBox
Friend WithEvents chkTimeTracking As System.Windows.Forms.CheckBox Friend WithEvents chkTimeTracking As System.Windows.Forms.CheckBox
Friend WithEvents Label1 As Label
Friend WithEvents nudSupressBackupThreshold As NumericUpDown
Friend WithEvents chkSupressBackup As CheckBox
End Class End Class
+4
View File
@@ -54,6 +54,8 @@
oSettings.ShowOverwriteWarning = chkOverwriteWarning.Checked oSettings.ShowOverwriteWarning = chkOverwriteWarning.Checked
oSettings.RestoreOnLaunch = chkRestoreOnLaunch.Checked oSettings.RestoreOnLaunch = chkRestoreOnLaunch.Checked
oSettings.TimeTracking = chkTimeTracking.Checked oSettings.TimeTracking = chkTimeTracking.Checked
oSettings.SupressBackup = chkSupressBackup.Checked
oSettings.SupressBackupThreshold = nudSupressBackupThreshold.Value
'We need to clear all checksums its turned off 'We need to clear all checksums its turned off
If chkCheckSum.Checked = False And oSettings.CheckSum = True Then If chkCheckSum.Checked = False And oSettings.CheckSum = True Then
@@ -104,6 +106,8 @@
chkSync.Checked = oSettings.Sync chkSync.Checked = oSettings.Sync
chkCheckSum.Checked = oSettings.CheckSum chkCheckSum.Checked = oSettings.CheckSum
chkTimeTracking.Checked = oSettings.TimeTracking chkTimeTracking.Checked = oSettings.TimeTracking
chkSupressBackup.Checked = oSettings.SupressBackup
nudSupressBackupThreshold.Value = oSettings.SupressBackupThreshold
End Sub End Sub
Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click Private Sub btnSave_Click(sender As System.Object, e As System.EventArgs) Handles btnSave.Click
+9 -4
View File
@@ -69,9 +69,10 @@ Public Class mgrSQLite
SQLiteConnection.CreateFile(sDatabaseLocation) SQLiteConnection.CreateFile(sDatabaseLocation)
'Add Tables (Settings) 'Add Tables (Settings)
sSql = "CREATE TABLE settings (SettingsID INTEGER NOT NULL PRIMARY KEY, MonitorOnStartup BOOLEAN NOT NULL, StartToTray BOOLEAN NOT NULL, ShowDetectionToolTips BOOLEAN NOT NULL, " & _ sSql = "CREATE TABLE settings (SettingsID INTEGER NOT NULL PRIMARY KEY, MonitorOnStartup BOOLEAN NOT NULL, StartToTray BOOLEAN NOT NULL, ShowDetectionToolTips BOOLEAN NOT NULL, " &
"DisableConfirmation BOOLEAN NOT NULL, CreateSubFolder BOOLEAN NOT NULL, ShowOverwriteWarning BOOLEAN NOT NULL, RestoreOnLaunch BOOLEAN NOT NULL, " & _ "DisableConfirmation BOOLEAN NOT NULL, CreateSubFolder BOOLEAN NOT NULL, ShowOverwriteWarning BOOLEAN NOT NULL, RestoreOnLaunch BOOLEAN NOT NULL, " &
"BackupFolder TEXT NOT NULL, Sync BOOLEAN NOT NULL, CheckSum BOOLEAN NOT NULL, StartWithWindows BOOLEAN NOT NULL, TimeTracking BOOLEAN NOT NULL);" "BackupFolder TEXT NOT NULL, Sync BOOLEAN NOT NULL, CheckSum BOOLEAN NOT NULL, StartWithWindows BOOLEAN NOT NULL, TimeTracking BOOLEAN NOT NULL, " &
"SupressBackup BOOLEAN NOT NULL, SupressBackupThreshold INTEGER NOT NULL);"
'Add Tables (Monitor List) 'Add Tables (Monitor List)
sSql &= "CREATE TABLE monitorlist (MonitorID TEXT NOT NULL UNIQUE, Name TEXT NOT NULL, Process TEXT NOT NULL, Path TEXT, " & _ sSql &= "CREATE TABLE monitorlist (MonitorID TEXT NOT NULL UNIQUE, Name TEXT NOT NULL, Process TEXT NOT NULL, Path TEXT, " & _
@@ -486,7 +487,11 @@ Public Class mgrSQLite
'Backup DB before starting 'Backup DB before starting
BackupDB("v94") BackupDB("v94")
sSQL = "PRAGMA user_version=95" 'Add new setting
sSQL = "ALTER TABLE settings ADD COLUMN SupressBackup BOOLEAN NOT NULL DEFAULT 0;"
sSQL &= "ALTER TABLE settings ADD COLUMN SupressBackupThreshold INTEGER NOT NULL DEFAULT 10;"
sSQL &= "PRAGMA user_version=95"
RunParamQuery(sSQL, New Hashtable) RunParamQuery(sSQL, New Hashtable)
End If End If
+26 -1
View File
@@ -12,6 +12,8 @@ Public Class mgrSettings
Private bSync As Boolean = True Private bSync As Boolean = True
Private bCheckSum As Boolean = True Private bCheckSum As Boolean = True
Private bTimeTracking As Boolean = True Private bTimeTracking As Boolean = True
Private bSupressBackup As Boolean = False
Private iSupressBackupThreshold As Integer = 10
Private sBackupFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).TrimEnd(New Char() {"\", "/"}) Private sBackupFolder As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments).TrimEnd(New Char() {"\", "/"})
Property StartWithWindows As Boolean Property StartWithWindows As Boolean
@@ -113,6 +115,24 @@ Public Class mgrSettings
End Set End Set
End Property End Property
Property SupressBackup As Boolean
Get
Return bSupressBackup
End Get
Set(value As Boolean)
bSupressBackup = value
End Set
End Property
Property SupressBackupThreshold As Integer
Get
Return iSupressBackupThreshold
End Get
Set(value As Integer)
iSupressBackupThreshold = value
End Set
End Property
Property BackupFolder As String Property BackupFolder As String
Get Get
Return sBackupFolder Return sBackupFolder
@@ -131,7 +151,8 @@ Public Class mgrSettings
oDatabase.RunParamQuery(sSQL, New Hashtable) oDatabase.RunParamQuery(sSQL, New Hashtable)
sSQL = "INSERT INTO settings VALUES (1, @MonitorOnStartup, @StartToTray, @ShowDetectionToolTips, @DisableConfirmation, " sSQL = "INSERT INTO settings VALUES (1, @MonitorOnStartup, @StartToTray, @ShowDetectionToolTips, @DisableConfirmation, "
sSQL &= "@CreateSubFolder, @ShowOverwriteWarning, @RestoreOnLaunch, @BackupFolder, @Sync, @CheckSum, @StartWithWindows, @TimeTracking)" sSQL &= "@CreateSubFolder, @ShowOverwriteWarning, @RestoreOnLaunch, @BackupFolder, @Sync, @CheckSum, @StartWithWindows, "
sSQL &= "@TimeTracking, @SupressBackup, @SupressBackupThreshold)"
hshParams.Add("MonitorOnStartup", MonitorOnStartup) hshParams.Add("MonitorOnStartup", MonitorOnStartup)
hshParams.Add("StartToTray", StartToTray) hshParams.Add("StartToTray", StartToTray)
@@ -145,6 +166,8 @@ Public Class mgrSettings
hshParams.Add("CheckSum", CheckSum) hshParams.Add("CheckSum", CheckSum)
hshParams.Add("StartWithWindows", StartWithWindows) hshParams.Add("StartWithWindows", StartWithWindows)
hshParams.Add("TimeTracking", TimeTracking) hshParams.Add("TimeTracking", TimeTracking)
hshParams.Add("SupressBackup", SupressBackup)
hshParams.Add("SupressBackupThreshold", SupressBackupThreshold)
oDatabase.RunParamQuery(sSQL, hshParams) oDatabase.RunParamQuery(sSQL, hshParams)
End Sub End Sub
@@ -172,6 +195,8 @@ Public Class mgrSettings
CheckSum = CBool(dr("CheckSum")) CheckSum = CBool(dr("CheckSum"))
StartWithWindows = CBool(dr("StartWithWindows")) StartWithWindows = CBool(dr("StartWithWindows"))
TimeTracking = CBool(dr("TimeTracking")) TimeTracking = CBool(dr("TimeTracking"))
SupressBackup = CBool(dr("SupressBackup"))
SupressBackupThreshold = CInt(dr("SupressBackupThreshold"))
Next Next
oDatabase.Disconnect() oDatabase.Disconnect()