Exemplo n.º 1
0
 private void BackupCompleted(object sender, EventArgs e)
 {
     this.Enabled = true;
     _progressForm.Hide();
     _progressForm = null;
     _backup       = null;
     if (!backupCancelled)
     {
         _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].LastBackupDate = DateTime.Today;
         backupCancelled = false;
     }
 }
Exemplo n.º 2
0
        private void StartBackup()
        {
            if (listBoxPicasaDBs.SelectedIndex == -1)
            {
                MessageBox.Show("Please choose a picasa database from the list first");
                return;
            }
            if (!Directory.Exists(_settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BaseDir))
            {
                MessageBox.Show("The base directory of this database doesn't exist or you didn't choose one yet.");
                return;
            }
            if (!Directory.Exists(_settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BackupDir))
            {
                MessageBox.Show("The backup directory of this database doesn't exist or you didn't choose one yet.");
                return;
            }
            if (_backup != null)
            {
                MessageBox.Show("There is a backup still running... please wait until it is finished before starting one again.");
                return;
            }
            // Set in the new backup date (will be reversed if backup doesn't complete)
            _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].LastBackupDate = DateTime.Today;
            SaveSettings();
            try
            {
                String tmpDBPath = _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BaseDir;
                if (!Directory.Exists(tmpDBPath + "\\Google\\Picasa2") &&
                   Directory.Exists(tmpDBPath + "\\Local Settings\\Application Data\\Google\\Picasa2"))
                {
                     DialogResult result = MessageBox.Show("Do you want to temporarily back up the Picasa version 3.8 database?\n" +
                         "This Picasa 3.8 Database path is:\n " + _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BaseDir + "\\Local Settings\\Application Data" +
                        "\n\n Please edit the database settings, and convert the database to version 3.9 to stop receiving this warning message",
                            "Database Not Converted for Picasa Version 3.9+", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
                            (MessageBoxOptions)0x40000);
                     if (result == DialogResult.Yes)
                     {
                         tmpDBPath = _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BaseDir + "\\Local Settings\\Application Data";
                     }
                     else
                     {
                         return;
                     }

                }
                // Initialise the paths where the database and the albums can be found
                String picasaDBPath = tmpDBPath + "\\Google\\Picasa2";
                String picasaAlbumsPath = tmpDBPath + "\\Google\\Picasa2Albums";
                String psSettingsPath = _appSettingsDir;

                // Read directories watched/excluded by Picasa in the text files in the Album dir... 
                string watched = File.ReadAllText(picasaAlbumsPath + "\\watchedfolders.txt");
                string excluded = File.ReadAllText(picasaAlbumsPath + "\\frexcludefolders.txt");

                string[] watchedDirs = watched.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                string[] excludedDirs = excluded.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                _backup = new Backup();
                if (_settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BackupDBOnly == false)
                {
                    _backup.DestDirPrefix = "Backup_";
                    _backup.DestinationDir = _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BackupDir;
                    _backup.DirsToBackup.AddRange(watchedDirs);     // Backup watched dirs
                    _backup.DirsToBackup.Add(picasaDBPath);         // Backup Picasa database
                    _backup.DirsToBackup.Add(picasaAlbumsPath);     // Backup albums
                    _backup.DirsToBackup.Add(psSettingsPath);     // Backup Settings
                    _backup.DirsToExclude.AddRange(excludedDirs);   // Exclude explicitly unwatched dirs
                    _backup.MaxNbBackups = 100;                     // Max nb. backups to keep
                }
                else
                {
                    _backup.DestDirPrefix = "DBBackup_";
                    _backup.DestinationDir = _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BackupDir;
                    //_backup.DirsToBackup.AddRange(watchedDirs);     // Backup watched dirs
                    _backup.DirsToBackup.Add(picasaDBPath);         // Backup Picasa database
                    _backup.DirsToBackup.Add(picasaAlbumsPath);     // Backup albums
                    _backup.DirsToBackup.Add(psSettingsPath);     // Backup Settings
                    _backup.DirsToExclude.AddRange(excludedDirs);   // Exclude explicitly unwatched dirs
                    _backup.MaxNbBackups = 100;                     // Max nb. backups to keep

                }
                _progressForm = new BackupProgressForm(this);
                _progressForm.Show();
                this.Enabled = false;

                _backup.ProgressEvent += new Backup.BackupProgressEventHandler(_progressForm.Progress);
                _backup.CompletedEvent += new Backup.BackupCompletedEventHandler(BackupCompleted);

                // Start the asynchronous operation.
                _backup.StartBackupAssync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Exemplo n.º 3
0
 private void BackupCompleted(object sender, EventArgs e)
 {
     this.Enabled = true;
     _progressForm.Hide();
     _progressForm = null;
     _backup = null;
     if (!backupCancelled)
     {
         _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].LastBackupDate = DateTime.Today;
         backupCancelled = false;
     }
 }
