Merge branch 'master' of http://181.204.191.98:81/Bonobo.Git.Server/Apigateway
This commit is contained in:
commit
ee149222e4
@ -17,6 +17,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MSAdminUsuarios", "Microser
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegradorBE", "Microservicios\IntegradorBE\IntegradorBE.csproj", "{E3B575F9-4A18-43E6-A542-7CC29B086752}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "IntegradorBE", "Microservicios\IntegradorBE\IntegradorBE.csproj", "{E3B575F9-4A18-43E6-A542-7CC29B086752}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LdapLoginLib", "LdapLoginLib\LdapLoginLib.csproj", "{6E864339-08B2-4C2F-909C-FCF0392E3F6D}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@ -39,6 +41,10 @@ Global
|
|||||||
{E3B575F9-4A18-43E6-A542-7CC29B086752}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{E3B575F9-4A18-43E6-A542-7CC29B086752}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{E3B575F9-4A18-43E6-A542-7CC29B086752}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{E3B575F9-4A18-43E6-A542-7CC29B086752}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{E3B575F9-4A18-43E6-A542-7CC29B086752}.Release|Any CPU.Build.0 = Release|Any CPU
|
{E3B575F9-4A18-43E6-A542-7CC29B086752}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{6E864339-08B2-4C2F-909C-FCF0392E3F6D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{6E864339-08B2-4C2F-909C-FCF0392E3F6D}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{6E864339-08B2-4C2F-909C-FCF0392E3F6D}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{6E864339-08B2-4C2F-909C-FCF0392E3F6D}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
@ -48,6 +54,7 @@ Global
|
|||||||
{76522272-9D28-4168-8296-AFC933D22650} = {F491CF9B-9CF8-4F3B-BBD7-A282F7DC1D6D}
|
{76522272-9D28-4168-8296-AFC933D22650} = {F491CF9B-9CF8-4F3B-BBD7-A282F7DC1D6D}
|
||||||
{D0B80363-4C96-413F-8C82-48FCF2CD7F57} = {A449A86B-39E4-4EEB-B7C6-B6B12A0CBD2E}
|
{D0B80363-4C96-413F-8C82-48FCF2CD7F57} = {A449A86B-39E4-4EEB-B7C6-B6B12A0CBD2E}
|
||||||
{E3B575F9-4A18-43E6-A542-7CC29B086752} = {A449A86B-39E4-4EEB-B7C6-B6B12A0CBD2E}
|
{E3B575F9-4A18-43E6-A542-7CC29B086752} = {A449A86B-39E4-4EEB-B7C6-B6B12A0CBD2E}
|
||||||
|
{6E864339-08B2-4C2F-909C-FCF0392E3F6D} = {F491CF9B-9CF8-4F3B-BBD7-A282F7DC1D6D}
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
SolutionGuid = {EC576D5A-ADE3-40CC-BF55-7E52E6F18AC4}
|
SolutionGuid = {EC576D5A-ADE3-40CC-BF55-7E52E6F18AC4}
|
||||||
|
@ -22,7 +22,8 @@ namespace MSAdminUsuarios.Context
|
|||||||
public virtual DbSet<PERFIL> PERFILESMs { get; set; } = null!;
|
public virtual DbSet<PERFIL> PERFILESMs { get; set; } = null!;
|
||||||
public virtual DbSet<PERFILPORUSUARIO> PERFILESPORUSUARIOs { get; set; } = null!;
|
public virtual DbSet<PERFILPORUSUARIO> PERFILESPORUSUARIOs { get; set; } = null!;
|
||||||
public virtual DbSet<USUARIO> USUARIOSMs { get; set; } = null!;
|
public virtual DbSet<USUARIO> USUARIOSMs { get; set; } = null!;
|
||||||
public virtual DbSet<CORREOSAREAMS> CORREOSAREAMS { 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)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
@ -48,7 +49,7 @@ namespace MSAdminUsuarios.Context
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
modelBuilder.HasDefaultSchema("ADMIN");
|
modelBuilder.HasDefaultSchema("ADMIN");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -75,6 +76,8 @@ namespace MSAdminUsuarios.Context
|
|||||||
.HasName("PERFILESMS_PK");
|
.HasName("PERFILESMS_PK");
|
||||||
|
|
||||||
entity.ToTable("PERFILESMS");
|
entity.ToTable("PERFILESMS");
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_UUID_PFL).HasMaxLength(40);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -85,7 +88,8 @@ namespace MSAdminUsuarios.Context
|
|||||||
|
|
||||||
entity.ToTable("PERFILESPORUSUARIO");
|
entity.ToTable("PERFILESPORUSUARIO");
|
||||||
|
|
||||||
entity.Property(e => e.TX_UUID_PFLXUSU).HasMaxLength(40);
|
entity.Property(e => e.TX_UUID_USUMS).HasMaxLength(40);
|
||||||
|
entity.Property(e => e.TX_UUID_PFL).HasMaxLength(40);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -109,6 +113,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_FINACTIVACION_USUTMP).HasColumnType("DATE");
|
||||||
|
|
||||||
|
entity.Property(e => e.FE_INICIOACTIVACION_USUTMP).HasColumnType("DATE");
|
||||||
|
|
||||||
|
entity.Property(e => e.NU_ESTADO_USUMS).HasPrecision(10);
|
||||||
|
|
||||||
|
entity.Property(e => e.NU_TIPODOC_USUMS).HasPrecision(10);
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_CORREO_USUMS).HasMaxLength(200);
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_NOMBRE_PVD).HasMaxLength(1999);
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_PKDOC_USUMS).HasMaxLength(200);
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_PRIMERAPELL_USUMS).HasMaxLength(200);
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_PRIMERNOM_USUMS).HasMaxLength(200);
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_SEGUNDOAPELL_USUMS).HasMaxLength(200);
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_SEGUNDONOM_USUMS).HasMaxLength(200);
|
||||||
|
|
||||||
|
entity.Property(e => e.TX_TELEFONO_USUMS).HasMaxLength(200);
|
||||||
|
});
|
||||||
|
|
||||||
OnModelCreatingPartial(modelBuilder);
|
OnModelCreatingPartial(modelBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ namespace MSAdminUsuarios.Context
|
|||||||
public string? TX_PERFIL_PFL { get; set; }
|
public string? TX_PERFIL_PFL { get; set; }
|
||||||
public int? BL_ESTADO_PFL { get; set; } = 1;
|
public int? BL_ESTADO_PFL { get; set; } = 1;
|
||||||
public int? NU_ROL_PFL { get; set; }
|
public int? NU_ROL_PFL { get; set; }
|
||||||
|
public string? TX_UUID_PFL { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,11 @@ namespace MSAdminUsuarios.Context
|
|||||||
public partial class PERFILPORUSUARIO
|
public partial class PERFILPORUSUARIO
|
||||||
{
|
{
|
||||||
public int NU_PK_PFLXUSU { get; set; }
|
public int NU_PK_PFLXUSU { get; set; }
|
||||||
public string? TX_FKDOC_USUMS { get; set; }
|
//public string? TX_FKDOC_USUMS { get; set; }
|
||||||
public int? NU_FK_PFL { get; set; }
|
public int? NU_FK_PFL { get; set; }
|
||||||
public int? BL_ESTADO_PFLXUSU { get; set; } = 1;
|
public int? BL_ESTADO_PFLXUSU { get; set; } = 1;
|
||||||
public string? TX_UUID_PFLXUSU { get; set; }
|
public string? TX_UUID_USUMS { get; set; }
|
||||||
|
public string? TX_UUID_PFL { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
Microservicios/MsUsuarios/Context/USUARIOSTEMP.cs
Normal file
22
Microservicios/MsUsuarios/Context/USUARIOSTEMP.cs
Normal 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_USUMS { get; set; }
|
||||||
|
public string? TX_PKDOC_USUMS { get; set; }
|
||||||
|
public string? TX_PRIMERNOM_USUMS { get; set; }
|
||||||
|
public string? TX_SEGUNDONOM_USUMS { get; set; }
|
||||||
|
public string? TX_PRIMERAPELL_USUMS { get; set; }
|
||||||
|
public string? TX_SEGUNDOAPELL_USUMS { get; set; }
|
||||||
|
public string? TX_NOMBRE_PVD { get; set; }
|
||||||
|
public string? TX_CORREO_USUMS { get; set; }
|
||||||
|
public string? TX_TELEFONO_USUMS { get; set; }
|
||||||
|
public int? NU_ESTADO_USUMS { get; set; }
|
||||||
|
public DateTime? FE_INICIOACTIVACION_USUTMP { get; set; }
|
||||||
|
public DateTime? FE_FINACTIVACION_USUTMP { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,8 @@
|
|||||||
|
using LdapLoginLib;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using MSAdminUsuarios.Context;
|
using MSAdminUsuarios.Context;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using Security;
|
using Security;
|
||||||
using System.IdentityModel.Tokens.Jwt;
|
using System.IdentityModel.Tokens.Jwt;
|
||||||
using System.Security.Claims;
|
using System.Security.Claims;
|
||||||
@ -29,16 +31,41 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
if (login.TX_LOGINNAME_USUMS == null) return BadRequest("Es necesario ingresar un correo");
|
if (login.TX_LOGINNAME_USUMS == null) return BadRequest("Es necesario ingresar un correo");
|
||||||
if (login.TX_PASSWORD_USUMS == null) return BadRequest("Es necesario ingresar una contrase<73>a");
|
if (login.TX_PASSWORD_USUMS == null) return BadRequest("Es necesario ingresar una contrase<73>a");
|
||||||
|
|
||||||
USUARIO? user = _context.USUARIOSMs.FirstOrDefault(u => u.TX_LOGINNAME_USUMS == login.TX_LOGINNAME_USUMS && u.TX_PASSWORD_USUMS == _encript.EncryptPwd(login.TX_PASSWORD_USUMS));
|
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);
|
||||||
|
if( boolldap == true) {
|
||||||
|
string token = Token(userldap);
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
token = token,
|
||||||
|
user = userldap.TX_PKDOC_USUMS
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BadRequest();
|
||||||
|
}
|
||||||
|
}else if(userldap.BL_VIENELDAP_USUMS != 1)
|
||||||
|
{
|
||||||
|
USUARIO? user = _context.USUARIOSMs.FirstOrDefault(u => u.TX_LOGINNAME_USUMS == login.TX_LOGINNAME_USUMS && u.TX_PASSWORD_USUMS == _encript.EncryptPwd(login.TX_PASSWORD_USUMS));
|
||||||
|
|
||||||
if (user == null) return BadRequest("Usuario o contrase<73>a incorrectos");
|
if (user == null) return BadRequest("Usuario o contrase<73>a incorrectos");
|
||||||
|
|
||||||
string token = Token(user);
|
string token = Token(user);
|
||||||
|
|
||||||
|
return Ok(new
|
||||||
|
{
|
||||||
|
token = token,
|
||||||
|
user = user.TX_PKDOC_USUMS
|
||||||
|
});
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
return BadRequest("Error");
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(new {
|
|
||||||
token = token,
|
|
||||||
user = user.TX_PKDOC_USUMS
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -21,6 +21,7 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
{
|
{
|
||||||
var consulta = from dm in _context.PERFILESMs
|
var consulta = from dm in _context.PERFILESMs
|
||||||
where dm.BL_ESTADO_PFL>=0
|
where dm.BL_ESTADO_PFL>=0
|
||||||
|
orderby dm.NU_PK_PFL ascending
|
||||||
select dm;
|
select dm;
|
||||||
|
|
||||||
return Ok(consulta);
|
return Ok(consulta);
|
||||||
@ -39,6 +40,13 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
|
|
||||||
if (guardado == null) return ValidationProblem();
|
if (guardado == null) return ValidationProblem();
|
||||||
|
|
||||||
|
if (guardado.TX_UUID_PFL == null)
|
||||||
|
{
|
||||||
|
Guid uuid = Guid.NewGuid();
|
||||||
|
var UUID = uuid.ToString();
|
||||||
|
guardado.TX_UUID_PFL = UUID;
|
||||||
|
}
|
||||||
|
|
||||||
_context.PERFILESMs.Add(guardado);
|
_context.PERFILESMs.Add(guardado);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
return Ok();
|
return Ok();
|
||||||
@ -59,6 +67,11 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
|
|
||||||
var existe = _context.PERFILESMs.Find(editado.NU_PK_PFL);
|
var existe = _context.PERFILESMs.Find(editado.NU_PK_PFL);
|
||||||
|
|
||||||
|
if (existe == null)
|
||||||
|
{
|
||||||
|
return BadRequest("Perfil no encontrado");
|
||||||
|
}
|
||||||
|
|
||||||
existe.TX_PERFIL_PFL = editado.TX_PERFIL_PFL;
|
existe.TX_PERFIL_PFL = editado.TX_PERFIL_PFL;
|
||||||
existe.NU_ROL_PFL = editado.NU_ROL_PFL;
|
existe.NU_ROL_PFL = editado.NU_ROL_PFL;
|
||||||
existe.BL_ESTADO_PFL = editado.BL_ESTADO_PFL;
|
existe.BL_ESTADO_PFL = editado.BL_ESTADO_PFL;
|
||||||
|
@ -53,7 +53,7 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
var count = 0;
|
var count = 0;
|
||||||
|
|
||||||
// Se cambia a estado 0 todos los perfiles por usuario existentes
|
// Se cambia a estado 0 todos los perfiles por usuario existentes
|
||||||
var existe_plfxusu = _context.PERFILESPORUSUARIOs.Where(x => x.BL_ESTADO_PFLXUSU == 1 && x.TX_FKDOC_USUMS == guardar[0].TX_FKDOC_USUMS).ToList();
|
var existe_plfxusu = _context.PERFILESPORUSUARIOs.Where(x => x.BL_ESTADO_PFLXUSU == 1 && x.TX_UUID_USUMS == guardar[0].TX_UUID_USUMS).ToList();
|
||||||
|
|
||||||
foreach (var cu in existe_plfxusu)
|
foreach (var cu in existe_plfxusu)
|
||||||
{
|
{
|
||||||
@ -68,7 +68,7 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
//Se comprueba existencia de cada pxu en base de datos
|
//Se comprueba existencia de cada pxu en base de datos
|
||||||
var existe_pxu = (from dm in _context.PERFILESPORUSUARIOs
|
var existe_pxu = (from dm in _context.PERFILESPORUSUARIOs
|
||||||
where dm.NU_FK_PFL == pxu.NU_FK_PFL
|
where dm.NU_FK_PFL == pxu.NU_FK_PFL
|
||||||
&& dm.TX_FKDOC_USUMS == pxu.TX_FKDOC_USUMS
|
&& dm.TX_UUID_USUMS == pxu.TX_UUID_USUMS
|
||||||
select dm).ToList();
|
select dm).ToList();
|
||||||
|
|
||||||
if (existe_pxu.Count() > 0)
|
if (existe_pxu.Count() > 0)
|
||||||
|
@ -8,6 +8,11 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Threading.Channels;
|
||||||
|
using MSAdminUsuarios.Dto.Externos.MsAgendaMedica;
|
||||||
|
using static MSAdminUsuarios.Utils.RabbitMQService;
|
||||||
|
using MSAdminUsuarios.Utils;
|
||||||
|
|
||||||
namespace MSAdminUsuarios.Controllers
|
namespace MSAdminUsuarios.Controllers
|
||||||
{
|
{
|
||||||
@ -17,11 +22,12 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
{
|
{
|
||||||
private readonly ModelContext _context;
|
private readonly ModelContext _context;
|
||||||
private readonly Encripter _encript = new();
|
private readonly Encripter _encript = new();
|
||||||
//private readonly IModel _channel;
|
private readonly IModel _channel;
|
||||||
|
|
||||||
public UsuariosController(ModelContext context)
|
public UsuariosController(ModelContext context, IModel channel)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
|
_channel = channel;
|
||||||
}
|
}
|
||||||
//public UsuariosController(ModelContext context, IModel channel)
|
//public UsuariosController(ModelContext context, IModel channel)
|
||||||
//{
|
//{
|
||||||
@ -208,7 +214,7 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
Guid uuid = Guid.NewGuid();
|
Guid uuid = Guid.NewGuid();
|
||||||
var UUID = uuid.ToString();
|
var UUID = uuid.ToString();
|
||||||
usuario.TX_UUID_USUMS = UUID;
|
usuario.TX_UUID_USUMS = UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.USUARIOSMs.Add(usuario);
|
_context.USUARIOSMs.Add(usuario);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
@ -284,6 +290,41 @@ namespace MSAdminUsuarios.Controllers
|
|||||||
_context.USUARIOSMs.Update(existe);
|
_context.USUARIOSMs.Update(existe);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 1. Perfiles del usuario
|
||||||
|
* 2. Buscar el perfil de medico
|
||||||
|
* 3. Si existe la relacion
|
||||||
|
* 3.1. Se hace la actualizacion de datos
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
List<PERFILPORUSUARIO> perfilesUsuario = this._context.PERFILESPORUSUARIOs.Where(pxu => pxu.TX_UUID_USUMS == existe.TX_UUID_USUMS).ToList();
|
||||||
|
|
||||||
|
if (perfilesUsuario.Count > 0 && perfilesUsuario.Exists(pxu => pxu.NU_FK_PFL == 1))
|
||||||
|
{
|
||||||
|
using (_channel)
|
||||||
|
{
|
||||||
|
var medico = new MedicoDto()
|
||||||
|
{
|
||||||
|
TX_UUID_MDC = existe.TX_UUID_USUMS,
|
||||||
|
TX_LUGARESATEN_MDC = existe.TX_SEDES_USUMS
|
||||||
|
};
|
||||||
|
|
||||||
|
string jsonMedico = JsonConvert.SerializeObject(medico);
|
||||||
|
|
||||||
|
string exchange = MQExchanges.AgendaMedica;
|
||||||
|
|
||||||
|
// Publish Usuario
|
||||||
|
RabbitMQMessages.PublishToMessageQueue(
|
||||||
|
channel: _channel,
|
||||||
|
exchange: exchange,
|
||||||
|
routingKey: $"{exchange}.{MQueues.medico}.patch",
|
||||||
|
message: jsonMedico
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
_errorModel.error = false;
|
_errorModel.error = false;
|
||||||
_errorModel.cuerpo.Add("Usuario actualizado.");
|
_errorModel.cuerpo.Add("Usuario actualizado.");
|
||||||
dbContextTransaction.Commit();
|
dbContextTransaction.Commit();
|
||||||
|
106
Microservicios/MsUsuarios/Controllers/UsuariosTempController.cs
Normal file
106
Microservicios/MsUsuarios/Controllers/UsuariosTempController.cs
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPatch]
|
||||||
|
public async Task<IActionResult> Patch(USUARIOSTEMP editado)
|
||||||
|
{
|
||||||
|
_errorModel = new ErrorModel();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (editado == null)
|
||||||
|
{
|
||||||
|
_errorModel.error = true;
|
||||||
|
_errorModel.cuerpo.Add("No se envió solicitud.");
|
||||||
|
return Conflict(_errorModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
USUARIOSTEMP? existente = await _context.USUARIOSTEMP.FirstOrDefaultAsync(ut => ut.NU_PK_USUTMP == editado.NU_PK_USUTMP);
|
||||||
|
if (existente == null)
|
||||||
|
{
|
||||||
|
_errorModel.error = true;
|
||||||
|
_errorModel.cuerpo.Add("Diseño no encontrado.");
|
||||||
|
return Conflict(_errorModel);
|
||||||
|
}
|
||||||
|
|
||||||
|
_context.Entry(existente).CurrentValues.SetValues(editado);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
namespace MSAdminUsuarios.Dto.Externos.MsAgendaMedica
|
||||||
|
{
|
||||||
|
public class MedicoDto
|
||||||
|
{
|
||||||
|
public int? NU_TIPOID_MDC { get; set; }
|
||||||
|
public string TX_DOCUMENTO_MDC { get; set; } = null!;
|
||||||
|
public string? TX_REGPROF_MDC { get; set; }
|
||||||
|
public string? TX_CODIGO_MDC { get; set; }
|
||||||
|
public int? NU_CARGO_MDC { get; set; }
|
||||||
|
public int? NU_TIPOPROF_MDC { get; set; }
|
||||||
|
public string? TX_PRINOMBRE_MDC { get; set; }
|
||||||
|
public string? TX_SEGNOMBRE_MDC { get; set; }
|
||||||
|
public string? TX_PRIAPELLIDO_MDC { get; set; }
|
||||||
|
public string? TX_SEGAPELLIDO_MDC { get; set; }
|
||||||
|
public string? TX_DIRECCION_MDC { get; set; }
|
||||||
|
public string? TX_EMAIL_MDC { get; set; }
|
||||||
|
public string? TX_TELEFONO_MDC { get; set; }
|
||||||
|
public string? NU_CELULAR_MDC { get; set; }
|
||||||
|
public int? NU_MODCONTRATACION_MDC { get; set; }
|
||||||
|
public string? TX_ESPECIALIDAD_MDC { get; set; }
|
||||||
|
public int? BL_ADSCRITO_MDC { get; set; }
|
||||||
|
public int? BL_PERCITAWEB_MDC { get; set; }
|
||||||
|
public int? BL_ESTADO_MDC { get; set; }
|
||||||
|
public int? NU_MAXCITASEXTRA_MDC { get; set; }
|
||||||
|
public string? TX_GRUPOSCUPS_MDC { get; set; }
|
||||||
|
public string? CL_AGENDA_MDC { get; set; }
|
||||||
|
public string? TX_LUGARESATEN_MDC { get; set; }
|
||||||
|
public string? TX_UUID_MDC { get; set; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,7 @@ namespace MSAdminUsuarios.Dto
|
|||||||
public int? NU_MODALIDADCTT_USUMS { get; set; }
|
public int? NU_MODALIDADCTT_USUMS { get; set; }
|
||||||
public string? TX_SEDES_USUMS { get; set; }
|
public string? TX_SEDES_USUMS { get; set; }
|
||||||
public int? NU_BLOQUEO_USUMS { get; set; }
|
public int? NU_BLOQUEO_USUMS { get; set; }
|
||||||
|
public string? TX_UUID_USUMS { get; set; }
|
||||||
public int? NU_TIPOUSUARIO_USUMS { get; set; }
|
public int? NU_TIPOUSUARIO_USUMS { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Auth\Auth.csproj" />
|
<ProjectReference Include="..\..\Auth\Auth.csproj" />
|
||||||
|
<ProjectReference Include="..\..\LdapLoginLib\LdapLoginLib.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
87
Microservicios/MsUsuarios/Utils/GenericTools.cs
Normal file
87
Microservicios/MsUsuarios/Utils/GenericTools.cs
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace MSAdminUsuarios.Utils
|
||||||
|
{
|
||||||
|
public static class GenericTools
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Permite clonar los valores de un objeto recorriendo cada parámetro
|
||||||
|
/// (<paramref name="Origin"/>,<paramref name="Destiny"/>,<paramref name="exceptions"/>).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Origin"> Objeto el cual se va a leer sus propiedades y valores</param>
|
||||||
|
/// <param name="Destiny"> Objeto el cual se va a ESCRIBIR los valores del origen basado en el nombre de la propiedad.</param>
|
||||||
|
/// <param name="exceptions"> Lista con nombres de propiedades a excluir de la copia</param>
|
||||||
|
public static void CloneObj<T>(T origin, T destiny, params Expression<Func<T, object>>[] exceptions) where T : class
|
||||||
|
{
|
||||||
|
var destinyProps = typeof(T).GetProperties();
|
||||||
|
var exceptionProps = new HashSet<string>();
|
||||||
|
if (exceptions != null)
|
||||||
|
{
|
||||||
|
foreach (var exception in exceptions)
|
||||||
|
{
|
||||||
|
if (exception.Body is MemberExpression memberExpression)
|
||||||
|
{
|
||||||
|
exceptionProps.Add(memberExpression.Member.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var prop in typeof(T).GetProperties())
|
||||||
|
{
|
||||||
|
var originName = prop.Name;
|
||||||
|
if (exceptionProps.Contains(originName))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (int i = 0; i < destinyProps.Length; i++)
|
||||||
|
{
|
||||||
|
if (destinyProps[i].Name == originName)
|
||||||
|
{
|
||||||
|
destinyProps[i].SetValue(destiny, prop.GetValue(origin, null));
|
||||||
|
i = destinyProps.Length + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Permite tomar parcialmente la información de un obejto Origen, validar si existe en el destino y si es diferente de nulo, para setearle el valor asignado
|
||||||
|
/// (<paramref name="Origin"/>,<paramref name="Destiny"/>,<paramref name="exceptions"/>).
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Origin"> Objeto el cual se va a leer sus propiedades y valores</param>
|
||||||
|
/// <param name="Destiny"> Objeto el cual se va a ESCRIBIR los valores del origen basado en el nombre de la propiedad.</param>
|
||||||
|
/// <param name="exceptions"> Lista con nombres de propiedades a excluir de la copia</param>
|
||||||
|
public static void ClonePartialObj<TFrom, TTo>(TFrom origin, TTo destiny, params Expression<Func<TTo, object>>[] exceptions) where TTo : class
|
||||||
|
{
|
||||||
|
var destinyProps = typeof(TTo).GetProperties();
|
||||||
|
var exceptionProps = new HashSet<string>();
|
||||||
|
if (exceptions != null)
|
||||||
|
{
|
||||||
|
foreach (var exception in exceptions)
|
||||||
|
{
|
||||||
|
if (exception.Body is MemberExpression memberExpression)
|
||||||
|
{
|
||||||
|
exceptionProps.Add(memberExpression.Member.Name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var prop in typeof(TFrom).GetProperties())
|
||||||
|
{
|
||||||
|
var originName = prop.Name;
|
||||||
|
var originValue = prop.GetValue(origin, null);
|
||||||
|
if (exceptionProps.Contains(originName))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
for (int i = 0; i < destinyProps.Length; i++)
|
||||||
|
{
|
||||||
|
if (destinyProps[i].Name == originName && originValue != null)
|
||||||
|
{
|
||||||
|
destinyProps[i].SetValue(destiny, originValue);
|
||||||
|
i = destinyProps.Length + 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
20
Microservicios/MsUsuarios/Utils/RabbitMQMessages.cs
Normal file
20
Microservicios/MsUsuarios/Utils/RabbitMQMessages.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using RabbitMQ.Client;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace MSAdminUsuarios.Utils
|
||||||
|
{
|
||||||
|
public static class RabbitMQMessages
|
||||||
|
{
|
||||||
|
public static void PublishToMessageQueue(IModel channel, string exchange, string routingKey, string message)
|
||||||
|
{
|
||||||
|
var body = Encoding.UTF8.GetBytes(message);
|
||||||
|
|
||||||
|
channel.BasicPublish(
|
||||||
|
exchange: exchange,
|
||||||
|
routingKey: routingKey,
|
||||||
|
basicProperties: null,
|
||||||
|
body: body
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,17 +12,53 @@ using System.Text;
|
|||||||
|
|
||||||
namespace MSAdminUsuarios.Utils
|
namespace MSAdminUsuarios.Utils
|
||||||
{
|
{
|
||||||
|
public readonly struct MQExchanges
|
||||||
|
{
|
||||||
|
public static readonly string AgendaMedica = "MsAgendaMedica";
|
||||||
|
public static readonly string Usuarios = "MSAdminUsuarios";
|
||||||
|
}
|
||||||
|
|
||||||
|
public readonly struct MQueues
|
||||||
|
{
|
||||||
|
public static readonly string medico = "UsuarioMedico";
|
||||||
|
public static readonly string PerfilesPorUsuario = "PerfilesPorUsuario";
|
||||||
|
public static readonly string Usuarios = "Usuarios";
|
||||||
|
public static readonly string FirmaUsuario = $"{Usuarios}.Firma";
|
||||||
|
|
||||||
|
}
|
||||||
|
public class MsComunicadoresModel
|
||||||
|
{
|
||||||
|
public string exchange { get; set; } = "";
|
||||||
|
public List<string> queues { get; set; } = new();
|
||||||
|
}
|
||||||
public static class RabbitMQService
|
public static class RabbitMQService
|
||||||
{
|
{
|
||||||
private static string[] _queues = Array.Empty<string>();
|
private static string[] _queues = Array.Empty<string>();
|
||||||
private static string _exchange = "MSAdminUsuarios";
|
private static string _exchange = "MSAdminUsuarios";
|
||||||
|
private static string Exchange
|
||||||
|
{
|
||||||
|
get { return _exchange; }
|
||||||
|
set { _exchange = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
private static readonly MsComunicadoresModel ExchangePrincipal = new()
|
||||||
|
{
|
||||||
|
exchange = Exchange,
|
||||||
|
queues = { MQueues.PerfilesPorUsuario, MQueues.Usuarios }
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
private static readonly List<MsComunicadoresModel> ListaExchanges = new() {
|
||||||
|
ExchangePrincipal,
|
||||||
|
new() {
|
||||||
|
exchange = MQExchanges.AgendaMedica,
|
||||||
|
queues = { MQueues.medico }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
public static IModel GetRabbitMQChannel(IServiceProvider serviceProvider, string projectName)
|
public static IModel GetRabbitMQChannel(IServiceProvider serviceProvider, string projectName)
|
||||||
{
|
{
|
||||||
//var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().AddEventLog());
|
|
||||||
//var logger = loggerFactory.CreateLogger("Rabbit1");
|
|
||||||
|
|
||||||
var connection = serviceProvider.GetService<IConnection>();
|
var connection = serviceProvider.GetService<IConnection>();
|
||||||
|
|
||||||
if (connection == null)
|
if (connection == null)
|
||||||
@ -32,39 +68,35 @@ namespace MSAdminUsuarios.Utils
|
|||||||
|
|
||||||
//Declare exchange if it doesnt already exist
|
//Declare exchange if it doesnt already exist
|
||||||
var exchangeName = projectName;
|
var exchangeName = projectName;
|
||||||
_exchange = exchangeName;
|
Exchange = exchangeName;
|
||||||
|
|
||||||
|
ListaExchanges.ForEach(ex => {
|
||||||
channel.ExchangeDeclare(
|
channel.ExchangeDeclare(
|
||||||
exchange: exchangeName,
|
exchange: ex.exchange,
|
||||||
type: ExchangeType.Topic,
|
type: ExchangeType.Topic,
|
||||||
durable: true,
|
|
||||||
autoDelete: false,
|
|
||||||
arguments: null
|
|
||||||
);
|
|
||||||
|
|
||||||
_queues = new string[]
|
|
||||||
{
|
|
||||||
$"{exchangeName}.PerfilesPorUsuario",
|
|
||||||
$"{exchangeName}.Usuarios"
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var queue in _queues)
|
|
||||||
{
|
|
||||||
channel.QueueDeclare(
|
|
||||||
queue: queue,
|
|
||||||
durable: true,
|
durable: true,
|
||||||
exclusive: false,
|
|
||||||
autoDelete: false,
|
autoDelete: false,
|
||||||
arguments: null
|
arguments: null
|
||||||
);
|
);
|
||||||
|
|
||||||
channel.QueueBind(
|
ex.queues.ForEach(q => {
|
||||||
queue: queue,
|
string queue = $"{ex.exchange}.{q}";
|
||||||
exchange: exchangeName,
|
|
||||||
routingKey: $"{queue}.*"
|
channel.QueueDeclare(
|
||||||
);
|
queue: queue,
|
||||||
}
|
durable: true,
|
||||||
|
exclusive: false,
|
||||||
|
autoDelete: false,
|
||||||
|
arguments: null
|
||||||
|
);
|
||||||
|
|
||||||
|
channel.QueueBind(
|
||||||
|
queue: queue,
|
||||||
|
exchange: ex.exchange,
|
||||||
|
routingKey: $"{queue}.*"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
@ -85,25 +117,20 @@ namespace MSAdminUsuarios.Utils
|
|||||||
};
|
};
|
||||||
|
|
||||||
IConnection connection = factory.CreateConnection();
|
IConnection connection = factory.CreateConnection();
|
||||||
IModel channel = connection.CreateModel();
|
IModel channelReceptor = connection.CreateModel();
|
||||||
|
|
||||||
EventingBasicConsumer consumer = new(channel);
|
EventingBasicConsumer consumer = new(channelReceptor);
|
||||||
|
|
||||||
consumer.Received += RabbitMQService.ConsumeRabbitMQEvent;
|
consumer.Received += RabbitMQService.ConsumeRabbitMQEvent;
|
||||||
|
|
||||||
List<string> queues = new()
|
|
||||||
{
|
|
||||||
$"{projectName}.PerfilesPorUsuario",
|
|
||||||
$"{projectName}.Usuarios",
|
|
||||||
};
|
|
||||||
|
|
||||||
foreach (var queue in queues)
|
foreach (var queue in ExchangePrincipal.queues)
|
||||||
{
|
{
|
||||||
channel.BasicConsume(
|
channelReceptor.BasicConsume(
|
||||||
queue: queue,
|
queue: $"{ExchangePrincipal.exchange}.{queue}",
|
||||||
autoAck: false,
|
autoAck: false,
|
||||||
consumer: consumer
|
consumer: consumer
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,7 +203,7 @@ namespace MSAdminUsuarios.Utils
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
var UsuariosCtrl = new UsuariosController(context);
|
var UsuariosCtrl = new UsuariosController(context, model);
|
||||||
if (controller[2] == "post")
|
if (controller[2] == "post")
|
||||||
{
|
{
|
||||||
var data = JsonConvert.DeserializeObject<USUARIO>(message);
|
var data = JsonConvert.DeserializeObject<USUARIO>(message);
|
||||||
|
Loading…
Reference in New Issue
Block a user