|
|
|
@@ -21,6 +21,7 @@ using Saxonite.Net.Standard.Dbas.App;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Saxonite.Net.Core.Web.Admin.App
|
|
|
|
@@ -99,7 +100,6 @@ namespace Saxonite.Net.Core.Web.Admin.App
|
|
|
|
|
/// <summary>Initialise environment - from internal (above) or unit tests.</summary>
|
|
|
|
|
protected void InitEnvironment(IWebHostEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
String fn = GetType().Name + ".InitEnvironment";
|
|
|
|
|
Development = env.IsDevelopment();
|
|
|
|
|
environmentName = env.EnvironmentName;
|
|
|
|
|
SaLogger.LogFilenamePrefix = "Sax-Web-Adm";
|
|
|
|
@@ -124,6 +124,9 @@ namespace Saxonite.Net.Core.Web.Admin.App
|
|
|
|
|
appConfigs = SaxAppConfigHelper.ExtractAppConfigs(SaxConfiguration.GetSection("AppConfigs"));
|
|
|
|
|
emailConfigs = SaxEmailConfigHelper.ExtractEmailConfigs(SaxConfiguration.GetSection("EmailConfigs"));
|
|
|
|
|
LoggingRootFolder = AppConfig.Logging.RootFolder;
|
|
|
|
|
// Ensure root log folder ends with Admin folder.
|
|
|
|
|
if (!StringUtil.IsBlank(LoggingRootFolder) && !Regex.IsMatch(LoggingRootFolder, "[\\\\/]Admin$", RegexOptions.IgnoreCase))
|
|
|
|
|
LoggingRootFolder = StringUtil.CombineFilePath(LoggingRootFolder, "Admin");
|
|
|
|
|
|
|
|
|
|
// Application instance.
|
|
|
|
|
if (AppConfig.Instance.EqualsCI("Dev")) instanceType = Sax.InstanceType.Dev;
|
|
|
|
@@ -139,7 +142,7 @@ namespace Saxonite.Net.Core.Web.Admin.App
|
|
|
|
|
}
|
|
|
|
|
if (DirectoryUtil.DirectoryExists(LoggingRootFolder))
|
|
|
|
|
SaLogger.LogFolder = LoggingRootFolder;
|
|
|
|
|
LogApplicationStart(fn);
|
|
|
|
|
LogApplicationStart(SysUtil.Fn);
|
|
|
|
|
|
|
|
|
|
//Messages.Add($"Database location: {AppConfig.CoreDatabase.Location}");
|
|
|
|
|
//Messages.Add($"LoggingRootFolder: {SaLogger.LogFolder}");
|
|
|
|
@@ -155,7 +158,7 @@ namespace Saxonite.Net.Core.Web.Admin.App
|
|
|
|
|
}
|
|
|
|
|
catch (Exception exc)
|
|
|
|
|
{
|
|
|
|
|
SaLogger.Error(fn + " " + ExceptionUtil.GetLogMessage(exc));
|
|
|
|
|
SaLogger.Error(SysUtil.Fn + " " + ExceptionUtil.GetLogMessage(exc));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Occasional startup processing.
|
|
|
|
@@ -165,22 +168,6 @@ namespace Saxonite.Net.Core.Web.Admin.App
|
|
|
|
|
populateRegionsFromDataFile(SessionContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void ConfigureDatabaseConnection(SessionContextData_Admin sessionContextData, Sax.Database databaseInstance)
|
|
|
|
|
{
|
|
|
|
|
String fn = GetType().Name + ".ConfigureDatabaseConnection";
|
|
|
|
|
|
|
|
|
|
// Configure database connection.
|
|
|
|
|
SaxAppConfig.DatabaseConfig databaseConfig = AppConfig.Databases.Databases.GetValue(databaseInstance, new SaxAppConfig.DatabaseConfig());
|
|
|
|
|
SacsDatabaseConsole.OdbcConfig config = new SacsDatabaseConsole.OdbcConfig();
|
|
|
|
|
config.location = databaseConfig.Location;
|
|
|
|
|
config.user = databaseConfig.User;
|
|
|
|
|
config.pword = databaseConfig.Password;
|
|
|
|
|
SacsDatabase database = SacsDatabaseConsole.OpenOdbcDatabase(config);
|
|
|
|
|
if (database.HasErrorState())
|
|
|
|
|
SaLogger.Warn(fn + " " + databaseInstance.ToString() + " Database initialisation error: " + database.ErrorStateMessage);
|
|
|
|
|
sessionContextData.Databases.Add(databaseInstance, database);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------
|
|
|
|
|
private void GenerateDatabaseDefinitions(SaxSessionContext sessionContext)
|
|
|
|
|
{
|
|
|
|
@@ -208,7 +195,7 @@ namespace Saxonite.Net.Core.Web.Admin.App
|
|
|
|
|
using (SaxInternals internals = new SaxInternals(sessionContext))
|
|
|
|
|
{
|
|
|
|
|
SaxReferenceMgr referenceMgr = internals.ReferenceMgr;
|
|
|
|
|
String regionsData = SaxResourceHelper.GetTextResource(SaxResourceHelper.TextResource.Data_CountriesWithRegions_Txt);
|
|
|
|
|
String regionsData = SaxResourceHelper.GetResourceText(SaxResourceHelper.TextResource.Data_CountriesWithRegions_Txt);
|
|
|
|
|
String[] regionDataValues = regionsData.Split("\n");
|
|
|
|
|
SysId parentRegionId = null;
|
|
|
|
|
for (int idx = 0; idx < regionDataValues.Length; idx++)
|
|
|
|
|