diff --git a/Directory.Packages.props b/Directory.Packages.props index fae4f2c4..cf44d50d 100644 --- a/Directory.Packages.props +++ b/Directory.Packages.props @@ -8,6 +8,11 @@ runtime; build; native; contentfiles; analyzers; buildtransitive all + + + + + diff --git a/EgwCoreLib.Lux.Data/Repository/Sales/OfferRepository.cs b/EgwCoreLib.Lux.Data/Repository/Sales/OfferRepository.cs index 629ff702..e8adc5e1 100644 --- a/EgwCoreLib.Lux.Data/Repository/Sales/OfferRepository.cs +++ b/EgwCoreLib.Lux.Data/Repository/Sales/OfferRepository.cs @@ -181,7 +181,13 @@ public async Task GetByIdAsync(int recId) { await using var dbCtx = await CreateContextAsync(); - return await dbCtx.DbSetOffer.FirstOrDefaultAsync(x => x.OfferID == recId); + return await dbCtx + .DbSetOffer + .Where(x => x.OfferID == recId) + .Include(c => c.CustomerNav) + .Include(d => d.DealerNav) + .Include(o => o.OfferRowNav) + .FirstOrDefaultAsync(); } /// diff --git a/EgwCoreLib.Lux.Data/Services/Sales/IOfferService.cs b/EgwCoreLib.Lux.Data/Services/Sales/IOfferService.cs index 4d57358c..86987652 100644 --- a/EgwCoreLib.Lux.Data/Services/Sales/IOfferService.cs +++ b/EgwCoreLib.Lux.Data/Services/Sales/IOfferService.cs @@ -35,6 +35,13 @@ /// Task> GetFiltAsync(DateTime inizio, DateTime fine); + /// + /// Restituisce una offerte per ID + /// + /// Data inizio + /// + Task GetByIdAsync(int OfferID); + /// /// Effettua update dei costi di tutte le righe del Offer indicato /// diff --git a/EgwCoreLib.Lux.Data/Services/Sales/OfferService.cs b/EgwCoreLib.Lux.Data/Services/Sales/OfferService.cs index 37c97226..3da483ac 100644 --- a/EgwCoreLib.Lux.Data/Services/Sales/OfferService.cs +++ b/EgwCoreLib.Lux.Data/Services/Sales/OfferService.cs @@ -91,6 +91,23 @@ }); } + /// + /// + /// + public async Task GetByIdAsync(int OfferID) + { + // Uso helper TraceAsync che gestisce automaticamente StartActivity, Log e Exception tracking + return await TraceAsync($"{_className}.GetFilt", async (activity) => + { + return await GetOrSetCacheAsync( + $"{_redisBaseKey}:{_className}:ById:{OfferID}", + async () => await _repo.GetByIdAsync(OfferID), + LongCache + ); + }); + } + + /// /// Elenco completo Offer da DB /// diff --git a/Lux.API/Controllers/ReportController.cs b/Lux.API/Controllers/ReportController.cs new file mode 100644 index 00000000..20962d10 --- /dev/null +++ b/Lux.API/Controllers/ReportController.cs @@ -0,0 +1,108 @@ +using EgwCoreLib.Lux.Data.DbModel.Sales; +using EgwCoreLib.Lux.Data.Services.Sales; + +namespace Lux.API.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class ReportController : ControllerBase + { + /// + /// Costruttore metodo + /// + /// + public ReportController(IOfferService offService) + { + _offService = offService; + // Configurazione serializzatore JSON per risolvere errore di loop circolare + JSSettings = new JsonSerializerSettings() + { + ReferenceLoopHandling = ReferenceLoopHandling.Ignore + }; + } + + private JsonSerializerSettings JSSettings; + + private IOfferService _offService; + + ///// + ///// Chiamata GET: restituisce file PNG (da file o da cache) + ///// PUT: api/image/png/00000000-0000-0000-0000-000000000000 + ///// + ///// id oggetto + ///// + //[HttpGet("png/{id}")] + //public async Task png(string id) + //{ + // Stopwatch sw = new Stopwatch(); + // sw.Start(); + // string base64Encoded = ""; + // byte[] decodedBytes = new byte[0]; + // // ...se ricevo percorso --> leggo jwd/svg cablato + // if (!string.IsNullOrEmpty(id)) + // { + // // bonifica nome svg da + // base64Encoded = _imgService.LoadPng(id, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.BEAM); + // // converto base64 + // decodedBytes = Convert.FromBase64String(base64Encoded); + // } + // sw.Stop(); + // Log.Info($"pngString | {sw.Elapsed.TotalMilliseconds:N3} ms"); + // //return Ok(decodedString); + // return File(decodedBytes, "image/png"); + //} + + + /// + /// Chiamata GET: riceve ELENCO Offerte dato periodo + /// GET: api/report/offert-list/?from=2026-01-01&to=2026-04-01 + /// + /// id univoco img + /// + [HttpGet("offert-list")] + public async Task Offert(DateTime from, DateTime to) + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + // recupera dal DB l'offerta con le righe relative + List offData = await _offService.GetFiltAsync(from, to); + + sw.Stop(); + //_logger.LogInformation($"svgString | {sw.Elapsed.TotalMilliseconds:N3} ms"); + string jsonRes = JsonConvert.SerializeObject(offData, JSSettings); + return Ok(jsonRes); + } + + /// + /// Chiamata GET: riceve OffertID, restituisce Json offerta + righe + /// GET: api/report/offert/1 + /// + /// id univoco img + /// + [HttpGet("offert/{id}")] + public async Task Offert(int id) + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + // recupera dal DB l'offerta con le righe relative + OfferModel? offData = await _offService.GetByIdAsync(id); + + sw.Stop(); + //_logger.LogInformation($"svgString | {sw.Elapsed.TotalMilliseconds:N3} ms"); + string jsonRes = JsonConvert.SerializeObject(offData, JSSettings); + return Ok(jsonRes); + } + + [HttpGet("version")] + public string version() + { + var version = Assembly + .GetExecutingAssembly() + .GetName() + .Version? + .ToString() ?? "unknown"; + + return version; + } + } +} diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 4e2713f3..eaedc6a4 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 1.1.2603.3017 + 1.1.2603.3116 diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index 94cf6b6e..36689be3 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 - 1.1.2603.3017 + 1.1.2603.3116 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 2be7e491..ebea3a66 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 1.1.2603.3017

+

Versione: 1.1.2603.3116


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 27d0bcb4..5894440b 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2603.3017 +1.1.2603.3116 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 700b05f8..c09f98eb 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2603.3017 + 1.1.2603.3116 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false