v1.2.10
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Sarand.Net.Standard.Base.App;
|
||||
using Sarand.Net.Standard.Base.Core;
|
||||
using Sarand.Net.Standard.Base.Utils;
|
||||
using Saxonite.Net.Standard.Base.App;
|
||||
@@ -17,7 +18,7 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
|
||||
//---------------------------------------------------------------
|
||||
// Construction.
|
||||
public SaxAppConfig (String context, ConfigurationSection configSection, SaxAppConfig defaultConfig)
|
||||
public SaxAppConfig(String context, ConfigurationSection configSection, SaxAppConfig defaultConfig)
|
||||
{
|
||||
Context = context;
|
||||
populateDefaults(defaultConfig);
|
||||
@@ -99,7 +100,7 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
Logging.RootFolder = StringUtil.OnEmpty(logging["RootFolder"], Logging.RootFolder);
|
||||
}
|
||||
// Database.
|
||||
extractDatabaseConfig(CoreDatabase, configSection.GetSection("CoreDatabase"));
|
||||
extractDatabasesConfig(Databases, configSection.GetSection("Databases"));
|
||||
// Variants.
|
||||
foreach (ConfigurationSection variantSection in configSection.GetSection("Variants").GetChildren())
|
||||
{
|
||||
@@ -121,12 +122,28 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
foreach (var addressBcc in emailSection.GetSection("AddressesBcc").GetChildren())
|
||||
config.AddressesBcc.Add(StringUtil.TrimAll(addressBcc.Value));
|
||||
}
|
||||
private void extractDatabaseConfig(DatabaseConfig database, IConfigurationSection databaseSection)
|
||||
private void extractDatabasesConfig(DatabasesConfig databases, IConfigurationSection databasesSection)
|
||||
{
|
||||
if (!databasesSection.Exists()) return;
|
||||
// 'Database' section contains a separate named configuration for each database: 'Core', 'Support' etc.
|
||||
foreach (var databaseSection in databasesSection.GetChildren())
|
||||
extractDatabaseConfig(databases, databaseSection);
|
||||
}
|
||||
private void extractDatabaseConfig(DatabasesConfig databases, IConfigurationSection databaseSection)
|
||||
{
|
||||
if (!databaseSection.Exists()) return;
|
||||
Sax.Database databaseType = EnumUtil.ParseEnum<Sax.Database>(databaseSection.Key);
|
||||
if (databaseType <= 0)
|
||||
{
|
||||
SaLogger.Warn(GetType().Name + ".extractDatabaseConfig Unrecognised database: " + databaseSection.Key);
|
||||
return;
|
||||
}
|
||||
// Extract database configuration.
|
||||
DatabaseConfig database = new DatabaseConfig();
|
||||
database.Location = StringUtil.OnEmpty(databaseSection["Location"], database.Location);
|
||||
database.User = StringUtil.OnEmpty(databaseSection["User"], database.User);
|
||||
database.Password = StringUtil.OnEmpty(databaseSection["Password"], database.Password);
|
||||
databases.Databases.Add(databaseType, database);
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------
|
||||
@@ -200,7 +217,13 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
public String User { get; internal set; }
|
||||
public String Password { get; internal set; }
|
||||
}
|
||||
public DatabaseConfig CoreDatabase { get; } = new DatabaseConfig();
|
||||
public class DatabasesConfig
|
||||
{
|
||||
public Dictionary<Sax.Database, DatabaseConfig> Databases { get; } = new Dictionary<Sax.Database, DatabaseConfig>();
|
||||
public DatabaseConfig Core { get { return Databases.GetValue(Sax.Database.Core, new DatabaseConfig()); } }
|
||||
public DatabaseConfig Support { get { return Databases.GetValue(Sax.Database.Support, new DatabaseConfig()); } }
|
||||
}
|
||||
public DatabasesConfig Databases { get; } = new DatabasesConfig();
|
||||
// Documents.
|
||||
public class DocumentsConfig
|
||||
{
|
||||
|
||||
@@ -23,6 +23,18 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
// Data members.
|
||||
protected Sax.InstanceType instanceType;
|
||||
protected String environmentName = "";
|
||||
// Session context.
|
||||
protected class SessionContextData_Web
|
||||
{
|
||||
public SessionContextData_Web(SaxSessionContext_Web sessionContext)
|
||||
{
|
||||
SessionContext = sessionContext;
|
||||
}
|
||||
public SaxSessionContext_Web SessionContext { get; }
|
||||
public Dictionary<Sax.Database, ISacsDatabase> Databases { get; } = new Dictionary<Sax.Database, ISacsDatabase>();
|
||||
public ISacsDatabase CoreDatabase { get { return Databases.GetValue(Sax.Database.Core, null); } }
|
||||
public ISacsDatabase SupportDatabase { get { return Databases.GetValue(Sax.Database.Support, null); } }
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Protected construction.
|
||||
@@ -47,7 +59,7 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
public abstract SaxAppConfig AppConfig { get; }
|
||||
public override SaxConsoleHelper ConsoleHelper { get { return ConsoleHelper_Web; } }
|
||||
public SaxConsoleHelper_Web ConsoleHelper_Web { get; protected set; }
|
||||
public override IDatabaseInfo CreateCoreDbInfo(SaxSessionContext sessionContext) { return new DbDataItem.DatabaseInfo(GetCoreDatabase(sessionContext)); }
|
||||
public override IDatabaseInfo CreateDbInfo(SaxSessionContext sessionContext, Sax.Database databaseType) { return new DbDataItem.DatabaseInfo(GetDatabase(sessionContext, databaseType)); }
|
||||
// Configuration.
|
||||
public IConfiguration Configuration { get; protected set; }
|
||||
public IConfiguration SaxConfiguration { get; protected set; }
|
||||
@@ -63,7 +75,10 @@ namespace Saxonite.Net.Core.Web.Base.App
|
||||
applicationParams.Add("Instance", InstanceType.ToString() + (!StringUtil.IsEmpty(AppConfig.Instance) ? " [" + AppConfig.Instance + "]" : ""));
|
||||
applicationParams.Add("Configuration", SaxSystem.DebugMode ? "Debug" : "Release");
|
||||
applicationParams.Add("Environment", EnvironmentName);
|
||||
applicationParams.Add("Database", AppConfig.CoreDatabase.Location);
|
||||
if (!StringUtil.IsBlank(AppConfig.Databases.Core.Location))
|
||||
applicationParams.Add("Database - Core", AppConfig.Databases.Core.Location);
|
||||
if (!StringUtil.IsBlank(AppConfig.Databases.Support.Location))
|
||||
applicationParams.Add("Database - Support", AppConfig.Databases.Support.Location);
|
||||
applicationParams.Add("Application root", SaxSystem.ApplicationFolder);
|
||||
if (!StringUtil.IsEmpty(AppConfig.Documents.RootFolder))
|
||||
applicationParams.Add("Documents root", AppConfig.Documents.RootFolder);
|
||||
|
||||
@@ -86,7 +86,7 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
|
||||
// Query the Activity Index.
|
||||
// NB An item may have multiple index entries but these wil only differe by Sport and/or Region.
|
||||
// User, Organisation Effective & Expiry dates wil be the same for all entries for an item.
|
||||
ISacsDatabase db = SaxGlobals.App.GetCoreDatabase(SessionContext);
|
||||
ISacsDatabase db = SaxGlobals.App.GetDatabase(SessionContext, Sax.Database.Core);
|
||||
DbQuery query = new DbQuery(db.DbmsType);
|
||||
query.Tables.Add(SaxDbDfn_Core.GetTableName(SaxDbDfn_Core.TableIdx.ActivityIndex, false), alias_ActivityIndex);
|
||||
query.Columns.Add(SaxDbDfn_Core.GetColumnNameQual(SaxDbDfn_Core.ColumnIdx.ActivityIndex_ItemType, alias_ActivityIndex), colItemType.DataName);
|
||||
@@ -479,7 +479,7 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
|
||||
String filter =
|
||||
SaxDbDfn_Core.GetColumnName(SaxDbDfn_Core.ColumnIdx.ActivityIndex_ItemType) + "=" + itemId.Type +
|
||||
" And " + SaxDbDfn_Core.GetColumnName(SaxDbDfn_Core.ColumnIdx.ActivityIndex_ItemId) + "=" + itemId.Id.ToLong();
|
||||
ISacsDatabase db = SaxGlobals.App.GetCoreDatabase(SessionContext);
|
||||
ISacsDatabase db = CoreDatabase;
|
||||
int recordsDeleted = db.ExecuteDelete(tableName, filter);
|
||||
if (recordsDeleted > 0)
|
||||
SaLogger.Info(fn + " Records deleted: " + recordsDeleted + ". Filter: " + filter, true);
|
||||
@@ -529,7 +529,7 @@ namespace Saxonite.Net.Core.Web.Base.Consoles
|
||||
};
|
||||
String sql = query.Concat("\n");
|
||||
//SaLogger.Debug(fn + " Query:\n" + sql);
|
||||
ISacsDatabase db = SaxGlobals.App.GetCoreDatabase(SessionContext);
|
||||
ISacsDatabase db = CoreDatabase;
|
||||
int rows = db.ExecuteNonQuery(sql);
|
||||
if (db.HasErrorState())
|
||||
SaLogger.Debug(fn + " Database error: " + db.ErrorStateMessage);
|
||||
|
||||
@@ -164,8 +164,8 @@ namespace Saxonite.Net.Core.Web.Base.Models
|
||||
}
|
||||
}
|
||||
// Additional includes.
|
||||
public List<String> AdditionalFiles_CSS { get; set; } = new List<string>();
|
||||
public List<String> AdditionalFiles_JS { get; set; } = new List<string>();
|
||||
public HashSet<String> AdditionalFiles_CSS { get; set; } = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
public HashSet<String> AdditionalFiles_JS { get; set; } = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
//-------------------------------------------------------------------
|
||||
// Redirection locations.
|
||||
|
||||
Reference in New Issue
Block a user