コード例 #1
0
        /// <summary>
        /// Deletes the old backup files.
        /// </summary>
        private void DeleteOldBackupFiles()
        {
            logHandler = new LogHandler();
            int    days           = ConfigurationXmlHandler.GetDeleteBackupsOlderThanDays();
            string backupLocation = ConfigurationXmlHandler.GetBackupLocation();

            if (days > 0)
            {
                try
                {
                    ProcessDeleteFiles(backupLocation, days + 1); //Add 1 to number of days, since it has to delete files older than the specified number of days
                    logHandler.LogMessage(LogHandler.MessageType.INFO, string.Format("Cleaned up backup files older than {0} days", days));
                }
                catch (Exception ex)
                {
                    logHandler.LogMessage(LogHandler.MessageType.ERROR, string.Format("Error while cleaning up files older than {0} days: {1}", days, ex.ToString()));
                }
            }
        }
コード例 #2
0
 /**
  * Synchronise with the values from the Configuration file.
  */
 private void SyncFromConfiguration()
 {
     this.backupLocation        = ConfigurationXmlHandler.GetBackupLocation();
     this.deleteBackupAfterDays = ConfigurationXmlHandler.GetDeleteBackupsOlderThanDays();
 }
コード例 #3
0
        public void RetrieveDeleteBackupOlderThanDaysTest()
        {
            int days = ConfigurationXmlHandler.GetDeleteBackupsOlderThanDays();

            Assert.AreEqual(7, days);
        }