Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            //accept button
            dbconnprop = DatabaseConnectionProperties.FromArray(GetTextBoxStrings());

            DialogResult = DialogResult.OK;
        }
Beispiel #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();
        }
Beispiel #3
0
        private async Task TestTextBoxValues()
        {
            string[] text_box_strings = GetTextBoxStrings();

            DatabaseConnectionProperties dbconnprop = DatabaseConnectionProperties.FromArray(text_box_strings);

            //if the host name is blank or unreachable
            if (text_box_strings[0] == "")
            {
                if (IsHandleCreated)
                {
                    Invoke((MethodInvoker)(() =>
                    {
                        tbs[0].BackColor = Color.LightSalmon;
                        tbs[1].BackColor = Color.GhostWhite;
                        tbs[2].BackColor = Color.GhostWhite;
                        tbs[3].BackColor = Color.GhostWhite;

                        Refresh();
                    }));
                }

                return;
            }

            if (await TestHostnameOrIP(text_box_strings[0]))
            {
                if (IsHandleCreated)
                {
                    Invoke((MethodInvoker)(() =>
                    {
                        tbs[0].BackColor = Color.LightGreen;
                    }));
                }
            }
            else
            {
                if (IsHandleCreated)
                {
                    Invoke((MethodInvoker)(() =>
                    {
                        tbs[0].BackColor = Color.LightSalmon;
                        tbs[1].BackColor = Color.GhostWhite;
                        tbs[2].BackColor = Color.GhostWhite;
                        tbs[3].BackColor = Color.GhostWhite;

                        Refresh();
                    }));
                }

                return;
            }

            if (text_box_strings[1] == "" || text_box_strings[2] == "" || text_box_strings[2] == "")
            {
                if (IsHandleCreated)
                {
                    Invoke((MethodInvoker)(() =>
                    {
                        tbs[1].BackColor = Color.LightSalmon;
                        tbs[2].BackColor = Color.LightSalmon;
                        tbs[3].BackColor = Color.LightSalmon;

                        Refresh();
                    }));
                }

                return;
            }

            if (await TestDBConnProp(dbconnprop))
            {
                if (IsHandleCreated)
                {
                    Invoke((MethodInvoker)(() =>
                    {
                        tbs[1].BackColor = Color.LightCyan;
                        tbs[2].BackColor = Color.LightCyan;
                        tbs[3].BackColor = Color.LightCyan;

                        button1.Enabled = true;
                        restoreToolStripMenuItem.Enabled = true;
                        saveToolStripMenuItem.Enabled = true;

                        Refresh();
                    }));
                }

                return;
            }
            else
            {
                if (IsHandleCreated)
                {
                    Invoke((MethodInvoker)(() =>
                    {
                        tbs[1].BackColor = Color.LightSalmon;
                        tbs[2].BackColor = Color.LightSalmon;
                        tbs[3].BackColor = Color.LightSalmon;

                        Refresh();
                    }));
                }

                return;
            }
        }