public override void Clean(BackUpInfo backUp) { if (backUp.BackupSize > maxBackupSize) { int i = 0; while (backUp.BackupSize > maxBackupSize && i < backUp.listOfRestorePoints.Count) { if (backUp.listOfRestorePoints[i] is IncrementalRestorePoint) { IncrementalRestorePoint tmp = (IncrementalRestorePoint)backUp.listOfRestorePoints[i]; if (tmp.id == tmp.deltaPointId) { throw new Exception("Error! You can't delete this restore point"); } } else { backUp.BackupSize -= backUp.listOfRestorePoints[i].size; backUp.listOfRestorePoints.RemoveAt(i); } i += 1; } } backUp.saveAlgo.Save(backUp); }
public void RemoveByIndex(BackUpInfo backUp) { for (int i = indexesToRemove.Count - 1; i >= 0; i--) { backUp.BackupSize -= backUp.listOfRestorePoints[i].size; backUp.listOfRestorePoints.RemoveAt(indexesToRemove[i]); } }
public IncrementalRestorePoint(int id, int prevPointId, BackUpInfo backUpInfo) : base(id, backUpInfo) { this.prevPointId = prevPointId; creationTime = DateTime.Now; this.id = id; restoreFiles = new List <FileRestoreCopyInfo>(); size = 0; }
public override bool isGoOutOfLimit(BackUpInfo backUp, int i) { if (backUp.listOfRestorePoints[i].creationTime > maxData) { return(true); } return(false); }
public override bool isGoOutOfLimit(BackUpInfo backUp, int i) { if (backUp.BackupSize > maxBackupSize) { return(true); } else { return(false); } }
public override bool isGoOutOfLimit(BackUpInfo backUp, int i) { if (backUp.listOfRestorePoints.Count > maxRestorePointsCount) { return(true); } else { return(false); } }
public override int AmountOfCleaning(BackUpInfo backUp) { int cnt = 0; for (int i = 0; i < backUp.listOfRestorePoints.Count; i++) { if (backUp.listOfRestorePoints[i].creationTime > maxData) { cnt += 1; } } return(cnt); }
public override void Save(BackUpInfo backUp) { string filePath = @"/Users/ekaterinacerednicenko/VisualStudioProjects/Project4.1/Project4.1/Data"; using (StreamWriter sv = new StreamWriter(filePath + "/" + backUp.Id.ToString() + ".txt", false)) { foreach (var restorePoint in backUp.listOfRestorePoints) { sv.WriteLine("Restore point ID: " + restorePoint.id); foreach (var restoreFile in restorePoint.restoreFiles) { sv.WriteLine(restoreFile.FilePath + " added to restore point. Creation time: " + restoreFile.CreationTime + ". Backup size is " + restoreFile.FileSize.ToString()); } sv.WriteLine(); } } }
public int CountOfLimits(BackUpInfo backUp, int index, CleaningByAmount cleaningByAmount, CleaningByDate cleaningByDate, CleaningBySize cleaningBySize) { int cnt = 0; if (isCleaningByAmount && cleaningByAmount.isGoOutOfLimit(backUp, index)) { cnt++; } if (isCleaningByDate && cleaningByDate.isGoOutOfLimit(backUp, index)) { cnt++; } if (isCleaningBySize && cleaningBySize.isGoOutOfLimit(backUp, index)) { cnt++; } return(cnt); }
public override int AmountOfCleaning(BackUpInfo backUp) { int cnt = 0; if (backUp.BackupSize > maxBackupSize) { int i = 0; int currentBackupSize = backUp.BackupSize; while (currentBackupSize > maxBackupSize && i < backUp.listOfRestorePoints.Count) { currentBackupSize -= backUp.listOfRestorePoints[i].size; cnt += 1; } return(cnt); } else { return(cnt); } }
public FullRestorePoint(int id, BackUpInfo backUpInfo) : base(id, backUpInfo) { creationTime = DateTime.Now; this.id = id; restoreFiles = new List <FileRestoreCopyInfo>(); size = 0; if (backUpInfo.listOfRestorePoints.Count != 0) { int i = 0; foreach (var oldRestorePOints in backUpInfo.listOfRestorePoints) { if (i == backUpInfo.listOfRestorePoints.Count - 1) { foreach (var restoreFile in oldRestorePOints.restoreFiles) { restoreFiles.Add(restoreFile); size += restoreFile.FileSize; } } i++; } } }
public override void Clean(BackUpInfo backUp) { CleaningByAmount cleaningByAmount = new CleaningByAmount(maxRestorePointsCount); CleaningByDate cleaningByDate = new CleaningByDate(); CleaningBySize cleaningBySize = new CleaningBySize(maxBackupSize); indexesToRemove = new List <int>(); for (int i = 0; i < backUp.listOfRestorePoints.Count; i++) { int currentCnt = CountOfLimits(backUp, i, cleaningByAmount, cleaningByDate, cleaningBySize); if (currentCnt > 0) { if (flag || (!flag && currentCnt == 3)) { if (backUp.listOfRestorePoints[i] is IncrementalRestorePoint) { IncrementalRestorePoint tmp = (IncrementalRestorePoint)backUp.listOfRestorePoints[i]; if (tmp.id == tmp.deltaPointId) { throw new Exception("Error! You can't delete this restore point"); } else { indexesToRemove.Add(i); } } else { indexesToRemove.Add(i); } } } } RemoveByIndex(backUp); backUp.saveAlgo.Save(backUp); }
public abstract bool isGoOutOfLimit(BackUpInfo backUp, int i);
public RestorePoint(int id, BackUpInfo backUpInfo) { }
public virtual void Save(BackUpInfo backUp) { }
public override int AmountOfCleaning(BackUpInfo backUp) { throw new Exception("Error! Invalid operation"); }
public override bool isGoOutOfLimit(BackUpInfo backUp, int i) { throw new NotImplementedException(); }
public abstract void Clean(BackUpInfo backUp);
public abstract int AmountOfCleaning(BackUpInfo backUp);
public override int AmountOfCleaning(BackUpInfo backUp) { return(backUp.listOfRestorePoints.Count - maxRestorePointsCount); }