Ajustes para MsAgendaMedica
This commit is contained in:
parent
848232b585
commit
d24b526f2f
@ -76,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);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -86,7 +88,7 @@ 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);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -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; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ namespace MSAdminUsuarios.Context
|
|||||||
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; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,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();
|
||||||
|
@ -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();
|
||||||
|
@ -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; }
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
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,45 +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.QueueBind(
|
channel.QueueDeclare(
|
||||||
queue: $"{exchangeName}.Usuarios",
|
queue: queue,
|
||||||
exchange: exchangeName,
|
durable: true,
|
||||||
routingKey: $"{exchangeName}.Usuarios.*.*"
|
exclusive: false,
|
||||||
);
|
autoDelete: false,
|
||||||
|
arguments: null
|
||||||
|
);
|
||||||
|
|
||||||
|
channel.QueueBind(
|
||||||
|
queue: queue,
|
||||||
|
exchange: ex.exchange,
|
||||||
|
routingKey: $"{queue}.*"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
return channel;
|
return channel;
|
||||||
}
|
}
|
||||||
@ -80,46 +106,32 @@ namespace MSAdminUsuarios.Utils
|
|||||||
RabbitMQConfig mqConfig = builder.Configuration.GetSection("RabbitMQConfig").Get<RabbitMQConfig>();
|
RabbitMQConfig mqConfig = builder.Configuration.GetSection("RabbitMQConfig").Get<RabbitMQConfig>();
|
||||||
|
|
||||||
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().AddEventLog());
|
var loggerFactory = LoggerFactory.Create(builder => builder.AddConsole().AddEventLog());
|
||||||
try
|
//var logger = loggerFactory.CreateLogger("Rabbit2");
|
||||||
|
//logger.LogInformation("Inicia Rabbitmq con");
|
||||||
|
|
||||||
|
ConnectionFactory factory = new()
|
||||||
{
|
{
|
||||||
//var logger = loggerFactory.CreateLogger("Rabbit2");
|
HostName = mqConfig.HostName,
|
||||||
//logger.LogInformation("Inicia Rabbitmq con");
|
UserName = mqConfig.UserName,
|
||||||
|
Password = mqConfig.Password,
|
||||||
ConnectionFactory factory = new()
|
|
||||||
{
|
|
||||||
HostName = mqConfig.HostName,
|
|
||||||
UserName = mqConfig.UserName,
|
|
||||||
Password = mqConfig.Password,
|
|
||||||
};
|
|
||||||
|
|
||||||
IConnection connection = factory.CreateConnection();
|
|
||||||
IModel channel = connection.CreateModel();
|
|
||||||
|
|
||||||
EventingBasicConsumer consumer = new(channel);
|
|
||||||
|
|
||||||
consumer.Received += RabbitMQService.ConsumeRabbitMQEvent;
|
|
||||||
|
|
||||||
List<string> queues = new()
|
|
||||||
{
|
|
||||||
$"{projectName}.PerfilesPorUsuario",
|
|
||||||
$"{projectName}.Usuarios",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
foreach (var queue in queues)
|
IConnection connection = factory.CreateConnection();
|
||||||
{
|
IModel channelReceptor = connection.CreateModel();
|
||||||
channel.BasicConsume(
|
|
||||||
queue: queue,
|
|
||||||
autoAck: false,
|
|
||||||
consumer: consumer
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
|
|
||||||
Console.WriteLine(ex.Message);
|
EventingBasicConsumer consumer = new(channelReceptor);
|
||||||
|
|
||||||
|
consumer.Received += RabbitMQService.ConsumeRabbitMQEvent;
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var queue in ExchangePrincipal.queues)
|
||||||
|
{
|
||||||
|
channelReceptor.BasicConsume(
|
||||||
|
queue: $"{ExchangePrincipal.exchange}.{queue}",
|
||||||
|
autoAck: false,
|
||||||
|
consumer: consumer
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -191,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