Exemplo n.º 1
0
 private void BackupCompleted(object sender, EventArgs e)
 {
     this.Enabled = true;
     _progressForm.Hide();
     _progressForm = null;
     _backup       = null;
     if (!backupCancelled)
     {
         Program.BackupComplete = true;
         backupCancelled        = false;
     }
     Close();
 }
Exemplo n.º 2
0
        private void StartBackupCL()
        {
            //Function will back up pictures and database when cmd line arg is /backup "database name"

            if (!Directory.Exists(_db.BaseDir))
            {
                //MessageBox.Show("The base directory of this database doesn't exist or you didn't choose one yet.");
                return;
            }
            if (!Directory.Exists(_db.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;
            }

            try
            {
                String tmpDBPath = _db.BaseDir;
                if (!Directory.Exists(tmpDBPath + "\\Google\\Picasa2") &&
                    Directory.Exists(tmpDBPath + "\\Local Settings\\Application Data\\Google\\Picasa2"))
                {
                    tmpDBPath = _db.BaseDir + "\\Local Settings\\Application Data";
                }
                // Initialise the paths where the database and the albums can be found
                String picasaDBPath     = tmpDBPath + "\\Google\\Picasa2";
                String picasaAlbumsPath = tmpDBPath + "\\Google\\Picasa2Albums";
                String psSettingsPath   = settingsDir;

                // 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 (_db.BackupDBOnly == false)
                {
                    _backup.DestDirPrefix  = "Backup_";
                    _backup.DestinationDir = _db.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 = _db.BackupDir;
                    _backup.DirsToBackup.Add(picasaDBPath);       // Backup Picasa database
                    _backup.DirsToBackup.Add(picasaAlbumsPath);   // Backup albums
                    _backup.DirsToBackup.Add(psSettingsPath);     // Backup Settings
                    _backup.MaxNbBackups = 100;                   // Max nb. backups to keep
                }

                _progressForm = new BackupProgressForm_CL(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 StartBackupCL()
        {
            //Function will back up pictures and database when cmd line arg is /backup "database name"
 
            if (!Directory.Exists(_db.BaseDir))
            {
                //MessageBox.Show("The base directory of this database doesn't exist or you didn't choose one yet.");
                return;
            }
            if (!Directory.Exists(_db.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;
            }

            try
            {
                String tmpDBPath = _db.BaseDir;
                if (!Directory.Exists(tmpDBPath + "\\Google\\Picasa2") &&
                   Directory.Exists(tmpDBPath + "\\Local Settings\\Application Data\\Google\\Picasa2"))
                {
                    tmpDBPath = _db.BaseDir + "\\Local Settings\\Application Data";
                }
                // Initialise the paths where the database and the albums can be found
                String picasaDBPath = tmpDBPath + "\\Google\\Picasa2";
                String picasaAlbumsPath = tmpDBPath + "\\Google\\Picasa2Albums";
                String psSettingsPath = settingsDir;

                // 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 (_db.BackupDBOnly == false)
                {
                    _backup.DestDirPrefix = "Backup_";
                    _backup.DestinationDir = _db.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 = _db.BackupDir;
                    _backup.DirsToBackup.Add(picasaDBPath);         // Backup Picasa database
                    _backup.DirsToBackup.Add(picasaAlbumsPath);     // Backup albums
                    _backup.DirsToBackup.Add(psSettingsPath);     // Backup Settings
                    _backup.MaxNbBackups = 100;                     // Max nb. backups to keep

                }

                _progressForm = new BackupProgressForm_CL(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.º 4
0
 private void BackupCompleted(object sender, EventArgs e)
 {
     this.Enabled = true;
     _progressForm.Hide();
     _progressForm = null;
     _backup = null;
     if (!backupCancelled)
     {
         Program.BackupComplete = true;
         backupCancelled = false;
     }
     Close();
 }