Esempio n. 1
0
        public IActionResult GetBackupList(string db)
        {
            var config = ConfigUtil.GetConfig();
            var path   = AppDomain.CurrentDomain.BaseDirectory + "\\DbBackup\\" + db;

            if (!System.IO.Directory.Exists(path))
            {
                System.IO.Directory.CreateDirectory(path);
            }
            var files = System.IO.Directory.GetFiles(path);
            List <BackupInfo> list = new List <BackupInfo>();

            foreach (var file in files)
            {
                var f          = new FileInfo(file);
                var backupInfo = new BackupInfo()
                {
                    Name     = f.Name,
                    Size     = (Math.Floor(Convert.ToDecimal(f.Length) / 1024)) + "KB",
                    Time     = f.CreationTime.ToString(),
                    Position = config.positiontype
                };
                list.Add(backupInfo);
            }
            return(Json(list));
        }
Esempio n. 2
0
        public static IDb GetDbInstance()
        {
            DbBackupConfig config = ConfigUtil.GetConfig();
            IDb            db     = null;

            if (config.dbtype == DbType.MySql.ToString())
            {
                db = new MySqlDb(config);
            }

            return(db);
        }
Esempio n. 3
0
        public IActionResult BackupManually(string db)
        {
            var config = ConfigUtil.GetConfig();
            var path   = AppDomain.CurrentDomain.BaseDirectory + "DbBackup\\" + db;

            //backup temp file

            //zip
            ZipUtil.Zip(path + "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".sql");

            //remove temp file

            return(Content(""));
        }
Esempio n. 4
0
 public IActionResult GetConfig()
 {
     return(Json(ConfigUtil.GetConfig()));
 }