internal bool IsOverriding(BackupIntervalDefinition backupIntervalDefinition)
        {
            for (int i = 0; i < IntervalList.Count; i++)
            {
                for (int j = i + 1; j < IntervalList.Count; j++)
                {
                    if (IntervalList[i].IsOverriding(IntervalList[j]))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #2
0
        public bool IsOverriding(BackupIntervalDefinition dailyInterval, BackupIntervalDefinition weeklyInterval)
        {
            foreach (var dailyIntervalItem in dailyInterval.IntervalList)
            {
                foreach (var weeklyIntervalItem in weeklyInterval.IntervalList)
                {
                    if (dailyIntervalItem.IsOverriding(weeklyIntervalItem))
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
Example #3
0
        public BackupIntervalDefinition SetInterval(DateTime dateReference,
                                                    BackupIntervalEnum interval,
                                                    int size)
        {
            BackupIntervalDefinition result = new BackupIntervalDefinition()
            {
                IntervalType = interval,
                IntervalList = new List <Interval>()
            };

            for (int i = 0; i < size; i++)
            {
                int dayToAdd = 1;

                if (interval == BackupIntervalEnum.Weekly)
                {
                    dayToAdd = 7;
                }
                else if (interval == BackupIntervalEnum.Monthly)
                {
                    dayToAdd = 30;
                }
                else if (interval == BackupIntervalEnum.Yearly)
                {
                    dayToAdd = 365;
                }

                result.IntervalList.Add(new Interval()
                {
                    Start = dateReference.AddDays(-1 * ((i * dayToAdd) + dayToAdd)),
                    End   = dateReference.AddDays(-1 * (i * dayToAdd)),
                });
            }

            Definition.ItemList.Add(result);

            return(result);
        }