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 bdtsFactu.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 ListaConexiones() { List lc = new List(); lc.Add(new Conexion() { Nombre = "Producción", Servidor = "192.168.61.201", Puerto = 30002, Usuario = "asegasa", Contraseña = "tk-8Vb/#%+2ÄM", Database = "gestionasegasa" }); lc.Add(new Conexion() { Nombre = "Producción Remoto", Servidor = "sevilla.asegasa.com", Puerto = 30002, Usuario = "asegasa", Contraseña = "tk-8Vb/#%+2ÄM", Database = "gestionasegasa" }); return lc; } internal static string ObtieneConexionDefecto(string NombreConexion="Producción") { try { // optionsBuilder.UseMySql("server=tsFactu;database=tsFactu;port=13306;uid=m3soft;pwd=Romian2023--;persistsecurityinfo=True;TreatTinyAsBoolean=True;allowuservariables=True", Microsoft.EntityFrameworkCore.ServerVersion.Parse("8.2.0-mysql")); string cs = ""; var lc = ListaConexiones(); var cn = lc.First(x => x.Nombre == NombreConexion); string servidor = ""; if (Environment.MachineName.ToUpper() == "VISDIG1") servidor = "localhost"; else { servidor = cn.Servidor; } cs = "server=" + servidor + ";pwd=" + tsUtilidades.crypt.FEncS(cn.Contraseña, @"[JO1]", @"[JD1]", -875421649) + ";port=" + cn.Puerto.ToString() + ";uid=" + cn.Usuario + ";database=" + cn.Database + cs; return cs; } // End If catch (Exception ex) { throw new Exception(ex.Message, ex); } } } }