Split out backup settings from general ops settings
This commit is contained in:
@@ -228,8 +228,8 @@ FROM index_groups;
|
||||
await ExecQueryAsync("CREATE TABLE aglobalbizsettings (id integer NOT NULL PRIMARY KEY, " +
|
||||
"searchcasesensitiveonly bool default false)");
|
||||
|
||||
//create global ops settings table
|
||||
await ExecQueryAsync("CREATE TABLE aglobalopssettings (id integer NOT NULL PRIMARY KEY, " +
|
||||
//create global ops BACKUP settings table
|
||||
await ExecQueryAsync("CREATE TABLE aglobalopsbackupsettings (id integer NOT NULL PRIMARY KEY, " +
|
||||
"backuptime timestamp, lastbackup timestamp, backupsetstokeep int, backupattachments bool)");
|
||||
|
||||
//create aevent biz event log table
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using AyaNova.Models;
|
||||
|
||||
namespace AyaNova.Util
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Contains static mirror copy in memory of global settings values that are set from DB during boot
|
||||
/// and accessible to Biz admin user (equivalent of v7's global object)
|
||||
/// used by many areas of the biz logic and processing too often to fetch on every request
|
||||
/// set at boot and on any update to the db global biz settings record
|
||||
/// </summary>
|
||||
internal static class ServerGlobalOpsSettings
|
||||
{
|
||||
|
||||
internal static DateTime BackupTime { get; set; }
|
||||
internal static DateTime LastBackup { get; set; }
|
||||
internal static int BackupSetsToKeep { get; set; }
|
||||
internal static bool BackupAttachments { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Populate and / or create the settings
|
||||
/// </summary>
|
||||
internal static void Initialize(GlobalOpsSettings global, AyContext ct = null)
|
||||
{
|
||||
|
||||
if (global == null)
|
||||
{
|
||||
//fetch or create as not provided (meaning this was called from Startup.cs)
|
||||
global = ct.GlobalOpsSettings.FirstOrDefault(z => z.Id == 1);
|
||||
if (global == null)
|
||||
{
|
||||
global = new GlobalOpsSettings();
|
||||
ct.GlobalOpsSettings.Add(global);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
//We have the object, now copy the static values here
|
||||
BackupAttachments = global.BackupAttachments;
|
||||
BackupSetsToKeep = global.BackupSetsToKeep;
|
||||
BackupTime = global.BackupTime;
|
||||
LastBackup = global.LastBackup;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
36
server/AyaNova/util/ServerGlobalOpsSettingsCache.cs
Normal file
36
server/AyaNova/util/ServerGlobalOpsSettingsCache.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
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; }
|
||||
|
||||
|
||||
/// <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.GlobalOpsSettings.FirstOrDefault(z => z.Id == 1);
|
||||
if (Backup == null)
|
||||
{
|
||||
Backup = new GlobalOpsBackupSettings();
|
||||
ct.GlobalOpsSettings.Add(Backup);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user