Exemple #1
0
        public bool Backup(BackupSetting setting, ConnectionInfo connectionInfo)
        {
            try
            {
                DbBackup backup = DbBackup.GetInstance(ManagerUtil.GetDatabaseType(setting.DatabaseType));
                backup.Setting        = setting;
                backup.ConnectionInfo = connectionInfo;

                this.FeedbackInfo("Begin to backup...");

                string saveFilePath = backup.Backup();

                if (File.Exists(saveFilePath))
                {
                    this.FeedbackInfo($"Database has been backuped to {saveFilePath}.");
                }
                else
                {
                    this.FeedbackInfo($"Database has been backuped.");
                }

                return(true);
            }
            catch (Exception ex)
            {
                this.FeedbackError(ExceptionHelper.GetExceptionDetails(ex));
            }

            return(false);
        }
        private void btnAddAccount_Click(object sender, EventArgs e)
        {
            string databaseType = this.cboDbType.Text;

            if (string.IsNullOrEmpty(databaseType))
            {
                MessageBox.Show("Please select a database type first.");
            }
            else
            {
                DatabaseType   dbType         = ManagerUtil.GetDatabaseType(databaseType);
                frmAccountInfo frmAccountInfo = new frmAccountInfo(dbType);
                DialogResult   result         = frmAccountInfo.ShowDialog();

                if (result == DialogResult.OK)
                {
                    this.LoadAccounts(frmAccountInfo.AccountProfileId);

                    if (this.cboAccount.SelectedItem != null)
                    {
                        (this.cboAccount.SelectedItem as AccountProfileInfo).Password = frmAccountInfo.AccountProfileInfo.Password;
                    }
                }
            }
        }
        private async void TranslateItem_Click(object sender, EventArgs e)
        {
            DatabaseType dbType = ManagerUtil.GetDatabaseType((sender as ToolStripMenuItem).Text);

            if (!this.IsValidSelectedNode())
            {
                return;
            }

            TreeNode node = this.GetSelectedNode();

            this.tvDbObjects.SelectedNode = node;

            await this.Translate(node, dbType);
        }
        private void Edit()
        {
            AccountProfileInfo profile = this.GetSelectRecord();

            if (profile != null)
            {
                frmAccountInfo frmAccountInfo = new frmAccountInfo(ManagerUtil.GetDatabaseType(this.cboDbType.Text), true)
                {
                    AccountProfileInfo = profile
                };

                if (frmAccountInfo.ShowDialog() == DialogResult.OK)
                {
                    this.LoadAccounts();
                }
            }
        }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            string databaseType = this.cboDbType.Text;

            if (string.IsNullOrEmpty(databaseType))
            {
                MessageBox.Show("Please select a database type first.");
            }
            else
            {
                DatabaseType   dbType         = ManagerUtil.GetDatabaseType(databaseType);
                frmAccountInfo frmAccountInfo = new frmAccountInfo(dbType);
                DialogResult   result         = frmAccountInfo.ShowDialog();

                if (result == DialogResult.OK)
                {
                    this.LoadAccounts();
                }
            }
        }
        private bool SetConnectionInfo(AccountProfileInfo accountProfileInfo)
        {
            DatabaseType dbType = ManagerUtil.GetDatabaseType(this.cboDbType.Text);

            frmAccountInfo frmAccountInfo = new frmAccountInfo(dbType, true)
            {
                AccountProfileInfo = accountProfileInfo
            };

            DialogResult dialogResult = frmAccountInfo.ShowDialog();

            if (dialogResult == DialogResult.OK)
            {
                AccountProfileInfo profileInfo = frmAccountInfo.AccountProfileInfo;
                ObjectHelper.CopyProperties(profileInfo, (this.cboAccount.SelectedItem as AccountProfileInfo));
                this.cboAccount.Text = profileInfo.Description;
                return(true);
            }
            else
            {
                this.btnConnect.Enabled = true;
            }
            return(false);
        }