This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user