Example #1
0
        private void button_Click(object sender, EventArgs e)
        {
            if((this.connectForm.getConnection) || (this.connectForm.getConnection2))
            {
                //MessageBox.Show(local_path.ToString());

                // get number of selected databases from checklistBox
                int selectedDbNum = DatabasesCheckedListBox.CheckedItems.Count;

                //array with selected databases number length, for store all selected databases
                string[] dbForBackup = new string[selectedDbNum];
                //get names of selected databases
                int i = 0;
                foreach (object itemChecked in DatabasesCheckedListBox.CheckedItems)
                {
                    dbForBackup[i] = itemChecked.ToString();
                    i++;
                }

                // check if upload to ftp is checked and initialize the backupDB object with suitable constructor
                if (cbUploadFtp.Checked)
                {
                    if (connectForm.getConnection)
                    {
                        uploadToFTP = true;
                        backupDB = new BackupDb(connectForm.getHostname, connectForm.getUsername, connectForm.getPassword, dbForBackup, local_path, ftpHost, ftpUsername, ftpPassword);
                    }
                    else
                    {
                        uploadToFTP = true;
                        backupDB = new BackupDb(connectForm.getHostname2, connectForm.getUsername2, connectForm.getPassword2, dbForBackup, local_path, ftpHost, ftpUsername, ftpPassword);
                    }
                }
                else
                {
                    if (connectForm.getConnection)
                    {
                        uploadToFTP = false;
                        backupDB = new BackupDb(connectForm.getHostname, connectForm.getUsername, connectForm.getPassword, dbForBackup, local_path);
                    }
                    else
                    {
                        uploadToFTP = false;
                        backupDB = new BackupDb(connectForm.getHostname, connectForm.getUsername, connectForm.getPassword, dbForBackup, local_path);
                    }
                }
                //check the response of backupdb() method, if true successed, else failed
                response = backupDB.downloadDb();
                MessageBox.Show(response);

                if (response.Equals("Backup completed successfully!"))
                {
                    success = true;

                }

                if(success)
                {

                    if (emailnotcheckBox.Checked)
                    {
                        mail = new SendEmail(emailtextBox.Text,response);
                        mail.PrepareEmail();
                        mail.setEmail();
                    }

                    form3 = new Form3(this);
                    form3.Visible = true;
                }
            }
        }
Example #2
0
        private void button_Click(object sender, EventArgs e)
        {
            if ((this.connectForm.getConnection) || (this.connectForm.getConnection2))
            {
                //MessageBox.Show(local_path.ToString());

                // get number of selected databases from checklistBox
                int selectedDbNum = DatabasesCheckedListBox.CheckedItems.Count;

                //array with selected databases number length, for store all selected databases
                string[] dbForBackup = new string[selectedDbNum];
                //get names of selected databases
                int i = 0;
                foreach (object itemChecked in DatabasesCheckedListBox.CheckedItems)
                {
                    dbForBackup[i] = itemChecked.ToString();
                    i++;
                }

                // check if upload to ftp is checked and initialize the backupDB object with suitable constructor
                if (cbUploadFtp.Checked)
                {
                    if (connectForm.getConnection)
                    {
                        uploadToFTP = true;
                        backupDB    = new BackupDb(connectForm.getHostname, connectForm.getUsername, connectForm.getPassword, dbForBackup, local_path, ftpHost, ftpUsername, ftpPassword);
                    }
                    else
                    {
                        uploadToFTP = true;
                        backupDB    = new BackupDb(connectForm.getHostname2, connectForm.getUsername2, connectForm.getPassword2, dbForBackup, local_path, ftpHost, ftpUsername, ftpPassword);
                    }
                }
                else
                {
                    if (connectForm.getConnection)
                    {
                        uploadToFTP = false;
                        backupDB    = new BackupDb(connectForm.getHostname, connectForm.getUsername, connectForm.getPassword, dbForBackup, local_path);
                    }
                    else
                    {
                        uploadToFTP = false;
                        backupDB    = new BackupDb(connectForm.getHostname, connectForm.getUsername, connectForm.getPassword, dbForBackup, local_path);
                    }
                }
                //check the response of backupdb() method, if true successed, else failed
                response = backupDB.downloadDb();
                MessageBox.Show(response);

                if (response.Equals("Backup completed successfully!"))
                {
                    success = true;
                }

                if (success)
                {
                    if (emailnotcheckBox.Checked)
                    {
                        mail = new SendEmail(emailtextBox.Text, response);
                        mail.PrepareEmail();
                        mail.setEmail();
                    }

                    form3         = new Form3(this);
                    form3.Visible = true;
                }
            }
        }