Revert "Add Queue to Dependency Injection (Optimize)"
This reverts commit cf7a79166a.
This commit is contained in:
parent
cf7a79166a
commit
a27f3551d8
3 changed files with 35 additions and 118 deletions
|
|
@ -14,7 +14,6 @@ using BMA.EHR.Leave.Service.DTOs.ChangeRound;
|
|||
using BMA.EHR.Leave.Service.DTOs.CheckIn;
|
||||
using BMA.EHR.Leave.Service.DTOs.DutyTime;
|
||||
using BMA.EHR.Leave.Service.DTOs.LeaveRequest;
|
||||
using BMA.EHR.Leave.Service.Services;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
|
@ -59,10 +58,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
private readonly string _bucketName = "check-in";
|
||||
|
||||
private readonly string _fakeQueueName = "fake-checkin-queue";
|
||||
private readonly string _realQueueName = "checkin-queue";
|
||||
private readonly RabbitCheckInService _rabbitCheckInService;
|
||||
|
||||
#endregion
|
||||
|
||||
#region " Constuctor and Destructor "
|
||||
|
|
@ -80,8 +75,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
AdditionalCheckRequestRepository additionalCheckRequestRepository,
|
||||
UserCalendarRepository userCalendarRepository,
|
||||
CommandRepository commandRepository,
|
||||
LeaveRequestRepository leaveRequestRepository,
|
||||
RabbitCheckInService rabbitCheckInService)
|
||||
LeaveRequestRepository leaveRequestRepository)
|
||||
{
|
||||
_dutyTimeRepository = dutyTimeRepository;
|
||||
_context = context;
|
||||
|
|
@ -97,7 +91,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
_userCalendarRepository = userCalendarRepository;
|
||||
_commandRepository = commandRepository;
|
||||
_leaveRequestRepository = leaveRequestRepository;
|
||||
_rabbitCheckInService = rabbitCheckInService;
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -465,32 +458,27 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
Token = AccessToken ?? ""
|
||||
};
|
||||
|
||||
//// create connection
|
||||
//var factory = new ConnectionFactory()
|
||||
//{
|
||||
// HostName = _configuration["Rabbit:Host"],
|
||||
// UserName = _configuration["Rabbit:User"],
|
||||
// Password = _configuration["Rabbit:Password"],
|
||||
//};
|
||||
// create connection
|
||||
var factory = new ConnectionFactory()
|
||||
{
|
||||
HostName = _configuration["Rabbit:Host"],
|
||||
UserName = _configuration["Rabbit:User"],
|
||||
Password = _configuration["Rabbit:Password"],
|
||||
};
|
||||
|
||||
//// create channel
|
||||
//using var connection = factory.CreateConnection();
|
||||
//using var channel = connection.CreateModel();
|
||||
//channel.QueueDeclare(queue: "checkin-queue", durable: false, exclusive: false, autoDelete: false, arguments: null);
|
||||
|
||||
//// แปลง Object เป็น JSON สตริง
|
||||
//var serializedObject = JsonConvert.SerializeObject(checkData);
|
||||
|
||||
//// แปลง JSON สตริงเป็น byte array
|
||||
//var body = Encoding.UTF8.GetBytes(serializedObject);
|
||||
|
||||
//channel.BasicPublish(exchange: "", routingKey: "checkin-queue", basicProperties: null, body: body);
|
||||
//Console.WriteLine($"Send to Queue: {serializedObject}");
|
||||
// create channel
|
||||
using var connection = factory.CreateConnection();
|
||||
using var channel = connection.CreateModel();
|
||||
channel.QueueDeclare(queue: "checkin-queue", durable: false, exclusive: false, autoDelete: false, arguments: null);
|
||||
|
||||
// แปลง Object เป็น JSON สตริง
|
||||
var serializedObject = JsonConvert.SerializeObject(checkData);
|
||||
var body = Encoding.UTF8.GetBytes(serializedObject);
|
||||
_rabbitCheckInService.SendMessageToQueue(_realQueueName, body);
|
||||
|
||||
// แปลง JSON สตริงเป็น byte array
|
||||
var body = Encoding.UTF8.GetBytes(serializedObject);
|
||||
|
||||
channel.BasicPublish(exchange: "", routingKey: "checkin-queue", basicProperties: null, body: body);
|
||||
Console.WriteLine($"Send to Queue: {serializedObject}");
|
||||
|
||||
return Success(new { date = currentDate });
|
||||
}
|
||||
|
|
@ -512,25 +500,27 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
var currentDate = DateTime.Now;
|
||||
|
||||
//// create connection
|
||||
//var factory = new ConnectionFactory()
|
||||
//{
|
||||
// HostName = _configuration["Rabbit:Host"],
|
||||
// UserName = _configuration["Rabbit:User"],
|
||||
// Password = _configuration["Rabbit:Password"],
|
||||
//};
|
||||
// create connection
|
||||
var factory = new ConnectionFactory()
|
||||
{
|
||||
HostName = _configuration["Rabbit:Host"],
|
||||
UserName = _configuration["Rabbit:User"],
|
||||
Password = _configuration["Rabbit:Password"],
|
||||
};
|
||||
|
||||
//// create channel
|
||||
//using var connection = factory.CreateConnection();
|
||||
//using var channel = connection.CreateModel();
|
||||
//channel.QueueDeclare(queue: "fake-checkin-queue", durable: false, exclusive: false, autoDelete: false, arguments: null);
|
||||
// create channel
|
||||
using var connection = factory.CreateConnection();
|
||||
using var channel = connection.CreateModel();
|
||||
channel.QueueDeclare(queue: "fake-checkin-queue", durable: false, exclusive: false, autoDelete: false, arguments: null);
|
||||
|
||||
// แปลง Object เป็น JSON สตริง
|
||||
var serializedObject = JsonConvert.SerializeObject(data);
|
||||
var body = Encoding.UTF8.GetBytes(serializedObject);
|
||||
_rabbitCheckInService.SendMessageToQueue(_fakeQueueName, body);
|
||||
|
||||
//channel.BasicPublish(exchange: "", routingKey: "fake-checkin-queue", basicProperties: null, body: body);
|
||||
//Console.WriteLine($"Send to Queue: {serializedObject}");
|
||||
// แปลง JSON สตริงเป็น byte array
|
||||
var body = Encoding.UTF8.GetBytes(serializedObject);
|
||||
|
||||
channel.BasicPublish(exchange: "", routingKey: "fake-checkin-queue", basicProperties: null, body: body);
|
||||
Console.WriteLine($"Send to Queue: {serializedObject}");
|
||||
|
||||
return Success(new { date = currentDate });
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue