Update API x elenco hwlist (get)
This commit is contained in:
@@ -13,11 +13,12 @@ namespace Lux.API.Controllers
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public WindowController(IConfiguration config, IRedisService redisService, ImageCacheService imgServ)
|
||||
public WindowController(IConfiguration config, IRedisService redisService, ImageCacheService imgServ, ConfigDataService confServ)
|
||||
{
|
||||
_config = config;
|
||||
_redisService = redisService;
|
||||
_imgService = imgServ;
|
||||
_confService = confServ;
|
||||
pubChannel = _config.GetValue<string>("ServerConf:PubChannel") ?? "";
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ namespace Lux.API.Controllers
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata GET: riceve Json in formato serializzato, invia richiesta modo 3 (HardwareModelList)
|
||||
/// Chiamata GET: invia richiesta modo 3 (HardwareModelList) che sarà poi salvata
|
||||
/// GET: api/window/hwlist
|
||||
/// </summary>
|
||||
/// <param name="id">id oggetto</param>
|
||||
@@ -86,6 +87,19 @@ namespace Lux.API.Controllers
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string hwContent = "";
|
||||
await sendHwReq();
|
||||
hwContent = "DONE";
|
||||
sw.Stop();
|
||||
Log.Info($"getHardwareList | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
return Ok(hwContent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue invio effettivo richiesta elenco HW list
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private async Task sendHwReq()
|
||||
{
|
||||
Dictionary<string, string> DictExec = new Dictionary<string, string>();
|
||||
DictExec.Add("Mode", $"{(int)Enums.EngineQueryType.HardwareModelList}");
|
||||
// da rivedere?
|
||||
@@ -96,10 +110,38 @@ namespace Lux.API.Controllers
|
||||
// da modificare con tipo richiesta...
|
||||
QuestionDTO currArgs = new QuestionDTO(nId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, DictExec);
|
||||
await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs);
|
||||
hwContent = "DONE";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Chiamata GET:
|
||||
/// - se trova in cache risponde con elenco hw già ricevuto
|
||||
/// - se non trova invia richiesta modo 3 (HardwareModelList) che sarà poi salvata
|
||||
/// GET: api/window/hwlist/nome_produttore
|
||||
/// </summary>
|
||||
/// <param name="id">nome del produttore, es HW.AGB (default)</param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("hwlist/{id}")]
|
||||
public async Task<ActionResult<List<Egw.Window.Data.Hardware>>> getHardwareList(string id)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
string hwReq = id ?? "HW.AGB";
|
||||
var answ = _confService.ElencoHw(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, hwReq);
|
||||
if (answ == null || answ.Count == 0)
|
||||
{
|
||||
await sendHwReq();
|
||||
answ = new List<Egw.Window.Data.Hardware>();
|
||||
}
|
||||
// filtro quelli default/non significativi (famili=descript)
|
||||
else
|
||||
{
|
||||
answ = answ
|
||||
.Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase))
|
||||
.ToList();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Info($"getHardwareList | {sw.Elapsed.TotalMilliseconds:N3} ms");
|
||||
return Ok(hwContent);
|
||||
return Ok(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -224,6 +266,7 @@ namespace Lux.API.Controllers
|
||||
#region Private Properties
|
||||
|
||||
private ImageCacheService _imgService { get; set; }
|
||||
private ConfigDataService _confService { get; set; }
|
||||
|
||||
#endregion Private Properties
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user