Continuo integrazione metodi tracciamento RUID
This commit is contained in:
@@ -5,6 +5,7 @@ using EgwMultiEngineManager.Data;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using NLog;
|
||||
using System.Diagnostics;
|
||||
using ZXing.QrCode.Internal;
|
||||
|
||||
namespace Lux.API.Controllers
|
||||
{
|
||||
@@ -14,12 +15,13 @@ namespace Lux.API.Controllers
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public GenericController(IConfiguration config, IRedisService redisService, ImageCacheService imgServ)
|
||||
public GenericController(IConfiguration config, IRedisService redisService, ImageCacheService imgServ, CalcRuidService crService)
|
||||
{
|
||||
_config = config;
|
||||
_redisService = redisService;
|
||||
_imgService = imgServ;
|
||||
chPub = _config.GetValue<string>("ServerConf:ChannelPub") ?? "";
|
||||
_calcRuidService = crService;
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
@@ -42,7 +44,10 @@ namespace Lux.API.Controllers
|
||||
// ...se ricevo percorso --> leggo jwd/svg cablato
|
||||
if (currReq != null)
|
||||
{
|
||||
// preparo variabili di base
|
||||
Dictionary<string, string> DictExec = currReq.DictExec;
|
||||
string envir = $"{currReq.EnvType}";
|
||||
string type = "ND";
|
||||
// controllo se mancassero parametri...
|
||||
if (!DictExec.ContainsKey("Mode"))
|
||||
{
|
||||
@@ -58,8 +63,13 @@ namespace Lux.API.Controllers
|
||||
}
|
||||
if (!DictExec.ContainsKey("RUID"))
|
||||
{
|
||||
// FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!!
|
||||
DictExec.Add("RUID", GenerateId());
|
||||
var mode = DictExec["Mode"];
|
||||
var sub = DictExec["SubMode"];
|
||||
type = string.IsNullOrEmpty(sub) ? mode : $"{mode}-{sub}";
|
||||
// creo registrazione richiesta...
|
||||
var ruid = await _calcRuidService.AddRequestAsync(envir, type, id);
|
||||
// aggiungo RUID effettivo
|
||||
DictExec.Add("RUID", ruid);
|
||||
}
|
||||
int nId = 1;
|
||||
// da modificare con tipo richiesta...
|
||||
@@ -73,17 +83,6 @@ namespace Lux.API.Controllers
|
||||
return Ok(retVal);
|
||||
}
|
||||
|
||||
private readonly Random _rnd = new Random();
|
||||
// ---------------------------------------------------------
|
||||
// ✅ ID incrementale: timestamp ms + random 4-6 chars
|
||||
// ---------------------------------------------------------
|
||||
private string GenerateId()
|
||||
{
|
||||
long ts = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
string rand = Convert.ToString(_rnd.Next(0x1000, 0xFFFF), 16).ToUpper();
|
||||
return $"{ts}-{rand}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata POST: riceve Json in formato JWD serializzato, invia richiesta calcolo modo 2 (BOM)
|
||||
/// PUT: api/window/bom/00000000-0000-0000-0000-000000000000
|
||||
@@ -99,6 +98,7 @@ namespace Lux.API.Controllers
|
||||
|
||||
// se messaggio vuoto --> uso default!
|
||||
currSer = string.IsNullOrEmpty(currSer) ? "" : currSer;
|
||||
var bomEnvir = Constants.EXECENVIRONMENTS.WINDOW;
|
||||
|
||||
// ...se ricevo percorso --> leggo jwd/svg cablato
|
||||
if (!string.IsNullOrEmpty(currSer))
|
||||
@@ -109,13 +109,16 @@ namespace Lux.API.Controllers
|
||||
// UID cablato x ora...
|
||||
DictExec.Add("UID", id);
|
||||
|
||||
// FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!!
|
||||
DictExec.Add("RUID", GenerateId());
|
||||
|
||||
string envir = $"{bomEnvir}";
|
||||
string type = $"{Enums.QuestionModes.BOM}";
|
||||
var ruid = await _calcRuidService.AddRequestAsync(envir, type, id);
|
||||
// Aggiungo RUID effettivo
|
||||
DictExec.Add("RUID", ruid);
|
||||
// valore serializzato x BOM
|
||||
DictExec.Add("SerializedData", currSer);
|
||||
int nId = 1;
|
||||
// da modificare con tipo richiesta...
|
||||
QuestionDTO currArgs = new QuestionDTO(nId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, DictExec);
|
||||
QuestionDTO currArgs = new QuestionDTO(nId, bomEnvir, DictExec);
|
||||
|
||||
await _redisService.PublishAsync(chPub, currArgs.sProcessArgs);
|
||||
retVal = "DONE";
|
||||
@@ -130,8 +133,10 @@ namespace Lux.API.Controllers
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private readonly CalcRuidService _calcRuidService;
|
||||
private readonly IRedisService _redisService;
|
||||
private readonly string chPub = "";
|
||||
|
||||
private IConfiguration _config;
|
||||
|
||||
#endregion Private Fields
|
||||
@@ -141,5 +146,10 @@ namespace Lux.API.Controllers
|
||||
private ImageCacheService _imgService { get; set; }
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user