Esempio n. 1
0
        // Token: 0x0600027B RID: 635 RVA: 0x00008AA4 File Offset: 0x00006CA4
        public static string BackUpDatabase()
        {
            string mapPath = FPUtils.GetMapPath(WebConfig.WebPath + "backup/datas");

            if (!Directory.Exists(mapPath))
            {
                Directory.CreateDirectory(mapPath);
            }
            DbConfigInfo dbConfig = DbConfigs.GetDbConfig();
            string       str      = dbConfig.dbname + "_" + DateTime.Now.ToString("yyyyMMddHHmmss");

            if (dbConfig.dbtype == FangPage.Data.DbType.SqlServer)
            {
                SQLServer sqlserver = new SQLServerClass();
                sqlserver.Connect(dbConfig.dbpath, dbConfig.userid, dbConfig.password);
                try
                {
                    if (File.Exists(mapPath + "\\" + dbConfig.dbname + ".bak"))
                    {
                        File.Delete(mapPath + "\\" + dbConfig.dbname + ".bak");
                    }
                    ((_Backup) new BackupClass
                    {
                        Action = SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database,
                        Initialize = true,
                        Files = mapPath + "\\" + dbConfig.dbname + ".bak",
                        Database = dbConfig.dbname
                    }).SQLBackup(sqlserver);
                    if (File.Exists(mapPath + "\\" + str + ".config"))
                    {
                        using (FPZip fpzip = new FPZip())
                        {
                            fpzip.AddFile(mapPath + "\\" + dbConfig.dbname + ".bak", dbConfig.dbname + ".bak");
                            fpzip.ZipSave(mapPath + "\\" + str + ".config");
                        }
                        File.Delete(mapPath + "\\" + dbConfig.dbname + ".bak");
                    }
                    return(string.Empty);
                }
                catch (Exception ex)
                {
                    string text = ex.Message.Replace("'", " ");
                    text = text.Replace("\n", " ");
                    return(text.Replace("\\", "/"));
                }
                finally
                {
                    sqlserver.DisConnect();
                }
            }
            string result;

            try
            {
                if (File.Exists(mapPath + "\\" + str + ".config"))
                {
                    File.Delete(mapPath + "\\" + str + ".zip");
                    using (FPZip fpzip = new FPZip())
                    {
                        fpzip.AddFile(WebConfig.WebPath + dbConfig.dbpath, dbConfig.dbpath);
                        fpzip.ZipSave(mapPath + "\\" + str + ".config");
                    }
                }
                result = string.Empty;
            }
            catch (Exception ex)
            {
                string text = ex.Message.Replace("'", " ");
                text   = text.Replace("\n", " ");
                text   = text.Replace("\\", "/");
                result = text;
            }
            return(result);
        }