2026-10-05 17:53:41 -05:00
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Net.Data
|
|
|
|
|
{
|
|
|
|
|
public class LocalData
|
|
|
|
|
{
|
|
|
|
|
public static string ConnectionString { get; private set; }
|
|
|
|
|
|
|
|
|
|
// Esquema HANA: por defecto la compañia del Service Layer (SapServiceLayer:company)
|
|
|
|
|
public static string Schema { get; private set; }
|
|
|
|
|
|
2026-10-19 16:42:12 -05:00
|
|
|
// Tabla de log de integracion (esquema fijo ITC_WMS_SAP). QA/Desarrollo: ITCA_LOG_INTEGRACION;
|
|
|
|
|
// produccion: ITCA_LOG_INTEGRACION_PROD (Hana:logTable en appsettings.json)
|
|
|
|
|
public static string LogTable { get; private set; } = "ITCA_LOG_INTEGRACION";
|
|
|
|
|
|
2026-10-05 17:53:41 -05:00
|
|
|
// Unico punto de lectura de las credenciales HANA (seccion "Hana" de appsettings.json)
|
|
|
|
|
public static void Configure(IConfiguration configuration)
|
|
|
|
|
{
|
|
|
|
|
var server = configuration["Hana:server"];
|
|
|
|
|
var user = configuration["Hana:user"];
|
|
|
|
|
var password = configuration["Hana:password"];
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrWhiteSpace(server) || string.IsNullOrWhiteSpace(user) || string.IsNullOrEmpty(password))
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Falta la seccion \"Hana\" (server, user, password) en appsettings.json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ConnectionString = $"Server={server};UserName={user};Password={password}";
|
|
|
|
|
|
|
|
|
|
var schema = configuration["Hana:schema"];
|
|
|
|
|
if (string.IsNullOrWhiteSpace(schema)) schema = configuration["SapServiceLayer:company"];
|
|
|
|
|
if (string.IsNullOrWhiteSpace(schema))
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("Falta el esquema HANA: configure Hana:schema o SapServiceLayer:company en appsettings.json");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Schema = schema;
|
2026-10-19 16:42:12 -05:00
|
|
|
|
|
|
|
|
var logTable = configuration["Hana:logTable"];
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(logTable)) LogTable = logTable.Trim();
|
2026-10-05 17:53:41 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|