Пример #1
0
        static void HandleDeviceArrived(string driveLetter)
        {
            MultiProgress progress = new MultiProgress(new IProgress[] {});

            List <IUsbDriveInfo> foundDrives = GetFoundDrives();
            var drive = foundDrives.FirstOrDefault(d => d.RootDirectory.ToString() == driveLetter);

            if (drive == null || !drive.IsReady)
            {
                return;
            }
            try
            {
                if (!IsAKnownBackupDrive(drive))
                {
                    if (DialogResult.Yes == new NewDrivePopup().ShowDialog())
                    {
                        Directory.CreateDirectory(BackupControl.GetDestinationFolderPath(drive.RootDirectory.ToString()));
                    }
                }
                //based on that popup, it might now pass this test:
                if (IsAKnownBackupDrive(drive))
                {
                    LaunchBackup(progress, GetFileLogProgress(progress), drive);
                }
            }
            catch (Exception error)
            {
                SIL.Reporting.ErrorReport.NotifyUserOfProblem(error, "Sorry, something went wrong.");
            }
        }
Пример #2
0
 public MainWindow(BackupControl backupControl, MultiProgress progress)
 {
     //Font = SystemFonts.MessageBoxFont;
     InitializeComponent();
     SetWindowText();
     backupControl.Dock      = DockStyle.Fill;
     backupControl.CloseNow += () => Close();
     _backupPage.Controls.Add(backupControl);
     progress.Add(_logBox);
 }
Пример #3
0
 private static bool IsAKnownBackupDrive(IUsbDriveInfo drive)
 {
     //though I could not reproduce it D Rowe had found that removing the drive before the popup closed gave and exception here
     try
     {
         return(Directory.Exists(BackupControl.GetDestinationFolderPath(drive.RootDirectory.ToString())));
     }
     catch
     {
         return(false);
     }
 }
Пример #4
0
        private static void DoTestRun()
        {
            MultiProgress progress = new MultiProgress(new IProgress[] { });
            var           destinationDeviceRoot = @"c:\dev\temp\SafetyStick";

//			if (Directory.Exists(path))
//				Directory.Delete(path, true);

            //		var info = new DriveInfo(Path.GetPathRoot(destinationPath));

            var totalSpaceInKilobytes = 900 * 1024;            // (int)(100.0 * info.AvailableFreeSpace / info.TotalSize);
            var freeSpaceInKilobytes  = 800 * 1024;
            var backupControl         = new BackupControl(destinationDeviceRoot, freeSpaceInKilobytes, totalSpaceInKilobytes, progress);

            backupControl.DoPreview = false;
            backupControl.AutoStart = true;

            new MainWindow(backupControl, progress).ShowDialog();
        }
Пример #5
0
        private static void LaunchBackup(IProgress progress, IProgress fileLogProgress, IUsbDriveInfo drive)
        {
            long   totalSpaceInKilobytes = (long)(drive.TotalSize / 1024);
            long   freeSpaceInKilobytes  = (long)(drive.AvailableFreeSpace / 1024);
            string destinationDeviceRoot = drive.RootDirectory.ToString();
            var    backupControl         = new BackupControl(destinationDeviceRoot, freeSpaceInKilobytes, totalSpaceInKilobytes, progress);

            UsageReporter.SendNavigationNotice("StartBackup");
            Settings.Default.Save();

            using (var form = new MainWindow(backupControl, progress))
            {
                form.ShowDialog();
                if (fileLogProgress != null)
                {
                    fileLogProgress.WriteMessage("Finished showing Dialog");
                }
            }
        }
Пример #6
0
        static void HandleDeviceArrived(string driveLetter)
        {
            MultiProgress       progress    = new MultiProgress(new IProgress[] {});
            List <UsbDriveInfo> foundDrives = GetFoundDrives();
            var drive = foundDrives.FirstOrDefault(d => d.RootDirectory.ToString() == driveLetter);

            if (drive == null || !drive.IsReady)
            {
                return;
            }
            try
            {
                if (!IsAKnownBackupDrive(drive))
                {
                    if (DialogResult.Yes == new NewDrivePopup().ShowDialog())
                    {
                        Directory.CreateDirectory(BackupControl.GetDestinationFolderPath(drive.RootDirectory.ToString()));
                    }
                }
                //based on that popup, it might now pass this test:
                if (IsAKnownBackupDrive(drive))
                {
                    long   totalSpaceInKilobytes = (long)(drive.TotalSize / 1024);
                    long   freeSpaceInKilobytes  = (long)(drive.AvailableFreeSpace / 1024);
                    string destinationDeviceRoot = drive.RootDirectory.ToString();
                    var    backupControl         = new BackupControl(destinationDeviceRoot, freeSpaceInKilobytes, totalSpaceInKilobytes, progress);
                    using (var form = new MainWindow(backupControl, progress))
                    {
                        form.ShowDialog();
                    }
                }
            }
            catch (Exception error)
            {
                Palaso.Reporting.ErrorReport.NotifyUserOfProblem(error, "Sorry, something went wrong.");
            }
        }
Пример #7
0
 private static bool IsAKnownBackupDrive(UsbDriveInfo drive)
 {
     return(Directory.Exists(BackupControl.GetDestinationFolderPath(drive.RootDirectory.ToString())));
 }