37 lines
1.1 KiB
C#
37 lines
1.1 KiB
C#
using System;
|
|
using System.Linq;
|
|
using AyaNova.Models;
|
|
|
|
namespace AyaNova.Util
|
|
{
|
|
|
|
/// <summary>
|
|
/// Contains static mirror copy in memory of Operations related settings stored in db
|
|
/// that are accessed frequently by server
|
|
/// </summary>
|
|
internal static class ServerGlobalOpsSettingsCache
|
|
{
|
|
|
|
internal static GlobalOpsBackupSettings Backup { get; set; }
|
|
// internal static DateTime LastBackup { get; set; }
|
|
|
|
|
|
/// <summary>
|
|
/// Populate and / or create the settings
|
|
/// </summary>
|
|
internal static void Initialize(AyContext ct = null)
|
|
{
|
|
//fetch or create as not provided (meaning this was called from Startup.cs)
|
|
Backup = ct.GlobalOpsBackupSettings.FirstOrDefault(z => z.Id == 1);
|
|
if (Backup == null)
|
|
{
|
|
Backup = new GlobalOpsBackupSettings();
|
|
ct.GlobalOpsBackupSettings.Add(Backup);
|
|
ct.SaveChanges();
|
|
}
|
|
Backup.LastBackup=FileUtil.MostRecentBackupFileDate();
|
|
}
|
|
|
|
|
|
}//eoc
|
|
}//eons |