/// <summary> /// 数据库备份bak文件方式 /// </summary> /// <returns>备份是否成功</returns> private bool DbBackup2005() { string[] path = CreatePath("bak"); DBBackupAndRestore bak = new DBBackupAndRestore(); int isOk = bak.BackupDB(path); if (isOk == 3) { Utils.RunJavaScript(this, "alert({msg:'备份失败,请检查备份目录是否存在并且有读写权限!',title:'提示信息'});"); return(false); } return(true); }
//还原 public void lnkbRestoreDB_Click(object sender, EventArgs e) { //判断是否有还原权限 if (IsHaveRightByOperCode("Restore")) { string sqlBackFiles = Request.Form["chkId"]; DBBackupAndRestore bak = new DBBackupAndRestore(); if (bak.RestoreDB(sqlBackFiles) == true) { WriteLog(GetLogValue("还原数据库成功", "Update", "DataBaseBackUp", true), "", 2); //写日志 Utils.RunJavaScript(this, "alert({msg:'还原数据库成功!',title:'提示信息'})"); } else { Utils.RunJavaScript(this, "alert({msg:'还原失败,可能原因有:<br>1.备份文件已经被删除或者重命名<br>2.数据库账户没有还原数据库的权限,设置权限请浏览<a href=\"javascript:changeMenu(\\'Memo\\');Closed();\" style=color:blue>还原须知</a>!',title:'提示信息'})"); } } }