Пример #1
0
        public bool Create(string currentDirectory, BackupModel model)
        {
            GlobalConfig.Database = model.Database;

            string fullFileInfoPath = $"{currentDirectory}\\{GlobalConfig.BackupAppFileInfo}";

            if (File.Exists(fullFileInfoPath))
            {
                int nextBackup = model.CurrentFile + 1;
                TextProcessor.UpdateCurrentFile(nextBackup, fullFileInfoPath);

                string backupFolder = model.SourceDir + "\\";
                GlobalConfig.Connection.CreateBackup(model.Database, backupFolder);

                _compression.Create(model, GlobalConfig.BackupPassword);

                string filePath = $@"{model.DestinationDir}\{model.Name}_{model.CurrentFile}.{model.CompressionType}";

                if (!_compression.CheckCompressedFile(filePath))
                {
                    throw new Exception("Compressed file corrupted!");
                }

                return(true);
            }
            else
            {
                throw new Exception($"{GlobalConfig.BackupAppFileInfo} file doesn't exist!");
            }
        }