72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
using System;
|
|
using System.Linq;
|
|
using bdAsegasa.dbcontext;
|
|
using System.Security.Cryptography;
|
|
using System.Text;
|
|
|
|
namespace bdAsegasa.db
|
|
{
|
|
public partial class gestionesvarias
|
|
{
|
|
public static gestionesvarias CreaNuevoCambioContraseñaAgente(int idAgente)
|
|
{
|
|
try
|
|
{
|
|
using (var bd = tscgestionasegasa.NuevoContexto())
|
|
{
|
|
var idTg = bd.enumeraciones.First(x => x.Codigo == "TGV.CCAG").idEnumeracion;
|
|
var ag = bd.agentes.First(x => x.idAgente == idAgente).Codigo;
|
|
|
|
var random = new Random();
|
|
string iAleatorio = random.Next(100000000, 999999999).ToString();
|
|
|
|
var ng = new gestionesvarias();
|
|
ng.idTipo = idTg;
|
|
ng.idAplicacion = idAgente;
|
|
ng.FechaCreacion = DateTime.Now;
|
|
ng.Descripción = ag;
|
|
ng.Parametros = tsUtilidades.crypt.SHA1ASCII("M3Soft." + iAleatorio);
|
|
|
|
bd.gestionesvarias.Add(ng);
|
|
bd.SaveChanges();
|
|
return ng;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message, ex);
|
|
}
|
|
}
|
|
|
|
public static gestionesvarias CreaNuevoCambioContraseñaSubAgente(int idSubAgente)
|
|
{
|
|
try
|
|
{
|
|
using (var bd = tscgestionasegasa.NuevoContexto())
|
|
{
|
|
var idTg = bd.enumeraciones.First(x => x.Codigo == "TGV.CCSAG").idEnumeracion;
|
|
var sag = bd.subagentes.First(x => x.idSubagente == idSubAgente);
|
|
|
|
var random = new Random();
|
|
string iAleatorio = random.Next(100000000, 999999999).ToString();
|
|
|
|
var ng = new gestionesvarias();
|
|
ng.idTipo = idTg;
|
|
ng.idAplicacion = idSubAgente;
|
|
ng.FechaCreacion = DateTime.Now;
|
|
ng.Descripción = $"{sag.idAgenteNavigation?.Codigo}-{sag.Codigo}";
|
|
ng.Parametros = tsUtilidades.crypt.SHA1("M3Soft." + iAleatorio);
|
|
|
|
bd.gestionesvarias.Add(ng);
|
|
bd.SaveChanges();
|
|
return ng;
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message, ex);
|
|
}
|
|
}
|
|
}
|
|
}
|