Fix recupero RUID x call REST
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using EgwCoreLib.Lux.Data.Services;
|
||||
using EgwMultiEngineManager.Data;
|
||||
using Lux.API.Services;
|
||||
using Microsoft.AspNetCore.Cors.Infrastructure;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Newtonsoft.Json;
|
||||
@@ -18,10 +19,17 @@ namespace Lux.API.Controllers
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public ProdController(ProdService prodService, ExternalMessageProcessor extMessProc)
|
||||
/// <summary>
|
||||
/// Costruttore metodo
|
||||
/// </summary>
|
||||
/// <param name="prodService"></param>
|
||||
/// <param name="extMessProc"></param>
|
||||
/// <param name="crService"></param>
|
||||
public ProdController(ProdService prodService, ExternalMessageProcessor extMessProc, CalcRuidService crService)
|
||||
{
|
||||
PService = prodService;
|
||||
EMProc = extMessProc;
|
||||
_calcRuidService = crService;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
@@ -32,7 +40,7 @@ namespace Lux.API.Controllers
|
||||
/// Chiamata GET: test status alive
|
||||
/// GET: api/Prod/alive
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <param name="id">uid oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("alive")]
|
||||
public async Task<IActionResult> Alive()
|
||||
@@ -51,13 +59,39 @@ namespace Lux.API.Controllers
|
||||
/// GET: api/Prod/getjob/ABC012345
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getjob/{id}")]
|
||||
public async Task<ActionResult<QuestionDTO>> GetJob(string id)
|
||||
[HttpGet("getjob/{uid}")]
|
||||
public async Task<ActionResult<QuestionDTO>> GetJob(string uid)
|
||||
{
|
||||
var result = await PService.GetJob(id);
|
||||
QuestionDTO deserRes = JsonConvert.DeserializeObject<QuestionDTO>(result);
|
||||
return Ok(deserRes);
|
||||
var result = await PService.GetJob(uid);
|
||||
QuestionDTO? deserRes = JsonConvert.DeserializeObject<QuestionDTO>(result);
|
||||
if (deserRes != null)
|
||||
{
|
||||
// verifico RUID code x rigenerarlo...
|
||||
if (deserRes.Args != null)
|
||||
{
|
||||
// elimino vecchio RUID se esistesse...
|
||||
if (deserRes.Args.ContainsKey("RUID"))
|
||||
{
|
||||
deserRes.Args.Remove("RUID");
|
||||
}
|
||||
// lo aggiungo!
|
||||
string envir = $"{deserRes.ExecEnvironment}";
|
||||
var mode = deserRes.Args["Mode"];
|
||||
var sub = deserRes.Args["SubMode"];
|
||||
string type = string.IsNullOrEmpty(sub) ? mode : $"{mode}-{sub}";
|
||||
// creo registrazione richiesta...
|
||||
var ruid = await _calcRuidService.AddRequestAsync(envir, type, uid);
|
||||
// aggiungo RUID effettivo
|
||||
deserRes.Args.Add("RUID", ruid);
|
||||
}
|
||||
return Ok(deserRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound("No Data Found");
|
||||
}
|
||||
}
|
||||
private readonly CalcRuidService _calcRuidService;
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata GET:
|
||||
@@ -70,9 +104,35 @@ namespace Lux.API.Controllers
|
||||
public async Task<ActionResult<QuestionDTO>> GetNext()
|
||||
{
|
||||
var result = await PService.GetNext();
|
||||
//return Ok(result);
|
||||
QuestionDTO deserRes = JsonConvert.DeserializeObject<QuestionDTO>(result);
|
||||
return Ok(deserRes);
|
||||
QuestionDTO? deserRes = JsonConvert.DeserializeObject<QuestionDTO>(result);
|
||||
if (deserRes != null)
|
||||
{
|
||||
// verifico RUID code x rigenerarlo...
|
||||
if (deserRes.Args != null)
|
||||
{
|
||||
// elimino vecchio RUID se esistesse...
|
||||
if (deserRes.Args.ContainsKey("RUID"))
|
||||
{
|
||||
deserRes.Args.Remove("RUID");
|
||||
}
|
||||
// lo aggiungo!
|
||||
string envir = $"{deserRes.ExecEnvironment}";
|
||||
var mode = deserRes.Args["Mode"];
|
||||
var sub = deserRes.Args["SubMode"];
|
||||
var uid = deserRes.Args["UID"];
|
||||
string type = string.IsNullOrEmpty(sub) ? mode : $"{mode}-{sub}";
|
||||
|
||||
// creo registrazione richiesta...
|
||||
var ruid = await _calcRuidService.AddRequestAsync(envir, type, uid);
|
||||
// aggiungo RUID effettivo
|
||||
deserRes.Args.Add("RUID", ruid);
|
||||
}
|
||||
return Ok(deserRes);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NotFound("No Data Available");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -112,7 +172,7 @@ namespace Lux.API.Controllers
|
||||
/// GET: api/Prod/rep-answer/ABC012345
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("rep-answer/{id}")]
|
||||
[HttpGet("rep-answer/{uid}")]
|
||||
public async Task<ActionResult<string>> ReplayAnswer(string id, int env)
|
||||
{
|
||||
Constants.EXECENVIRONMENTS envir = (Constants.EXECENVIRONMENTS)env;
|
||||
@@ -217,7 +277,7 @@ namespace Lux.API.Controllers
|
||||
/// GET: api/Prod/queue-len/waiting
|
||||
/// GET: api/Prod/queue-len/running
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <param name="id">uid oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("qlen/{type}")]
|
||||
public async Task<IActionResult> QueueLen(QueueType type = QueueType.waiting)
|
||||
@@ -230,7 +290,7 @@ namespace Lux.API.Controllers
|
||||
/// Chiamata GET: dizionario stato richieste
|
||||
/// GET: api/Prod/queue-status/
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
/// <param name="id">uid oggetto</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("qstatus")]
|
||||
public async Task<IActionResult> QueueStatus()
|
||||
|
||||
Reference in New Issue
Block a user