This commit is contained in:
2020-05-23 13:51:58 +00:00
parent 6f7f162de4
commit ff3946b2b0
4 changed files with 46 additions and 21 deletions

View File

@@ -13,7 +13,7 @@ namespace AyaNova.Util
{
internal static GlobalOpsBackupSettings Backup { get; set; }
// internal static DateTime LastBackup { get; set; }
internal static DateTime NextBackup { get; set; }
/// <summary>
@@ -28,8 +28,27 @@ namespace AyaNova.Util
Backup = new GlobalOpsBackupSettings();
ct.GlobalOpsBackupSettings.Add(Backup);
ct.SaveChanges();
}
Backup.LastBackup=FileUtil.MostRecentBackupFileDate();
}
Backup.LastBackup=FileUtil.MostRecentAutomatedBackupFileDate();
SetNextBackup();
}
internal static void SetNextBackup()
{
//If backup at 6pm and come here need to check if should add day
DateTime utcNow = DateTime.UtcNow;
//Has last backup run more than 24 hours ago?
if (NextBackup < utcNow.AddHours(-24))
{
//set it to today then
NextBackup = new DateTime(utcNow.Year, utcNow.Month, utcNow.Day, Backup.BackupTime.Hour, Backup.BackupTime.Minute, 0, DateTimeKind.Utc);
}
else
{
//less than 24 hours, set it to tomorrow
NextBackup = new DateTime(utcNow.Year, utcNow.Month, utcNow.Day+1, Backup.BackupTime.Hour, Backup.BackupTime.Minute, 0, DateTimeKind.Utc);
}
}