public AdvancedBackupM(string name = null) : base(name) { this.State = BackupStates.Idle; this.CheckMD5Files = true; this.MD5Files = new Dictionary <string, byte[]>(); FilesSelectorM = new FilesSelectorM(typeof(StringMatchPathFilterM)); SchedulerM = new SchedulerM(intervalloVerificaMs: 10000); }
private BackupCompressionResult StartCompression() { BackupCompressionResult args; bool filesAreChanged = false; try { string fullPath; this.State = BackupStates.FilesToBackupCalculation; FilesSelectorM.CalculateFileList(); if (FilesSelectorM.FilesSelected.Count == 0) { args = new BackupCompressionResult(compressionResult: true, filesAreChanged: filesAreChanged, filesToBackup: 0); this.CompressionEnd?.Invoke(this, args); return(args); } do { string prefix = DateTime.Now.ToString("yy-MM-dd_HH.mm.ss_"); fullPath = System.IO.Path.Combine(this.DestinationFolder, prefix + this.Name); } while (System.IO.File.Exists(fullPath)); this.State = BackupStates.Compressing; if (Zip.Comprimi(FilesSelectorM.FilesSelected.ToList(), fullPath, out this.thrCompression, progressione: this.Progress) == true) { args = new BackupCompressionResult(compressionResult: true, filesAreChanged: filesAreChanged, filesToBackup: FilesSelectorM.FilesSelected.Count); } else { args = new BackupCompressionResult(compressionResult: false, filesAreChanged: filesAreChanged, filesToBackup: FilesSelectorM.FilesSelected.Count); } this.CompressionEnd?.Invoke(this, args); return(args); } catch { args = new BackupCompressionResult(compressionResult: false, filesAreChanged: filesAreChanged, filesToBackup: FilesSelectorM.FilesSelected.Count); this.CompressionEnd?.Invoke(this, args); return(args); } finally { this.State = BackupStates.Idle; this.Progress.Percentage = 0; } }
public SimpleBackupM() { FilesSelectorM = new FilesSelectorM(typeof(StringMatchPathFilterM)); }
private BackupCompressionResult StartCompression() { BackupCompressionResult args; bool filesAreChanged = false; bool compressResult; Dictionary <string, byte[]> newMD5Files = new Dictionary <string, byte[]>(); try { string fullPath; this.State = BackupStates.FilesToBackupCalculation; FilesSelectorM.CalculateFileList(); if (checkMD5Files == true) { this.State = BackupStates.MD5Calculation; CalcMD5Files(out filesAreChanged, out newMD5Files); if (filesAreChanged == false) { //outParam["filesAreChanged"] = filesAreChanged; args = new BackupCompressionResult(compressionResult: true, filesAreChanged: filesAreChanged); this.CompressionEnd?.Invoke(this, args); return(args); } } if (FilesSelectorM.FilesSelected.Count == 0) { args = new BackupCompressionResult(compressionResult: true, filesAreChanged: filesAreChanged, filesToBackup: 0); this.CompressionEnd?.Invoke(this, args); return(args); } do { string prefix = DateTime.Now.ToString("yy-MM-dd_HH.mm.ss_"); fullPath = System.IO.Path.Combine(this.DestinationFolder, prefix + this.Name); } while (System.IO.File.Exists(fullPath)); this.State = BackupStates.Compressing; compressResult = Zip.Comprimi(FilesSelectorM.FilesSelected.ToList(), fullPath, out this.thrCompression, progressione: this.Progress); args = new BackupCompressionResult(compressionResult: compressResult, filesAreChanged: filesAreChanged, filesToBackup: FilesSelectorM.FilesSelected.Count); if (compressResult == true && checkMD5Files == true && filesAreChanged == true) { this.MD5Files = newMD5Files; } this.CompressionEnd?.Invoke(this, args); return(args); } catch { args = new BackupCompressionResult(compressionResult: false, filesAreChanged: filesAreChanged, filesToBackup: FilesSelectorM.FilesSelected.Count); this.CompressionEnd?.Invoke(this, args); return(args); } finally { this.State = BackupStates.Idle; this.Progress.Percentage = 0; } }