updated the mysqlconnectionstring with preload string to load when app is deployed
parent
937bcc50d3
commit
679b0a053e
|
|
@ -13,6 +13,9 @@ namespace UtopiaCanteenSystem.Services;
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class ConfigService : IConfigService
|
public class ConfigService : IConfigService
|
||||||
{
|
{
|
||||||
|
private const string DefaultMySqlConnectionString =
|
||||||
|
"SERVER=utopia-industries-rr.c5qech8o9lgg.us-east-1.rds.amazonaws.com;DATABASE=hrms;UID=uind_hrms_user;PASSWORD=UINDHRMS01;";
|
||||||
|
|
||||||
private readonly string _configPath;
|
private readonly string _configPath;
|
||||||
private AppConfig _config;
|
private AppConfig _config;
|
||||||
|
|
||||||
|
|
@ -232,6 +235,7 @@ public class ConfigService : IConfigService
|
||||||
{
|
{
|
||||||
System.Diagnostics.Debug.WriteLine("[ConfigService] Config file not found. Creating with defaults.");
|
System.Diagnostics.Debug.WriteLine("[ConfigService] Config file not found. Creating with defaults.");
|
||||||
var defaults = new AppConfig();
|
var defaults = new AppConfig();
|
||||||
|
EnsureConnectionStringDefaults(defaults);
|
||||||
SaveConfig(defaults);
|
SaveConfig(defaults);
|
||||||
return defaults;
|
return defaults;
|
||||||
}
|
}
|
||||||
|
|
@ -240,6 +244,9 @@ public class ConfigService : IConfigService
|
||||||
var config = JsonSerializer.Deserialize<AppConfig>(json);
|
var config = JsonSerializer.Deserialize<AppConfig>(json);
|
||||||
config ??= new AppConfig();
|
config ??= new AppConfig();
|
||||||
MigrateScanIntervalFromSecondsIfNeeded(config);
|
MigrateScanIntervalFromSecondsIfNeeded(config);
|
||||||
|
var changed = EnsureConnectionStringDefaults(config);
|
||||||
|
if (changed)
|
||||||
|
SaveConfig(config);
|
||||||
|
|
||||||
System.Diagnostics.Debug.WriteLine($"[ConfigService] Config loaded from {_configPath}");
|
System.Diagnostics.Debug.WriteLine($"[ConfigService] Config loaded from {_configPath}");
|
||||||
System.Diagnostics.Debug.WriteLine($"[ConfigService] SiteId: '{config.SiteId}' (empty=not configured)");
|
System.Diagnostics.Debug.WriteLine($"[ConfigService] SiteId: '{config.SiteId}' (empty=not configured)");
|
||||||
|
|
@ -255,6 +262,17 @@ public class ConfigService : IConfigService
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool EnsureConnectionStringDefaults(AppConfig config)
|
||||||
|
{
|
||||||
|
var changed = false;
|
||||||
|
if (string.IsNullOrWhiteSpace(config.MySqlConnectionString))
|
||||||
|
{
|
||||||
|
config.MySqlConnectionString = DefaultMySqlConnectionString;
|
||||||
|
changed = true;
|
||||||
|
}
|
||||||
|
return changed;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// One-time migration: if old ScanTimeoutSeconds is set and new D/H/M are all zero, convert and persist.
|
/// One-time migration: if old ScanTimeoutSeconds is set and new D/H/M are all zero, convert and persist.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue