Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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]);
     }
 }
Exemplo n.º 3
0
        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;
        }
Exemplo n.º 4
0
        public override bool isGoOutOfLimit(BackUpInfo backUp, int i)
        {
            if (backUp.listOfRestorePoints[i].creationTime > maxData)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 5
0
 public override bool isGoOutOfLimit(BackUpInfo backUp, int i)
 {
     if (backUp.BackupSize > maxBackupSize)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 6
0
 public override bool isGoOutOfLimit(BackUpInfo backUp, int i)
 {
     if (backUp.listOfRestorePoints.Count > maxRestorePointsCount)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 7
0
        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);
        }
Exemplo n.º 8
0
        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();
                }
            }
        }
Exemplo n.º 9
0
        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);
        }
Exemplo n.º 10
0
        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);
            }
        }
Exemplo n.º 11
0
 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++;
         }
     }
 }
Exemplo n.º 12
0
        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);
        }
Exemplo n.º 13
0
 public abstract bool isGoOutOfLimit(BackUpInfo backUp, int i);
Exemplo n.º 14
0
 public RestorePoint(int id, BackUpInfo backUpInfo)
 {
 }
Exemplo n.º 15
0
 public virtual void Save(BackUpInfo backUp)
 {
 }
Exemplo n.º 16
0
 public override int AmountOfCleaning(BackUpInfo backUp)
 {
     throw new Exception("Error! Invalid operation");
 }
Exemplo n.º 17
0
 public override bool isGoOutOfLimit(BackUpInfo backUp, int i)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 18
0
 public abstract void Clean(BackUpInfo backUp);
Exemplo n.º 19
0
 public abstract int AmountOfCleaning(BackUpInfo backUp);
Exemplo n.º 20
0
 public override int AmountOfCleaning(BackUpInfo backUp)
 {
     return(backUp.listOfRestorePoints.Count - maxRestorePointsCount);
 }