Esempio n. 1
0
        public bool Go(string backupName)
        {
            try
            {
                ZipTools.CreateZipFile(backupName, TempPath, null);
                if (File.Exists(Path.Combine(TempPath, backupName)))
                {
                    File.Delete(Path.Combine(TempPath, backupName));
                }

                var zipName = backupName.Replace(".sql", ".zip");
                NewFileName = zipName;

                if (File.Exists(Path.Combine(TempPath, zipName)))
                {
                    File.Move(Path.Combine(TempPath, zipName), Path.Combine(BackupPath, zipName));
                }

                return(true);
            }
            catch (Exception ex)
            {
                //TODO - ILogger
                return(false);
            }
        }
        public string CreateSingle(int i, DateTime dt, string backupPath, bool deleteSqlFile = true)
        {
            var sqlFile = dt.ToString("yyyyMMdd") + "_dummy" + ".sql";
            var path    = backupPath + sqlFile;

            File.WriteAllText(path, i.ToString());

            ZipTools.CreateZipFile(sqlFile, backupPath, null);

            if (deleteSqlFile)
            {
                File.Delete(Path.Combine(path));
            }

            File.SetLastWriteTime(
                path.Replace(".sql", ".zip"),
                dt);

            return(sqlFile);
        }