Add Fake Checkin for K6 Test
This commit is contained in:
parent
e1533a5c23
commit
127f21dc43
3 changed files with 65 additions and 7 deletions
|
|
@ -61,14 +61,9 @@ consumer.Received += async (model, ea) =>
|
||||||
|
|
||||||
channel.BasicConsume(queue: "checkin-queue", autoAck: true, consumer: consumer);
|
channel.BasicConsume(queue: "checkin-queue", autoAck: true, consumer: consumer);
|
||||||
|
|
||||||
Console.WriteLine("\nPress 'Enter' to exit the process...");
|
//Console.WriteLine("\nPress 'Enter' to exit the process...");
|
||||||
|
|
||||||
// another use of "Console.ReadKey()" method
|
|
||||||
// here it asks to press the enter key to exit
|
|
||||||
while (Console.ReadKey().Key != ConsoleKey.Enter)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
await Task.Delay(-1);
|
||||||
|
|
||||||
static void WriteToConsole(string message)
|
static void WriteToConsole(string message)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -483,6 +483,48 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
return Success(new { date = currentDate });
|
return Success(new { date = currentDate });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Fake Check in
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>
|
||||||
|
/// </returns>
|
||||||
|
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("check-in"), DisableRequestSizeLimit]
|
||||||
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
[AllowAnonymous]
|
||||||
|
public ActionResult<ResponseObject> FakeCheckIn([FromBody] FakeCheckTimeDto data)
|
||||||
|
{
|
||||||
|
var currentDate = DateTime.Now;
|
||||||
|
|
||||||
|
// 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);
|
||||||
|
|
||||||
|
// แปลง Object เป็น JSON สตริง
|
||||||
|
var serializedObject = JsonConvert.SerializeObject(data);
|
||||||
|
|
||||||
|
// แปลง 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 });
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check in Processing
|
/// Check in Processing
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,27 @@ namespace BMA.EHR.Leave.Service.DTOs.CheckIn
|
||||||
public string? Remark { get; set; } = string.Empty;
|
public string? Remark { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class FakeCheckTimeDto
|
||||||
|
{
|
||||||
|
public Guid? CheckInId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public double Lat { get; set; } = 0;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public double Lon { get; set; } = 0;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string POI { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public bool IsLocation { get; set; } = true;
|
||||||
|
|
||||||
|
public string? LocationName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string? Remark { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
public class CheckTimeDtoRB
|
public class CheckTimeDtoRB
|
||||||
{
|
{
|
||||||
public string Token { get; set; } = "";
|
public string Token { get; set; } = "";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue