diff --git a/EgwCoreLib.Lux.Core/RestPayload/CalcRequestDTO.cs b/EgwCoreLib.Lux.Core/RestPayload/CalcRequestDTO.cs new file mode 100644 index 00000000..f7408892 --- /dev/null +++ b/EgwCoreLib.Lux.Core/RestPayload/CalcRequestDTO.cs @@ -0,0 +1,21 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EgwCoreLib.Lux.Core.RestPayload +{ + public class CalcRequestDTO + { + /// + /// Tipologia di richiesta da inviare al calcolo + /// + public string ReqType { get; set; } = ""; + + /// + /// Dizionario completo dei parametri da inviare + /// + public Dictionary DictExec { get; set; } = new Dictionary(); + } +} diff --git a/Lux.API/Controllers/GenericController.cs b/Lux.API/Controllers/GenericController.cs new file mode 100644 index 00000000..57e5ef66 --- /dev/null +++ b/Lux.API/Controllers/GenericController.cs @@ -0,0 +1,99 @@ +using EgwCoreLib.Lux.Core.RestPayload; +using EgwCoreLib.Lux.Data.Services; +using EgwMultiEngineManager; +using Microsoft.AspNetCore.Mvc; +using NLog; +using System.Diagnostics; + +namespace Lux.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class GenericController : ControllerBase + { + #region Public Constructors + + public GenericController(IConfiguration config, IRedisService redisService, ImageCacheService imgServ) + { + _config = config; + _redisService = redisService; + _imgService = imgServ; + pubChannel = _config.GetValue("ServerConf:PubChannel") ?? ""; + } + + #endregion Public Constructors + + #region Public Methods + + + /// + /// Chiamata POST: specificando il tipo di richiesta + dizionario parametri esegue chiamata + /// PUT: api/generic/calc/00000000-0000-0000-0000-000000000000 + /// + /// id oggetto + /// + [HttpPost("calc/{id}")] + public async Task> calc(string id, [FromBody] CalcRequestDTO currReq) + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + string svgContent = ""; + + // se contiene ".svg" lo levo... + if (id.EndsWith(".svg")) + { + id = id.Replace(".svg", ""); + } + + // ...se ricevo percorso --> leggo jwd/svg cablato + if (currReq != null) + { + Dictionary DictExec = currReq.DictExec; + // controllo se mancassero parametri... + if(!DictExec.ContainsKey("Mode")) + { + DictExec.Add("Mode", "1"); + } + if (!DictExec.ContainsKey("UID")) + { + DictExec.Add("UID", id); + } + if (!DictExec.ContainsKey("Jwd")) + { + DictExec.Add("Jwd", demoJwd); + } + int nId = 1; + // da modificare con tipo richiesta... + ProcessArgs currArgs = new ProcessArgs(nId, DictExec); + + await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs); + svgContent = "DONE"; + } + sw.Stop(); + Log.Info($"calcSvg | {sw.Elapsed.TotalMilliseconds:N3} ms"); + return Ok(svgContent); + } + + #endregion Public Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + private readonly IRedisService _redisService; + private readonly string pubChannel = ""; + private IConfiguration _config; + + /// + /// Demorichiesta jwd x fare test richiesta calcolo + /// + private string demoJwd = "{\r\n\"ProfilePath\":\"Profilo78\",\r\n\"AreaList\":[\r\n{\r\n\"Shape\":\"RECTANGLE\",\r\n\"DimensionList\":[\r\n{\r\n\"nIndex\":1,\r\n\"sName\":\"Width\",\r\n\"dValue\":1200.0\r\n},\r\n{\r\n\"nIndex\":2,\r\n\"sName\":\"Height\",\r\n\"dValue\":1500.0\r\n}\r\n],\r\n\"JointList\":[\r\n{\r\n\"nIndex\":1,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":2,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":3,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":4,\r\n\"JointType\":\"FULL_V\"\r\n}\r\n],\r\n\"BottomRail\":false,\r\n\"BottomRailQty\":0,\r\n\"AreaList\":[\r\n{\r\n\"bIsSashVertical\":true,\r\n\"SashList\":[\r\n{\r\n\"OpeningType\":\"TURNONLY_LEFT\",\r\n\"bHasHandle\":false,\r\n\"dDimension\":50.0\r\n},\r\n{\r\n\"OpeningType\":\"TILTTURN_RIGHT\",\r\n\"bHasHandle\":true,\r\n\"dDimension\":50.0\r\n}\r\n],\r\n\"SashType\":\"NULL\",\r\n\"JointList\":[\r\n{\r\n\"nIndex\":1,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":2,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":3,\r\n\"JointType\":\"FULL_V\"\r\n},\r\n{\r\n\"nIndex\":4,\r\n\"JointType\":\"FULL_V\"\r\n}\r\n],\r\n\"Hardware\":\"000000\",\r\n\"AreaList\":[\r\n{\r\n\"AreaList\":[\r\n{\r\n\"FillType\":\"GLASS\",\r\n\"AreaList\":[],\r\n\"AreaType\":\"FILL\"\r\n}\r\n],\r\n\"AreaType\":\"SPLITTED\"\r\n},\r\n{\r\n\"AreaList\":[\r\n{\r\n\"FillType\":\"GLASS\",\r\n\"AreaList\":[],\r\n\"AreaType\":\"FILL\"\r\n}\r\n],\r\n\"AreaType\":\"SPLITTED\"\r\n}\r\n],\r\n\"AreaType\":\"SASH\"\r\n}\r\n],\r\n\"AreaType\":\"FRAME\"\r\n}\r\n]\r\n}"; + + #endregion Private Fields + + #region Private Properties + + private ImageCacheService _imgService { get; set; } + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/Lux.API/Controllers/WindowController.cs b/Lux.API/Controllers/WindowController.cs index e0c83adb..e05cbcb3 100644 --- a/Lux.API/Controllers/WindowController.cs +++ b/Lux.API/Controllers/WindowController.cs @@ -12,7 +12,7 @@ namespace Lux.API.Controllers { #region Public Constructors - public WindowController(IConfiguration config, ImageCacheService imgServ, IRedisService redisService) + public WindowController(IConfiguration config, IRedisService redisService, ImageCacheService imgServ) { _config = config; _redisService = redisService; @@ -32,7 +32,7 @@ namespace Lux.API.Controllers } /// - /// Chiamata POST: riceve Json in formato JWD serializzato, invia richeista calcolo modo 2 (BOM) + /// Chiamata POST: riceve Json in formato JWD serializzato, invia richiesta calcolo modo 2 (BOM) /// PUT: api/window/bom/00000000-0000-0000-0000-000000000000 /// /// id oggetto @@ -56,19 +56,16 @@ namespace Lux.API.Controllers // ...se ricevo percorso --> leggo jwd/svg cablato if (!string.IsNullOrEmpty(currJwd)) { - if (true) - { - Dictionary DictExec = new Dictionary(); - DictExec.Add("Mode", "2"); - // UID cablato x ora... - DictExec.Add("UID", id); - DictExec.Add("Jwd", currJwd); - int nId = 1; - ProcessArgs currArgs = new ProcessArgs(nId, DictExec); + Dictionary DictExec = new Dictionary(); + DictExec.Add("Mode", "2"); + // UID cablato x ora... + DictExec.Add("UID", id); + DictExec.Add("Jwd", currJwd); + int nId = 1; + ProcessArgs currArgs = new ProcessArgs(nId, DictExec); - await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs); - svgContent = "DONE"; - } + await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs); + svgContent = "DONE"; } sw.Stop(); Log.Info($"getBom | {sw.Elapsed.TotalMilliseconds:N3} ms"); @@ -76,7 +73,7 @@ namespace Lux.API.Controllers } /// - /// Chiamata POST: riceve Json in formato JWD serializzato, lo ripete come risposta + /// Chiamata GET: restituisce file SVG (da file o da cache) /// PUT: api/window/svg/00000000-0000-0000-0000-000000000000 /// /// id oggetto @@ -98,7 +95,7 @@ namespace Lux.API.Controllers } /// - /// Chiamata POST: riceve Json in formato JWD serializzato, lo ripete come risposta + /// Chiamata GET: restituisce file SVG (da file o da cache) /// PUT: api/window/svg-file/00000000-0000-0000-0000-000000000000 /// /// id oggetto @@ -154,19 +151,16 @@ namespace Lux.API.Controllers // ...se ricevo percorso --> leggo jwd/svg cablato if (!string.IsNullOrEmpty(currJwd)) { - if (true) - { - Dictionary DictExec = new Dictionary(); - DictExec.Add("Mode", "1"); - // UID cablato x ora... - DictExec.Add("UID", id); - DictExec.Add("Jwd", currJwd); - int nId = 1; - ProcessArgs currArgs = new ProcessArgs(nId, DictExec); + Dictionary DictExec = new Dictionary(); + DictExec.Add("Mode", "1"); + // UID cablato x ora... + DictExec.Add("UID", id); + DictExec.Add("Jwd", currJwd); + int nId = 1; + ProcessArgs currArgs = new ProcessArgs(nId, DictExec); - await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs); - svgContent = "DONE"; - } + await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs); + svgContent = "DONE"; } sw.Stop(); Log.Info($"calcSvg | {sw.Elapsed.TotalMilliseconds:N3} ms"); diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 84d74f1f..e29a0f2b 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 0.9.2508.0416 + 0.9.2508.0511 diff --git a/Lux.API/README.md b/Lux.API/README.md index 9b79c6b2..37698a33 100644 --- a/Lux.API/README.md +++ b/Lux.API/README.md @@ -2,7 +2,7 @@ Classe per routing/gestione comunicazione tra servizi, ad esempio * ricezione richiesta REST di calcolo di un SVG a partire da un JWD - * inoltro richeista (via REDIS channel) all'Engine EgwMultiEngine + * inoltro richiesta (via REDIS channel) all'Engine EgwMultiEngine * attesa risposta, salvataggio in cache REDIS + inoltro su canale pubblicazione immagini x interfacce ## Sviluppi diff --git a/Lux.API/Services/ExternalMessageProcessor.cs b/Lux.API/Services/ExternalMessageProcessor.cs index bfa5c545..6c714e46 100644 --- a/Lux.API/Services/ExternalMessageProcessor.cs +++ b/Lux.API/Services/ExternalMessageProcessor.cs @@ -86,7 +86,7 @@ namespace Lux.API.Services /// private void ProcessMan_m_AnswerReceived(ProcessArgsResult result) { - // verifico che sia la mia richeista con id immagine... FARE!!! + // verifico che sia la mia richiesta con id immagine... FARE!!! // salvo il risultato... if (result.Args != null && result.Args.Count > 0) { diff --git a/Lux.UI/Components/Pages/Scratch.razor.cs b/Lux.UI/Components/Pages/Scratch.razor.cs index 1ea2ac04..a9879534 100644 --- a/Lux.UI/Components/Pages/Scratch.razor.cs +++ b/Lux.UI/Components/Pages/Scratch.razor.cs @@ -81,11 +81,6 @@ namespace Lux.UI.Components.Pages #endregion Private Fields -#if false - [Inject] - protected IRedisService RedServ { get; set; } = null!; -#endif - #region Private Methods private async void CalcDonePipe_EA_NewMessage(object? sender, EventArgs e) diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index 1d831f3c..7d054d12 100644 --- a/Lux.UI/Lux.UI.csproj +++ b/Lux.UI/Lux.UI.csproj @@ -5,7 +5,7 @@ enable enable aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50 - 0.9.2508.0417 + 0.9.2508.0511 diff --git a/Lux.UI/Program.cs b/Lux.UI/Program.cs index 07d870bc..b2532041 100644 --- a/Lux.UI/Program.cs +++ b/Lux.UI/Program.cs @@ -60,13 +60,9 @@ builder.Services.AddSingleton(redisConn); // registro wrapper servizi REDIS builder.Services.AddSingleton(); builder.Services.AddSingleton(); - // Aggiunta servizi specifici builder.Services.AddSingleton(); builder.Services.AddSingleton(); -#if false -builder.Services.AddSingleton(); -#endif var app = builder.Build(); diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index ccdeb046..680d6049 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 0.9.2508.0417

+

Versione: 0.9.2508.0511


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 88f4dd9e..e0f257eb 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -0.9.2508.0417 +0.9.2508.0511 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 02cf22b0..5775df57 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 0.9.2508.0417 + 0.9.2508.0511 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false