Files
EmtusaHuelva/bdEmtusa/dbcontext/conexion.cs
2026-09-09 14:06:28 +02:00

50 lines
2.0 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Runtime.InteropServices.JavaScript.JSType;
using tsUtilidades.Enumeraciones;
using System.Drawing.Imaging;
namespace bdEmtusa.dbcontext
{
public class Conexion
{
public string Nombre { get; set; }
public string Servidor { get; set; }
public int Puerto { get; set; }
public string Database { get; set; }
public string Usuario { get; set; }
public string Contraseña { get; set; }
public static List<Conexion> ListaConexiones()
{
List<Conexion> lc = new List<Conexion>();
lc.Add(new Conexion() { Nombre = "Producción", Puerto = 3306, Servidor = "192.168.41.56", Usuario = "tecnosis", Contraseña = "0êmF/e#g/*6pZÛLWqölLvPp", Database = "gestionemtusa" });
lc.Add(new Conexion() { Nombre = "sololectura", Puerto = 3306, Servidor = "192.168.41.56", Usuario = "sololectura", Contraseña = "ÁÔ,mâ1üeqzHbû", Database = "gestionemtusa" });
return lc;
}
internal static string ObtieneConexionDefecto(string NombreConexion="Producción")
{
try
{
// server=10.10.10.1;database=Emtusa;port=3306;uid=root;pwd=larga;persistsecurityinfo=True;TreatTinyAsBoolean=False;allowuservariables=True
string cs = @";persistsecurityinfo=True;TreatTinyAsBoolean=False;allowuservariables=True";
var lc = ListaConexiones();
var cn = lc.First(x => x.Nombre == NombreConexion);
cs = "server=" + cn.Servidor + ";pwd=" + tsUtilidades.crypt.FEncS(cn.Contraseña, @"[JO1]", @"[JD1]", -875421649) + ";port=" + cn.Puerto.ToString() + ";uid=" + cn.Usuario + ";database=" + cn.Database + cs;
return cs;
}
catch (Exception ex)
{
throw new Exception(ex.Message, ex);
}
}
}
}