Ajuste Revision 2 Usuarios

This commit is contained in:
Dario F. Gomez Z 2023-11-07 08:35:29 -05:00
parent 39db90fc07
commit f97a42f296
5 changed files with 165 additions and 22 deletions

View File

@ -23,6 +23,7 @@ namespace MSAdminUsuarios.Context
public virtual DbSet<PERFILPORUSUARIO> PERFILESPORUSUARIOs { get; set; } = null!;
public virtual DbSet<USUARIO> USUARIOSMs { get; set; } = null!;
public virtual DbSet<CORREOSAREAMS> CORREOSAREAMS { get; set; } = null!;
public virtual DbSet<USUARIOSTEMP> USUARIOSTEMP { get; set; } = null!;
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
@ -109,6 +110,40 @@ namespace MSAdminUsuarios.Context
});
modelBuilder.Entity<USUARIOSTEMP>(entity =>
{
entity.HasKey(e => e.NU_PK_USUTMP)
.HasName("USUARIOSTEMP_PK");
entity.ToTable("USUARIOSTEMP");
entity.Property(e => e.NU_PK_USUTMP).HasPrecision(10);
entity.Property(e => e.FE_INICIOACTIVACION_USUTMP).HasColumnType("DATE");
entity.Property(e => e.FE_FINACTIVACION_USUTMP).HasColumnType("DATE");
entity.Property(e => e.NU_ESTADO_USUTMP).HasPrecision(10);
entity.Property(e => e.NU_TIPODOC_USUTMP).HasPrecision(10);
entity.Property(e => e.TX_CORREO_USUTMP).HasMaxLength(200);
entity.Property(e => e.TX_IDENTIFICACION_USUTMP).HasMaxLength(100);
entity.Property(e => e.TX_NOMBREPVD_USUTMP).HasMaxLength(1999);
entity.Property(e => e.TX_PRIMERAPELL_USUTMP).HasMaxLength(200);
entity.Property(e => e.TX_PRIMERNOM_USUTMP).HasMaxLength(200);
entity.Property(e => e.TX_SEGUNDOAPELL_USUTMP).HasMaxLength(200);
entity.Property(e => e.TX_SEGUNDONOM_USUTMP).HasMaxLength(200);
entity.Property(e => e.TX_TELEFONO_USUTMP).HasMaxLength(100);
});
OnModelCreatingPartial(modelBuilder);
}

View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
namespace MSAdminUsuarios.Context
{
public partial class USUARIOSTEMP
{
public int NU_PK_USUTMP { get; set; }
public int? NU_TIPODOC_USUTMP { get; set; }
public string? TX_IDENTIFICACION_USUTMP { get; set; }
public string? TX_PRIMERNOM_USUTMP { get; set; }
public string? TX_SEGUNDONOM_USUTMP { get; set; }
public string? TX_PRIMERAPELL_USUTMP { get; set; }
public string? TX_SEGUNDOAPELL_USUTMP { get; set; }
public string? TX_NOMBREPVD_USUTMP { get; set; }
public string? TX_CORREO_USUTMP { get; set; }
public string? TX_TELEFONO_USUTMP { get; set; }
public int? NU_ESTADO_USUTMP { get; set; }
public DateTime? FE_INICIOACTIVACION_USUTMP { get; set; }
public DateTime? FE_FINACTIVACION_USUTMP { get; set; }
}
}

View File

@ -32,6 +32,7 @@ namespace MSAdminUsuarios.Controllers
if (login.TX_PASSWORD_USUMS == null) return BadRequest("Es necesario ingresar una contrase<73>a");
USUARIO? userldap = _context.USUARIOSMs.FirstOrDefault(u => u.TX_LOGINNAME_USUMS == login.TX_LOGINNAME_USUMS);
if (userldap == null) return BadRequest("usuario");
if(userldap.BL_VIENELDAP_USUMS == 1)
{
bool boolldap = LoginLib.Login(login.TX_LOGINNAME_USUMS, login.TX_PASSWORD_USUMS);

View File

@ -0,0 +1,70 @@
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using MSAdminUsuarios.Context;
using MSAdminUsuarios.Models;
namespace MSAdminUsuarios.Controllers
{
[Route("[controller]")]
[ApiController]
public class UsuariosTempController : ControllerBase
{
private readonly ModelContext _context;
private readonly ILogger<UsuariosTempController> _logger;
private ErrorModel _errorModel;
public UsuariosTempController(ModelContext context, ILogger<UsuariosTempController> logger)
{
_context = context;
_logger = logger;
_errorModel = new ErrorModel();
}
[HttpGet]
public async Task<IActionResult> Get()
{
_errorModel = new ErrorModel();
try
{
List<USUARIOSTEMP> externos = await _context.USUARIOSTEMP.OrderBy(q => q.NU_PK_USUTMP).ToListAsync();
return Ok(externos);
}
catch (Exception)
{
_errorModel.error = true;
_errorModel.cuerpo.Add("Error con la base de datos.");
return BadRequest(_errorModel);
}
}
[HttpPost]
public async Task<IActionResult> Post(USUARIOSTEMP nuevo)
{
_errorModel = new ErrorModel();
try
{
if (nuevo == null)
{
_errorModel.error = true;
_errorModel.cuerpo.Add("No se envió solicitud.");
return Conflict(_errorModel);
}
_context.USUARIOSTEMP.Add(nuevo);
await _context.SaveChangesAsync();
_errorModel.error = false;
_errorModel.cuerpo.Add("Solicitud de usuario temporal guardado correctamente.");
return Ok(_errorModel);
}
catch (Exception)
{
_errorModel.error = true;
_errorModel.cuerpo.Add("Error con la base de datos.");
return BadRequest(_errorModel);
}
}
}
}

View File

@ -66,6 +66,12 @@ namespace MSAdminUsuarios.Utils
);
}
channel.QueueBind(
queue: $"{exchangeName}.Usuarios",
exchange: exchangeName,
routingKey: $"{exchangeName}.Usuarios.*.*"
);
return channel;
}
@ -74,6 +80,8 @@ namespace MSAdminUsuarios.Utils
RabbitMQConfig mqConfig = builder.Configuration.GetSection("RabbitMQConfig").Get<RabbitMQConfig>();
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().AddEventLog());
try
{
//var logger = loggerFactory.CreateLogger("Rabbit2");
//logger.LogInformation("Inicia Rabbitmq con");
@ -106,6 +114,13 @@ namespace MSAdminUsuarios.Utils
);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
public static async void ConsumeRabbitMQEvent(object? sender, BasicDeliverEventArgs ea)