Beispiel #1
0
        // Show restore dialog.
        public void showRestore()
        {
            DialogResult result = MessageBox.Show("You should backup the existing database before restoring as restoring will overwrite the current database." + Environment.NewLine + Environment.NewLine + "Overwriting the current database is irreversible, are you sure you want to continue?", ModuleGeneric.getAppShortName(), MessageBoxButtons.OKCancel);

            if (result == DialogResult.Cancel)
            {
                return;
            }

            restoreDialog.FileName         = ModuleGeneric.DATABASE_NAME;
            restoreDialog.Title            = "Restore Listener Database";
            restoreDialog.Filter           = "SQLite Database Files|*.s3db";
            restoreDialog.CheckPathExists  = true;
            restoreDialog.InitialDirectory = "A:\\";

            // If successful, backup the database.
            if (restoreDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (DBUtils.RestoreDatabase(restoreDialog.FileName, ModuleGeneric.GetDatabasePath()))
                {
                    Interaction.MsgBox("Database restore successful.");
                }
                else
                {
                    Interaction.MsgBox("Error: Database was not restored correctly!");
                }
            }
        }
Beispiel #2
0
        // Show backup dialog.
        public void showBackup()
        {
            backupDialog.FileName         = ModuleGeneric.DATABASE_NAME;
            backupDialog.Title            = "Backup Listener Database";
            backupDialog.Filter           = "SQLite Database Files|*.s3db";
            backupDialog.CheckPathExists  = true;
            backupDialog.InitialDirectory = "A:\\";
            backupDialog.OverwritePrompt  = Settings.Default.OverwritePrompt;

            // If successful, backup the database.
            if (backupDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                if (DBUtils.CopyDatabase(ModuleGeneric.GetDatabasePath(), backupDialog.FileName))
                {
                    Interaction.MsgBox("Database backup successful, please restart app!");
                }
                else
                {
                    Interaction.MsgBox("Error: Database was not copied correctly!");
                }
            }
        }