[HttpGet]
public bool BackupDB()
{
bool a = false;
SqlConnection conn = new SqlConnection(DbHelper.ConnectionString);
SqlCommand cmdBK = new SqlCommand();
cmdBK.CommandType = CommandType.Text;
cmdBK.Connection = conn;
cmdBK.CommandText = @"backup database DB_QA_TZ to disk='F:\DataBase\DB_QA_TZ.bak'";
try
{
conn.Open();
cmdBK.ExecuteNonQuery();
a = true;
}
catch (Exception ex)
{
}
finally
{
conn.Close();
conn.Dispose();
}
return a;
}
[HttpGet]
public bool RecoveryDB()
{
HttpContext context = HttpContext.Current;
var path = context.Request.QueryString["path"].ToString();
var UserName = context.Request.QueryString["UserName"].ToString();
bool b = false;
SqlConnection conn = new SqlConnection(DbHelper.ConnectionString);
conn.Open();
SqlCommand cmdRT = new SqlCommand();
cmdRT.CommandType = CommandType.Text;
cmdRT.Connection = conn;
cmdRT.CommandText = @"restore database DB_QA_TZ from disk='" + path + "' WITH REPLACE";
try
{
cmdRT.ExecuteNonQuery();
b = true;
}
catch (Exception ex)
{
}
finally
{
conn.Close();
}
return b;
}