Exemplo n.º 4
0
        private void StartBackup()
        {
            if (listBoxPicasaDBs.SelectedIndex == -1)
            {
                MessageBox.Show("Please choose a picasa database from the list first");
                return;
            }
            if (!Directory.Exists(_settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BaseDir))
            {
                MessageBox.Show("The base directory of this database doesn't exist or you didn't choose one yet.");
                return;
            }
            if (!Directory.Exists(_settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BackupDir))
            {
                MessageBox.Show("The backup directory of this database doesn't exist or you didn't choose one yet.");
                return;
            }
            if (_backup != null)
            {
                MessageBox.Show("There is a backup still running... please wait until it is finished before starting one again.");
                return;
            }
            // Set in the new backup date (will be reversed if backup doesn't complete)
            _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].LastBackupDate = DateTime.Today;
            SaveSettings();
            try
            {
                String tmpDBPath = _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BaseDir;
                if (!Directory.Exists(tmpDBPath + "\\Google\\Picasa2") &&
                    Directory.Exists(tmpDBPath + "\\Local Settings\\Application Data\\Google\\Picasa2"))
                {
                    DialogResult result = MessageBox.Show("Do you want to temporarily back up the Picasa version 3.8 database?\n" +
                                                          "This Picasa 3.8 Database path is:\n " + _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BaseDir + "\\Local Settings\\Application Data" +
                                                          "\n\n Please edit the database settings, and convert the database to version 3.9 to stop receiving this warning message",
                                                          "Database Not Converted for Picasa Version 3.9+", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1,
                                                          (MessageBoxOptions)0x40000);
                    if (result == DialogResult.Yes)
                    {
                        tmpDBPath = _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BaseDir + "\\Local Settings\\Application Data";
                    }
                    else
                    {
                        return;
                    }
                }
                // Initialise the paths where the database and the albums can be found
                String picasaDBPath     = tmpDBPath + "\\Google\\Picasa2";
                String picasaAlbumsPath = tmpDBPath + "\\Google\\Picasa2Albums";
                String psSettingsPath   = _appSettingsDir;

                // Read directories watched/excluded by Picasa in the text files in the Album dir...
                string watched  = File.ReadAllText(picasaAlbumsPath + "\\watchedfolders.txt");
                string excluded = File.ReadAllText(picasaAlbumsPath + "\\frexcludefolders.txt");

                string[] watchedDirs  = watched.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);
                string[] excludedDirs = excluded.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries);

                _backup = new Backup();
                if (_settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BackupDBOnly == false)
                {
                    _backup.DestDirPrefix  = "Backup_";
                    _backup.DestinationDir = _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BackupDir;
                    _backup.DirsToBackup.AddRange(watchedDirs);   // Backup watched dirs
                    _backup.DirsToBackup.Add(picasaDBPath);       // Backup Picasa database
                    _backup.DirsToBackup.Add(picasaAlbumsPath);   // Backup albums
                    _backup.DirsToBackup.Add(psSettingsPath);     // Backup Settings
                    _backup.DirsToExclude.AddRange(excludedDirs); // Exclude explicitly unwatched dirs
                    _backup.MaxNbBackups = 100;                   // Max nb. backups to keep
                }
                else
                {
                    _backup.DestDirPrefix  = "DBBackup_";
                    _backup.DestinationDir = _settings.picasaDBs[listBoxPicasaDBs.SelectedIndex].BackupDir;
                    //_backup.DirsToBackup.AddRange(watchedDirs);     // Backup watched dirs
                    _backup.DirsToBackup.Add(picasaDBPath);       // Backup Picasa database
                    _backup.DirsToBackup.Add(picasaAlbumsPath);   // Backup albums
                    _backup.DirsToBackup.Add(psSettingsPath);     // Backup Settings
                    _backup.DirsToExclude.AddRange(excludedDirs); // Exclude explicitly unwatched dirs
                    _backup.MaxNbBackups = 100;                   // Max nb. backups to keep
                }
                _progressForm = new BackupProgressForm(this);
                _progressForm.Show();
                this.Enabled = false;

                _backup.ProgressEvent  += new Backup.BackupProgressEventHandler(_progressForm.Progress);
                _backup.CompletedEvent += new Backup.BackupCompletedEventHandler(BackupCompleted);

                // Start the asynchronous operation.
                _backup.StartBackupAssync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }