Addition of global business settings for static server use (equivalent of v7 Global object)
This commit is contained in:
@@ -442,6 +442,10 @@ namespace AyaNova
|
||||
//Initialize license
|
||||
AyaNova.Core.License.InitializeAsync(apiServerState, dbContext, _newLog).Wait();
|
||||
|
||||
//Set static global biz settings
|
||||
_newLog.LogDebug("BOOT: init global settings");
|
||||
ServerGlobalBizSettings.Initialize(null, dbContext);
|
||||
|
||||
//Ensure translations are present, not missing any keys and that there is a server default translation that exists
|
||||
TranslationBiz lb = new TranslationBiz(dbContext, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.OpsAdminFull);
|
||||
lb.ValidateTranslationsAsync().Wait();
|
||||
|
||||
@@ -5,6 +5,7 @@ namespace AyaNova.Models
|
||||
{
|
||||
public partial class AyContext : DbContext
|
||||
{
|
||||
public virtual DbSet<GlobalBizSettings> GlobalBizSettings { get; set; }
|
||||
public virtual DbSet<Event> Event { get; set; }
|
||||
public virtual DbSet<SearchDictionary> SearchDictionary { get; set; }
|
||||
public virtual DbSet<SearchKey> SearchKey { get; set; }
|
||||
@@ -20,8 +21,8 @@ namespace AyaNova.Models
|
||||
public virtual DbSet<DataListView> DataListView { get; set; }
|
||||
public virtual DbSet<Tag> Tag { get; set; }
|
||||
public virtual DbSet<FormCustom> FormCustom { get; set; }
|
||||
public virtual DbSet<PickListTemplate> PickListTemplate { get; set; }
|
||||
|
||||
public virtual DbSet<PickListTemplate> PickListTemplate { get; set; }
|
||||
|
||||
|
||||
//Note: had to add this constructor to work with the code in startup.cs that gets the connection string from the appsettings.json file
|
||||
//and commented out the above on configuring
|
||||
|
||||
22
server/AyaNova/models/GlobalBizSettings.cs
Normal file
22
server/AyaNova/models/GlobalBizSettings.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Newtonsoft.Json;
|
||||
namespace AyaNova.Models
|
||||
{
|
||||
|
||||
public partial class GlobalBizSettings
|
||||
{
|
||||
public long Id { get; set; }//this is always 1 as there is only ever one single global biz object
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
//Global settings
|
||||
//Picklist and other searches override the normal case insensitive value
|
||||
//this is precautionarily added for non latinate languages where it could be an issue
|
||||
public bool SearchCaseSensitiveOnly {get;set;}
|
||||
|
||||
public GlobalBizSettings()
|
||||
{
|
||||
Id=1;//always 1
|
||||
SearchCaseSensitiveOnly = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,8 +22,8 @@ namespace AyaNova.Util
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||
private const int DESIRED_SCHEMA_LEVEL = 10;
|
||||
|
||||
internal const long EXPECTED_COLUMN_COUNT = 100;
|
||||
internal const long EXPECTED_INDEX_COUNT = 27;
|
||||
internal const long EXPECTED_COLUMN_COUNT = 102;
|
||||
internal const long EXPECTED_INDEX_COUNT = 28;
|
||||
|
||||
//!!!!WARNING: BE SURE TO UPDATE THE DbUtil::EmptyBizDataFromDatabaseForSeedingOrImporting WHEN NEW TABLES ADDED!!!!
|
||||
|
||||
@@ -138,6 +138,10 @@ namespace AyaNova.Util
|
||||
{
|
||||
LogUpdateMessage(log);
|
||||
|
||||
//create global biz settings table
|
||||
await ExecQueryAsync("CREATE TABLE aglobalbizsettings (id integer NOT NULL PRIMARY KEY, " +
|
||||
"searchcasesensitiveonly bool default false)");
|
||||
|
||||
//create aevent biz event log table
|
||||
await ExecQueryAsync("CREATE TABLE aevent (id BIGSERIAL PRIMARY KEY, created timestamp not null, userid bigint not null," +
|
||||
"ayid bigint not null, aytype integer not null, ayevent integer not null, textra varchar(255))");
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
||||
47
server/AyaNova/util/ServerGlobalBizSettings.cs
Normal file
47
server/AyaNova/util/ServerGlobalBizSettings.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
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 ServerGlobalBizSettings
|
||||
{
|
||||
|
||||
internal static bool SearchCaseSensitiveOnly { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Populate and / or create the settings
|
||||
/// </summary>
|
||||
internal static void Initialize(GlobalBizSettings global, AyContext ct = null)
|
||||
{
|
||||
|
||||
if (global == null)
|
||||
{
|
||||
//fetch or create as not provided (meaning this was called from Startup.cs)
|
||||
global = ct.GlobalBizSettings.FirstOrDefault(m => m.Id == 1);
|
||||
if (global == null)
|
||||
{
|
||||
global = new GlobalBizSettings();
|
||||
ct.GlobalBizSettings.Add(global);
|
||||
ct.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
SearchCaseSensitiveOnly = global.SearchCaseSensitiveOnly;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}//eoc
|
||||
}//eons
|
||||
Reference in New Issue
Block a user