Primera versión estable compatible con linux de WSAsegasa
This commit is contained in:
59
bdAsegasa/dbcontext/conexion.cs
Normal file
59
bdAsegasa/dbcontext/conexion.cs
Normal file
@@ -0,0 +1,59 @@
|
||||
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<Conexion> ListaConexiones()
|
||||
{
|
||||
List<Conexion> lc = new List<Conexion>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user