コード例 #1
0
 /// <summary>
 /// 执行还原
 /// </summary>
 private void RestoreThread()
 {
     if (DataOperateBLL.RestoreDB(dbName, path, serverIp, "sa", "sa", pBarDB))
     {
         MessageBox.Show("还原成功");
     }
     RunState(0);
 }
コード例 #2
0
 /// <summary>
 /// 执行备份
 /// </summary>
 private void BackupThread()
 {
     if (DataOperateBLL.BackUPDB(dbName, path, serverIp, "sa", "sa", pBarDB))
     {
         string p = txtPath.Text;
         p = p.Length > 24 ? (p.Substring(0, 24) + "...") : p;
         lblBackupPath.Text = p;
         lblFileName.Text   = "文件名为 " + txtPath.Tag.ToString();
         if (MessageBox.Show(@"您已经成功将数据库备份到" + "\r\n" + p + "\r\n文件名为 " + txtPath.Tag.ToString() + "\r\n是否打开文件夹",
                             "提示信息", MessageBoxButtons.YesNo) == DialogResult.Yes)
         {
             System.Diagnostics.Process.Start("explorer.exe", "/select," + txtPath.Text + "\\" + txtPath.Tag.ToString());
         }
     }
     RunState(0);
 }
コード例 #3
0
        private void btnRevert_Click(object sender, EventArgs e)
        {
            #region [ 浏览选择文件 ]

            OpenFileDialog o = new OpenFileDialog();
            o.InitialDirectory = @"D:\database\backup"; // 默认路径为默认备份路径
            if (o.ShowDialog() == DialogResult.OK)
            {
                txtFile.Text = o.FileName;
            }
            else
            {
                return;
            }

            #endregion

            #region [ 还原数据库存在时是否先备份 ]

            // 数据库存在时提示是备份否强制还原
            ArrayList array = DataOperateBLL.GetDbList(serverIp, "sa", "sa");
            foreach (object obj in array)
            {
                if (obj.ToString().ToLower() == dbName.ToLower())
                {
                    DialogResult msgType = MessageBox.Show("数据库 ["
                                                           + dbName
                                                           + "] 已存在,还原前是否先备份", "提示信息", MessageBoxButtons.YesNoCancel);
                    // 备份
                    if (msgType == DialogResult.Yes)
                    {
                        // 备份前选择文件夹
                        FolderBrowserDialog s = new FolderBrowserDialog();
                        if (s.ShowDialog() == DialogResult.OK)
                        {
                            txtPath.Text = s.SelectedPath;
                        }
                        else
                        {
                            return;
                        }

                        // 备份
                        btnBackup_Click(sender, e);
                        return;
                    }// 取消还原
                    else if (msgType == DialogResult.Cancel)
                    {
                        lblInfo.Visible = false;
                        return;
                    }
                }
            }

            #endregion

            // 还原文件路径及文件名
            path = txtFile.Text;

            // 还原时界面效果
            RunState(2);
            DisplayBarValue();              // 显示进度百分比
            // 创建线程执行还原
            myThread = new Thread(RestoreThread);
            myThread.Start();

            //存入日志
            LogSave.Messages("[FrmDataManage]", LogIDType.UserLogID, "还原数据库,还原文件路径及文件名为:" + path);
        }