コード例 #1
0
        private async void button5_Click(object sender, EventArgs e)
        {
            //restore button
            List <bool> enable_states = new List <bool>();

            foreach (Control c in Controls)
            {
                enable_states.Add(c.Enabled);
                c.Enabled = false;
            }

            var cfg = MCv2Persistance.Instance.Config;

            ProgressDialog pgd = new ProgressDialog("Database Restore");

            pgd.Show();
            pgd.SetMarqueeStyle();

            var backup_filename = backups.Keys.ElementAt(dataGridView1.SelectedRows[0].Index);

            pgd.LabelText = "Restoring from " + new FileInfo(backup_filename).Name;

            await DBBackupAndRestore.Restore(backup_filename);

            pgd.Dispose();

            for (int i = 0; i < enable_states.Count; i++)
            {
                Controls[i].Enabled = enable_states[i];
            }
        }
コード例 #2
0
        private async void databaseToolStripMenuItem_Click(object sender, EventArgs e)
        {
            dbconnprop = DatabaseConnectionProperties.FromArray(GetTextBoxStrings());

            MCv2Persistance.Instance.Config.DatabaseConfiguration.DatabaseConnectionProperties = dbconnprop;

            List <string> files_to_import = new List <string>();

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Multiselect      = true;
                ofd.Filter           = "Supported Extentions (*.db2bak)|*.db2bak";
                ofd.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
                ofd.FileName         = "";

                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    files_to_import.AddRange(ofd.FileNames);
                }
            }

            if (files_to_import.Count() == 0)
            {
                return;
            }

            ProgressDialog pgd = new ProgressDialog("Restoring Database");

            pgd.Show();
            pgd.SetMarqueeStyle();

            foreach (var file in files_to_import)
            {
                pgd.LabelText = "Processing " + file;

                try
                {
                    await DBBackupAndRestore.Restore(file, DatabaseConnectionProperties.FromArray(GetTextBoxStrings()));
                }
                catch (Exception ex)
                {
                    MessageBox.Show("An error occured while restoring from " + file + ".");
                }
            }

            pgd.Dispose();
        }