1
Fork 0

added code that is run at the end of the copy (almost), so backup record can be put there. Still need to lock progress bars.

This commit is contained in:
Jake Howard 2014-12-30 17:34:33 +00:00
parent 1b6ba42639
commit 127f26c7ed

View file

@ -8,6 +8,7 @@ using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using System.IO; using System.IO;
using System.Diagnostics;
using CopyFiles; using CopyFiles;
@ -16,15 +17,29 @@ namespace Saviour_Backup_System
public partial class transferWindow : Form, CopyFiles.ICopyFilesDiag, IDisposable public partial class transferWindow : Form, CopyFiles.ICopyFilesDiag, IDisposable
{ {
public System.ComponentModel.ISynchronizeInvoke SynchronizationObject { get; set; } public System.ComponentModel.ISynchronizeInvoke SynchronizationObject { get; set; }
int arrayIndex; private int arrayIndex;
DriveInfo copyingDrive; public Int64 startTime = tools.getUnixTimeStamp(); //snapshots it.
private DriveInfo copyingDrive;
public transferWindow(int backups, DriveInfo drive) { private Stopwatch SW = new Stopwatch();
string driveHash;
bool finalised = false;
public transferWindow(int backups, DriveInfo drive, string hash) {
driveHash = hash;
copyingDrive = drive; copyingDrive = drive;
InitializeComponent(); InitializeComponent();
arrayIndex = backups; arrayIndex = backups;
currentFileProgress.Maximum = 1000; currentFileProgress.Maximum = 1000;
SW.Start(); //starts the stopwatch to count how long the copy takes
}
private void finaliseCopy() {
SW.Stop(); //stops the stopwatch. Is done a little too early, but it's good enough!
databaseTools.createBackupRecord(copyingDrive, startTime, SW.Elapsed.Seconds, driveHash);
setup.CT.progressBars[arrayIndex].ColorTable = DevComponents.DotNetBar.eProgressBarItemColor.Normal;
setup.CT.progressBars[arrayIndex].Value = 100;
setup.CT.progressBars[arrayIndex].Maximum = 100;
setup.CT.progressBars[arrayIndex].Text = "Complete!";
finalised = true;
} }
public void update(Int32 totalFiles, Int32 copiedFiles, Int64 totalBytes, Int64 copiedBytes, string currentFilename) public void update(Int32 totalFiles, Int32 copiedFiles, Int64 totalBytes, Int64 copiedBytes, string currentFilename)
@ -40,12 +55,11 @@ namespace Saviour_Backup_System
setup.CT.progressBars[arrayIndex].Value = totalFilesProgress.Value; setup.CT.progressBars[arrayIndex].Value = totalFilesProgress.Value;
setup.CT.progressBars[arrayIndex].Maximum = totalFiles; setup.CT.progressBars[arrayIndex].Maximum = totalFiles;
setup.CT.progressBars[arrayIndex].Text = "Copying " + (copiedBytes / 1024f).ToString() + " of " + (totalBytes / 1024f).ToString(); setup.CT.progressBars[arrayIndex].Text = "Copying " + (copiedBytes / 1024f).ToString() + " of " + (totalBytes / 1024f).ToString();
int percentage = ((totalFiles + 1) / (copiedFiles + 1)) * 10000;
if (setup.MW.selectedDrive.Name.Substring(0, 1) == currentFilename.Substring(0, 1)) { if (percentage >= 9999 && !finalised)
setup.MW.backupProgress.Value = totalFilesProgress.Value; {
setup.MW.backupProgress.Maximum = totalFiles; finaliseCopy();
} }
} }
public void cancelCopy() { public void cancelCopy() {