154 lines
4.8 KiB
C#
154 lines
4.8 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using NLog;
|
|
using WebDoorCreator.API.Data;
|
|
|
|
namespace WebDoorCreator.API.Controllers
|
|
{
|
|
[Route("api/[controller]")]
|
|
[ApiController]
|
|
public class QueueController : ControllerBase
|
|
{
|
|
#region Public Constructors
|
|
|
|
public QueueController(IConfiguration configuration, QueueDataService DataService)
|
|
{
|
|
Log.Info("Starting QueueController");
|
|
_configuration = configuration;
|
|
QDataServ = DataService;
|
|
Log.Info("Avviato QueueController");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// Lunghezza coda in attesa
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("ActPendingLenght")]
|
|
public async Task<long> ActPendingLenght()
|
|
{
|
|
long numQueue = await QDataServ.NumRequestPending();
|
|
return numQueue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Lunghezza coda in fase di processing
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("ActProcessingLenght")]
|
|
public async Task<long> ActProcessingLenght()
|
|
{
|
|
long numQueue = await QDataServ.NumRequestProcessing();
|
|
return numQueue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invio elenco messaggi elaborazioni (se ho errori --> messaggi oppure libero)
|
|
/// </summary>
|
|
/// <param name="ProcMessageList"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("PostProcessingMessage")]
|
|
public async Task<bool> PostProcessingMessage(Dictionary<string, string> ProcMessageList)
|
|
{
|
|
bool answ = false;
|
|
await Task.Delay(1);
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invio elenco risultati elaborazioni (modalità boolean di esecuzione corretta)
|
|
/// </summary>
|
|
/// <param name="ProcResultList"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("PostProcessingResult")]
|
|
public async Task<bool> PostProcessingResult(Dictionary<string, bool> ProcResultList)
|
|
{
|
|
bool answ = false;
|
|
//VC19Check answ = new VC19Check()
|
|
//{
|
|
// Result = "KO"
|
|
//};
|
|
//var result = await _DataService.InsertCheck(DecodedData, "10.74.82.255");
|
|
//if (result)
|
|
//{
|
|
// answ = new VC19Check
|
|
// {
|
|
// DTRecord = DateTime.Now,
|
|
// CheckRecorded = true,
|
|
// TimbrRecorder = true,
|
|
// Result = $"OK, Check Recorded for {DecodedData.nam.fn} {DecodedData.nam.gn} {DecodedData.dob:yyyy.MM.dd}"
|
|
// };
|
|
//}
|
|
//else
|
|
//{ }
|
|
await Task.Delay(1);
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Invio elenco risultati elaborazioni come elenco di SVG
|
|
/// </summary>
|
|
/// <param name="ProcSvgList"></param>
|
|
/// <returns></returns>
|
|
[HttpPost("PostProcessingSvg")]
|
|
public async Task<bool> PostProcessingSvg(Dictionary<string, string> ProcSvgList)
|
|
{
|
|
bool answ = false;
|
|
await Task.Delay(1);
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco richieste in stato pending
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("ShowPending")]
|
|
public async Task<Dictionary<string, string>?> ShowPending()
|
|
{
|
|
var actQueue = await QDataServ.RequestPending();
|
|
return actQueue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco richeiste in stato processing
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("ShowProcessing")]
|
|
public async Task<Dictionary<string, string>> ShowProcessing()
|
|
{
|
|
var actQueue = await QDataServ.RequestProcessing();
|
|
return actQueue;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Chiede un numero massimo di items dalla coda NB:
|
|
/// - verranno tolti dalla coda FIFO richieste
|
|
/// - verranno messi nella coda FIFO processing
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet("TakeProcessingItems")]
|
|
public async Task<Dictionary<string, string>> TakeProcessingItems(int numItems)
|
|
{
|
|
var actQueue = await QDataServ.TakeProcessingItems(numItems);
|
|
return actQueue;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Private Fields
|
|
|
|
private static IConfiguration _configuration = null!;
|
|
|
|
private static Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private QueueDataService QDataServ { get; set; } = null!;
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |