using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static GB5Shared.DTO.Framework.Enum.FrameworkEnumDTO;
namespace GB5Shared.DTO.Framework.CommonConfig
{
public class Gb5SystemDTO // ✅ Separate DTO class to avoid recursive constructor calls
{
public int DataBaseType { get; set; }
public string Gb5System { get; set; }
public string Gb5SystemPG { get; set; }
public string Gb4ServiceCache { get; set; }
public string JasperServer { get; set; }
public string JasperNewVersion { get; set; }
public string SchedulerTemplate { get; set; }
///
/// Per-module override for the session idle timeout (minutes).
///
public int SessionExpiryMinutes { get; set; } = 0;
///
/// Public base URL of this service — used to build email approval links.
///
public string ServiceBaseUrl { get; set; } = string.Empty;
///
/// 0 = SQL Server (Gb5System)
/// 2 = PostgreSQL (Gb5SystemPG)
///
public string ActiveConnectionString => DataBaseType switch
{
0 => Gb5System, // SQL Server
2 => !string.IsNullOrWhiteSpace(Gb5SystemPG)
? Gb5SystemPG // ✅ New format — use Gb5SystemPG
: Gb5System, // ✅ Old format — PG string in Gb5System
_ => throw new NotSupportedException($"DataBaseType '{DataBaseType}' is not supported.")
};
public DatabaseType ActiveDatabaseType =>
(DatabaseType)DataBaseType;
}
// ✅ ADD THIS — Wrapper class to allow DI injection of DatabaseType enum
// (enums cannot be registered directly as singleton in .NET DI)
public class DatabaseTypeConfig
{
public DatabaseType Value { get; set; }
public DatabaseTypeConfig(DatabaseType value)
{
Value = value;
}
}
}