case 4632

This commit is contained in:
2025-02-18 21:08:56 +00:00
parent 406e42df4e
commit 9d7c575dd1
5 changed files with 813 additions and 345 deletions

View File

@@ -3,10 +3,8 @@ using System.Collections.Generic;
using System.IO;
using Microsoft.Extensions.Configuration;
namespace AyaNova.Util
{
/// <summary>
/// Contains config values from bootup
/// </summary>
@@ -14,23 +12,29 @@ namespace AyaNova.Util
{
//############################################################################################################
//STATIC HARD CODED COMPILE TIME DEFAULTS NOT SET THROUGH CONFIG
internal const int FAILED_AUTH_DELAY = 3000;//ms
internal const int JOB_OBJECT_HANDLE_BATCH_JOB_LOOP_DELAY = 200;//ms this delay is a temporary measure to ensure super big time consuming batch jobs don't use all server CPU resources
internal const int JOB_PROGRESS_UPDATE_AND_CANCEL_CHECK_SECONDS = 5;//seconds between progress updates and checks for cancellation of long running jobs
internal const int JOB_OBJECT_EMAIL_LOOP_DELAY = 500;//ms this delay ensures multiple email sendings in a job don't overwhelm the mail server
internal const int FAILED_AUTH_DELAY = 3000; //ms
internal const int JOB_OBJECT_HANDLE_BATCH_JOB_LOOP_DELAY = 200; //ms this delay is a temporary measure to ensure super big time consuming batch jobs don't use all server CPU resources
internal const int JOB_PROGRESS_UPDATE_AND_CANCEL_CHECK_SECONDS = 5; //seconds between progress updates and checks for cancellation of long running jobs
internal const int JOB_OBJECT_EMAIL_LOOP_DELAY = 500; //ms this delay ensures multiple email sendings in a job don't overwhelm the mail server
//UPLOAD LIMITS 1048576 = 1MiB for testing 10737420000 10737418240 10,737,418,240
internal const long MAX_ATTACHMENT_UPLOAD_BYTES = 10737420000;//slight bit of overage as 10737418241=10GiB
internal const long MAX_LOGO_UPLOAD_BYTES = 512000;//500KiB limit
internal const long MAX_IMPORT_FILE_UPLOAD_BYTES = 104857600;//100MiB limit
internal const long MAX_REPORT_TEMPLATE_UPLOAD_BYTES = 15728640;//15MiB limit; currently the largest v7 export for a report template is 828kb, I'm guessing 15mb is more than enough
internal const long MAX_TRANSLATION_UPLOAD_BYTES = 15728640;//15MiB limit; currently export file is 200kb * 50 maximum at a time = 15mb
internal const long MAX_ATTACHMENT_UPLOAD_BYTES = 10737420000; //slight bit of overage as 10737418241=10GiB
internal const long MAX_LOGO_UPLOAD_BYTES = 512000; //500KiB limit
internal const long MAX_IMPORT_FILE_UPLOAD_BYTES = 104857600; //100MiB limit
internal const long MAX_REPORT_TEMPLATE_UPLOAD_BYTES = 15728640; //15MiB limit; currently the largest v7 export for a report template is 828kb, I'm guessing 15mb is more than enough
internal const long MAX_TRANSLATION_UPLOAD_BYTES = 15728640; //15MiB limit; currently export file is 200kb * 50 maximum at a time = 15mb
//case 4632 safety constant as it's now referenced in multiple places
internal const string CUSTOMER_NOTIFICATION_ATTACHED_REPORT_RENDER_USERNAME =
"CUSTOMER NOTIFICATION - NO USER";
//############################################################################################################
//############################
//SEEDING FLAG INTERNAL ONLY
//used to speed up seeding with bypasses to normal validation etc
internal static bool SEEDING { get; set; }
//############################
//############################
@@ -42,17 +46,15 @@ namespace AyaNova.Util
//Diagnostic static values used during development, may not be related to config at all, this is just a convenient class to put them in
#if (DEBUG)
internal static List<string> TranslationKeysRequested { get; set; }
#endif
//CONTENTROOTPATH
//** Not intended for end users but required in release mode
internal static string AYANOVA_CONTENT_ROOT_PATH { get; set; } //Note: set in startup.cs, not in program.cs as it requires startup IHostingEnvironment
//LANGUAGE / Translation
internal static string AYANOVA_DEFAULT_TRANSLATION { get; set; }
//** Not intended for end users
internal static long AYANOVA_DEFAULT_TRANSLATION_ID { get; set; } //internal setting set at boot by TranslationBiz::ValidateTranslations
@@ -61,9 +63,9 @@ namespace AyaNova.Util
internal static string AYANOVA_USE_URLS { get; set; }
internal static int AYANOVA_REPORT_RENDERING_TIMEOUT { get; set; }
//DATABASE
internal static string AYANOVA_DB_CONNECTION { get; set; }
//** Not intended for end users
internal static bool AYANOVA_PERMANENTLY_ERASE_DATABASE { get; set; }
@@ -81,13 +83,13 @@ namespace AyaNova.Util
//REPORT RENDERING BROWSER PATH (if not set then will attempt to auto-download on first render)
internal static string AYANOVA_REPORT_RENDER_BROWSER_PATH { get; set; }
//REPORT RENDERING BROWSER PARAMS
//REPORT RENDERING BROWSER PARAMS
internal static string AYANOVA_REPORT_RENDER_BROWSER_PARAMS { get; set; }
//REPORT RENDERING API URL OVERRIDE
internal static string AYANOVA_REPORT_RENDER_API_URL_OVERRIDE { get; set; }
//LOGGING
internal static string AYANOVA_LOG_PATH { get; set; }
internal static string AYANOVA_LOG_LEVEL { get; set; }
@@ -97,9 +99,10 @@ namespace AyaNova.Util
internal static string AYANOVA_SET_SUPERUSER_PW { get; set; }
//HELPFUL INFORMATION FOR DIAGNOSTICS
internal static Dictionary<string, string> BOOT_DIAGNOSTIC_INFO { get; set; } = new Dictionary<string, string>();
internal static Dictionary<string, string> DBSERVER_DIAGNOSTIC_INFO { get; set; } = new Dictionary<string, string>();
internal static Dictionary<string, string> BOOT_DIAGNOSTIC_INFO { get; set; } =
new Dictionary<string, string>();
internal static Dictionary<string, string> DBSERVER_DIAGNOSTIC_INFO { get; set; } =
new Dictionary<string, string>();
/// <summary>
/// Populate the config from the configuration found at boot
@@ -108,7 +111,6 @@ namespace AyaNova.Util
/// <param name="config"></param>
internal static void SetConfiguration(IConfigurationRoot config)
{
#if (DEBUG)
TranslationKeysRequested = new List<string>();
#endif
@@ -121,7 +123,9 @@ namespace AyaNova.Util
//LANGUAGE
//TranslationBiz will validate this later at boot pfc and ensure a sane default is set (English)
AYANOVA_DEFAULT_TRANSLATION = config.GetValue<string>("AYANOVA_DEFAULT_TRANSLATION");
AYANOVA_DEFAULT_TRANSLATION = string.IsNullOrWhiteSpace(AYANOVA_DEFAULT_TRANSLATION) ? "en" : AYANOVA_DEFAULT_TRANSLATION;
AYANOVA_DEFAULT_TRANSLATION = string.IsNullOrWhiteSpace(AYANOVA_DEFAULT_TRANSLATION)
? "en"
: AYANOVA_DEFAULT_TRANSLATION;
string lowTranslation = AYANOVA_DEFAULT_TRANSLATION.ToLowerInvariant();
switch (lowTranslation)
{
@@ -149,12 +153,11 @@ namespace AyaNova.Util
break;
}
//LOGLEVEL
AYANOVA_LOG_LEVEL = config.GetValue<string>("AYANOVA_LOG_LEVEL");
AYANOVA_LOG_LEVEL = string.IsNullOrWhiteSpace(AYANOVA_LOG_LEVEL) ? "Info" : AYANOVA_LOG_LEVEL;
AYANOVA_LOG_LEVEL = string.IsNullOrWhiteSpace(AYANOVA_LOG_LEVEL)
? "Info"
: AYANOVA_LOG_LEVEL;
//LOGGING DIAGNOSTIC LOG
bTemp = config.GetValue<bool?>("AYANOVA_LOG_ENABLE_LOGGER_DIAGNOSTIC_LOG");
@@ -162,30 +165,37 @@ namespace AyaNova.Util
//PORT / API
AYANOVA_USE_URLS = config.GetValue<string>("AYANOVA_USE_URLS");
AYANOVA_USE_URLS = string.IsNullOrWhiteSpace(AYANOVA_USE_URLS) ? "http://*:7575" : AYANOVA_USE_URLS;
AYANOVA_USE_URLS = string.IsNullOrWhiteSpace(AYANOVA_USE_URLS)
? "http://*:7575"
: AYANOVA_USE_URLS;
AYANOVA_JWT_SECRET = config.GetValue<string>("AYANOVA_JWT_SECRET");
//backdoor back door password superuser reset
AYANOVA_SET_SUPERUSER_PW = config.GetValue<string>("AYANOVA_SET_SUPERUSER_PW");
//REPORT RENDERING
//REPORT RENDERING
//RENDER OVERRIDE URL FOR CORS ISSUES BEHIND IIS (case 4398)
AYANOVA_REPORT_RENDER_API_URL_OVERRIDE = config.GetValue<string>("AYANOVA_REPORT_RENDER_API_URL_OVERRIDE");
AYANOVA_REPORT_RENDER_API_URL_OVERRIDE = config.GetValue<string>(
"AYANOVA_REPORT_RENDER_API_URL_OVERRIDE"
);
//RENDER ENGINE PATH
AYANOVA_REPORT_RENDER_BROWSER_PATH = ActualFullPath(config.GetValue<string>("AYANOVA_REPORT_RENDER_BROWSER_PATH"));
//RENDER ENGINE PATH
AYANOVA_REPORT_RENDER_BROWSER_PATH = ActualFullPath(
config.GetValue<string>("AYANOVA_REPORT_RENDER_BROWSER_PATH")
);
//RENDER ENGINE PARAMS
AYANOVA_REPORT_RENDER_BROWSER_PARAMS = config.GetValue<string>("AYANOVA_REPORT_RENDER_BROWSER_PARAMS");
AYANOVA_REPORT_RENDER_BROWSER_PARAMS = config.GetValue<string>(
"AYANOVA_REPORT_RENDER_BROWSER_PARAMS"
);
//PROCESS CONTROL
int? nTemp = config.GetValue<int?>("AYANOVA_REPORT_RENDERING_TIMEOUT");
AYANOVA_REPORT_RENDERING_TIMEOUT = (null == nTemp) ? 5 : (int)nTemp;//default
if (AYANOVA_REPORT_RENDERING_TIMEOUT < 1) AYANOVA_REPORT_RENDERING_TIMEOUT = 1; //one minute minimum timeout
AYANOVA_REPORT_RENDERING_TIMEOUT = (null == nTemp) ? 5 : (int)nTemp; //default
if (AYANOVA_REPORT_RENDERING_TIMEOUT < 1)
AYANOVA_REPORT_RENDERING_TIMEOUT = 1; //one minute minimum timeout
//DB
AYANOVA_DB_CONNECTION = config.GetValue<string>("AYANOVA_DB_CONNECTION");
@@ -197,41 +207,64 @@ namespace AyaNova.Util
bTemp = config.GetValue<bool?>("AYANOVA_REMOVE_LICENSE_FROM_DB");
AYANOVA_REMOVE_LICENSE_FROM_DB = (null == bTemp) ? false : (bool)bTemp;
//FOLDERS
string DataFolderPath = ActualFullPath(config.GetValue<string>("AYANOVA_DATA_PATH"));
string LogPath = ActualFullPath(config.GetValue<string>("AYANOVA_LOG_PATH"));
string AttachmentFilesPath = ActualFullPath(config.GetValue<string>("AYANOVA_ATTACHMENT_FILES_PATH"));
string BackupFilesPath = ActualFullPath(config.GetValue<string>("AYANOVA_BACKUP_FILES_PATH"));
string TempFilesPath = ActualFullPath(config.GetValue<string>("AYANOVA_TEMP_FILES_PATH"));
AYANOVA_BACKUP_PG_DUMP_PATH = ActualFullPath(config.GetValue<string>("AYANOVA_BACKUP_PG_DUMP_PATH"));
string AttachmentFilesPath = ActualFullPath(
config.GetValue<string>("AYANOVA_ATTACHMENT_FILES_PATH")
);
string BackupFilesPath = ActualFullPath(
config.GetValue<string>("AYANOVA_BACKUP_FILES_PATH")
);
string TempFilesPath = ActualFullPath(
config.GetValue<string>("AYANOVA_TEMP_FILES_PATH")
);
AYANOVA_BACKUP_PG_DUMP_PATH = ActualFullPath(
config.GetValue<string>("AYANOVA_BACKUP_PG_DUMP_PATH")
);
if (string.IsNullOrWhiteSpace(DataFolderPath))
{
//In this case *must* have paths for *everything* specified
if (string.IsNullOrWhiteSpace(LogPath))
throw new System.ArgumentNullException("AYANOVA_LOG_PATH configuration setting missing and required");
throw new System.ArgumentNullException(
"AYANOVA_LOG_PATH configuration setting missing and required"
);
if (string.IsNullOrWhiteSpace(AttachmentFilesPath))
throw new System.ArgumentNullException("AYANOVA_ATTACHMENT_FILES_PATH configuration setting missing and required");
throw new System.ArgumentNullException(
"AYANOVA_ATTACHMENT_FILES_PATH configuration setting missing and required"
);
if (string.IsNullOrWhiteSpace(BackupFilesPath))
throw new System.ArgumentNullException("AYANOVA_BACKUP_FILES_PATH configuration setting missing and required");
throw new System.ArgumentNullException(
"AYANOVA_BACKUP_FILES_PATH configuration setting missing and required"
);
if (string.IsNullOrWhiteSpace(TempFilesPath))
throw new System.ArgumentNullException("AYANOVA_TEMP_FILES_PATH configuration setting missing and required");
throw new System.ArgumentNullException(
"AYANOVA_TEMP_FILES_PATH configuration setting missing and required"
);
}
//set paths
AYANOVA_LOG_PATH = (string.IsNullOrWhiteSpace(LogPath)) ? Path.Combine(DataFolderPath, "logs") : LogPath;
AYANOVA_ATTACHMENT_FILES_PATH = (string.IsNullOrWhiteSpace(AttachmentFilesPath)) ? Path.Combine(DataFolderPath, "attachments") : AttachmentFilesPath;
AYANOVA_BACKUP_FILES_PATH = (string.IsNullOrWhiteSpace(BackupFilesPath)) ? Path.Combine(DataFolderPath, "backups") : BackupFilesPath;
AYANOVA_TEMP_FILES_PATH = (string.IsNullOrWhiteSpace(TempFilesPath)) ? Path.Combine(DataFolderPath, "temp") : TempFilesPath;
AYANOVA_LOG_PATH =
(string.IsNullOrWhiteSpace(LogPath))
? Path.Combine(DataFolderPath, "logs")
: LogPath;
AYANOVA_ATTACHMENT_FILES_PATH =
(string.IsNullOrWhiteSpace(AttachmentFilesPath))
? Path.Combine(DataFolderPath, "attachments")
: AttachmentFilesPath;
AYANOVA_BACKUP_FILES_PATH =
(string.IsNullOrWhiteSpace(BackupFilesPath))
? Path.Combine(DataFolderPath, "backups")
: BackupFilesPath;
AYANOVA_TEMP_FILES_PATH =
(string.IsNullOrWhiteSpace(TempFilesPath))
? Path.Combine(DataFolderPath, "temp")
: TempFilesPath;
#endregion server BASICS
}
internal static string ActualFullPath(string p)
{
if (string.IsNullOrWhiteSpace(p))
@@ -245,7 +278,9 @@ namespace AyaNova.Util
get
{
if (string.IsNullOrWhiteSpace(AYANOVA_USE_URLS))
{ return null; }
{
return null;
}
if (!AYANOVA_USE_URLS.Contains(";"))
{
@@ -253,15 +288,7 @@ namespace AyaNova.Util
}
var s = AYANOVA_USE_URLS.Split(';');
return s[0].Replace("*", "localhost");
}
}
}//eoc
}//eons
} //eoc
} //eons