Пример #1
0
    /// <summary>
    /// 备份数据库
    /// </summary>
    protected void Backup()
    {
        ///设定要备份的数据库名
        string strDataBaseName = DataBackupBLL.GetDataBaseName();

        ///备份数据库
        int backupCount = DataBackupBLL.BackupDatabaseInfo(strDataBaseName, strPathFileName);


        try
        {
            if (backupCount != 0)
            {
                Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("004215", "备份已经成功!")));
                lblMessage.Text = "";
                lblMessage.Text = GetTran("004214", "已经将系统数据库备份为:") + strPathFileName1;// +" 建立的时间为: " + File.GetLastWriteTime(strPathFileName);
                BackupLog();
            }
        }
        catch
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("004213", "备份失败,请联系管理员")));
            return;
        }
    }
Пример #2
0
    /// <summary>
    /// 备份数据库
    /// </summary>
    protected void Backup()
    {
        ///设定要备份的数据库名
        string strDataBaseName = DataBackupBLL.GetDataBaseName();

        ///备份数据库
        int backupCount = DataBackupBLL.BackupDatabaseInfo(strDataBaseName, "D:\\DBBackup\\" + strDataBaseName + ".bak");

        try
        {
            if (backupCount != 0)
            {
                //Process.Start("D:\\DBBackup\\dbcmd.bat"); //调用bat命令文件,将备份的bak数据库文件打包成rar格式的
                //Thread.Sleep(6000); //程序睡眠6秒中

                Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("004215", "备份已经成功!")));
                lblMessage.Text = "";
                lblMessage.Text = GetTran("004214", "已经将系统数据库备份为:") + strDataBaseName + ".bak";// +" 建立的时间为: " + File.GetLastWriteTime(strDataBaseName + ".bak");
                BackupLog(strDataBaseName + ".bak");
            }
        }
        catch
        {
            Page.ClientScript.RegisterStartupScript(GetType(), "", Transforms.ReturnAlert(GetTran("004213", "备份失败,请联系管理员")));
            return;
        }
    }