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; } } }