diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs index 5f776a2f..438ab672 100644 --- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs +++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs @@ -2497,7 +2497,7 @@ namespace EgwCoreLib.Lux.Data.Controllers try { DateTime adesso = DateTime.Now; - // recupero offerta... + // recupero ordine... var currRec = dbCtx .DbSetOrder .Where(x => x.OrderID == orderId) @@ -2517,13 +2517,12 @@ namespace EgwCoreLib.Lux.Data.Controllers /// /// /// - internal async Task OrderFromOffer(OfferModel rec2clone) + internal async Task OrderFromOffer(OfferModel rec2clone) { - int orderId = 0; + OrderModel? newRec = null; //using (DataLayerContext dbCtx = new DataLayerContext(_config)) using (DataLayerContext dbCtx = new DataLayerContext()) { - OrderModel? newRec = null; try { DateTime adesso = DateTime.Now; @@ -2610,7 +2609,9 @@ namespace EgwCoreLib.Lux.Data.Controllers // se ok sistemo UID... if (numSave > 0 && newRec != null) { - orderId = newRec.OrderID; +#if false + orderId = newRec.OrderID; +#endif // sistemo UID... foreach (var item in newRec.OrderRowNav) { @@ -2657,7 +2658,10 @@ namespace EgwCoreLib.Lux.Data.Controllers Log.Error($"Eccezione durante OrderFromOffer{Environment.NewLine}{exc}"); } } - return orderId; + return newRec; +#if false + return orderId; +#endif } /// diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index d0d95210..0bb1679c 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -1264,8 +1264,9 @@ namespace EgwCoreLib.Lux.Data.Services /// Restituisce record ordine + righe Ordine dato ID /// /// + /// /// - public async Task OrderById(int orderId) + public async Task OrderById(int orderId, bool doForce) { string source = "DB"; Stopwatch sw = new Stopwatch(); @@ -1274,7 +1275,7 @@ namespace EgwCoreLib.Lux.Data.Services // cerco in redis... string currKey = $"{redisBaseKey}:Orders:ById:{orderId}"; RedisValue rawData = await redisDb.StringGetAsync(currKey); - if (rawData.HasValue) + if (rawData.HasValue && !doForce) { result = JsonConvert.DeserializeObject($"{rawData}"); source = "REDIS"; @@ -1302,13 +1303,13 @@ namespace EgwCoreLib.Lux.Data.Services /// /// /// - public async Task OrderFromOffer(OfferModel rec2clone) + public async Task OrderFromOffer(OfferModel rec2clone) { Stopwatch sw = new Stopwatch(); sw.Start(); // calcolo - int orderId = await dbController.OrderFromOffer(rec2clone); - if (orderId > 0) + OrderModel? newOrd = await dbController.OrderFromOffer(rec2clone); + if (newOrd != null) { // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); @@ -1316,7 +1317,7 @@ namespace EgwCoreLib.Lux.Data.Services } sw.Stop(); Log.Debug($"OrderFromOffer in {sw.Elapsed.TotalMilliseconds} ms"); - return orderId; + return newOrd; } /// diff --git a/Lux.API/Controllers/ProdController.cs b/Lux.API/Controllers/ProdController.cs index a2439eac..799e6121 100644 --- a/Lux.API/Controllers/ProdController.cs +++ b/Lux.API/Controllers/ProdController.cs @@ -2,6 +2,7 @@ using EgwCoreLib.Lux.Data.Services; using EgwMultiEngineManager.Data; using Lux.API.Services; +using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.SignalR; using Newtonsoft.Json; @@ -18,10 +19,17 @@ namespace Lux.API.Controllers { #region Public Constructors - public ProdController(ProdService prodService, ExternalMessageProcessor extMessProc) + /// + /// Costruttore metodo + /// + /// + /// + /// + public ProdController(ProdService prodService, ExternalMessageProcessor extMessProc, CalcRuidService crService) { PService = prodService; EMProc = extMessProc; + _calcRuidService = crService; } #endregion Public Constructors @@ -32,7 +40,7 @@ namespace Lux.API.Controllers /// Chiamata GET: test status alive /// GET: api/Prod/alive /// - /// id oggetto + /// uid oggetto /// [HttpGet("alive")] public async Task Alive() @@ -51,13 +59,39 @@ namespace Lux.API.Controllers /// GET: api/Prod/getjob/ABC012345 /// /// - [HttpGet("getjob/{id}")] - public async Task> GetJob(string id) + [HttpGet("getjob/{uid}")] + public async Task> GetJob(string uid) { - var result = await PService.GetJob(id); - QuestionDTO deserRes = JsonConvert.DeserializeObject(result); - return Ok(deserRes); + var result = await PService.GetJob(uid); + QuestionDTO? deserRes = JsonConvert.DeserializeObject(result); + if (deserRes != null) + { + // verifico RUID code x rigenerarlo... + if (deserRes.Args != null) + { + // elimino vecchio RUID se esistesse... + if (deserRes.Args.ContainsKey("RUID")) + { + deserRes.Args.Remove("RUID"); + } + // lo aggiungo! + string envir = $"{deserRes.ExecEnvironment}"; + var mode = deserRes.Args["Mode"]; + var sub = deserRes.Args["SubMode"]; + string type = string.IsNullOrEmpty(sub) ? mode : $"{mode}-{sub}"; + // creo registrazione richiesta... + var ruid = await _calcRuidService.AddRequestAsync(envir, type, uid); + // aggiungo RUID effettivo + deserRes.Args.Add("RUID", ruid); + } + return Ok(deserRes); + } + else + { + return NotFound("No Data Found"); + } } + private readonly CalcRuidService _calcRuidService; /// /// Chiamata GET: @@ -70,9 +104,35 @@ namespace Lux.API.Controllers public async Task> GetNext() { var result = await PService.GetNext(); - //return Ok(result); - QuestionDTO deserRes = JsonConvert.DeserializeObject(result); - return Ok(deserRes); + QuestionDTO? deserRes = JsonConvert.DeserializeObject(result); + if (deserRes != null) + { + // verifico RUID code x rigenerarlo... + if (deserRes.Args != null) + { + // elimino vecchio RUID se esistesse... + if (deserRes.Args.ContainsKey("RUID")) + { + deserRes.Args.Remove("RUID"); + } + // lo aggiungo! + string envir = $"{deserRes.ExecEnvironment}"; + var mode = deserRes.Args["Mode"]; + var sub = deserRes.Args["SubMode"]; + var uid = deserRes.Args["UID"]; + string type = string.IsNullOrEmpty(sub) ? mode : $"{mode}-{sub}"; + + // creo registrazione richiesta... + var ruid = await _calcRuidService.AddRequestAsync(envir, type, uid); + // aggiungo RUID effettivo + deserRes.Args.Add("RUID", ruid); + } + return Ok(deserRes); + } + else + { + return NotFound("No Data Available"); + } } /// @@ -112,7 +172,7 @@ namespace Lux.API.Controllers /// GET: api/Prod/rep-answer/ABC012345 /// /// - [HttpGet("rep-answer/{id}")] + [HttpGet("rep-answer/{uid}")] public async Task> ReplayAnswer(string id, int env) { Constants.EXECENVIRONMENTS envir = (Constants.EXECENVIRONMENTS)env; @@ -217,7 +277,7 @@ namespace Lux.API.Controllers /// GET: api/Prod/queue-len/waiting /// GET: api/Prod/queue-len/running /// - /// id oggetto + /// uid oggetto /// [HttpGet("qlen/{type}")] public async Task QueueLen(QueueType type = QueueType.waiting) @@ -230,7 +290,7 @@ namespace Lux.API.Controllers /// Chiamata GET: dizionario stato richieste /// GET: api/Prod/queue-status/ /// - /// id oggetto + /// uid oggetto /// [HttpGet("qstatus")] public async Task QueueStatus() diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 784e102d..ef90d390 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 0.9.2512.1311 + 0.9.2512.1514 diff --git a/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs b/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs index 95263f04..dfde6e60 100644 --- a/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/HardwareMan.razor.cs @@ -31,6 +31,9 @@ namespace Lux.UI.Components.Compo.Config [Inject] protected IConfiguration Config { get; set; } = null!; + [Inject] + protected CalcRuidService CRService { get; set; } = null!; + [Inject] protected CalcRequestService CService { get; set; } = null!; @@ -108,6 +111,8 @@ namespace Lux.UI.Components.Compo.Config private string calcTag = "calc"; + private Constants.EXECENVIRONMENTS cEnvir = Constants.EXECENVIRONMENTS.WINDOW; + /// /// Conf HW corrente (produttore) - gestire con conf? /// @@ -148,16 +153,21 @@ namespace Lux.UI.Components.Compo.Config private async Task callRefreshHwList(string reqUid) { Dictionary DictExec = new Dictionary(); - DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.HARDWARE}"); - // da rivedere? + var cMode = Egw.Window.Data.Enums.QuestionModes.HARDWARE; + var cSubMode = Egw.Window.Data.Enums.QuestionHwSubModes.LIST; + var cManufact = Egw.Window.Data.Enums.HardwareManufacturers.AGB; + // compongo righiesta + DictExec.Add("Mode", $"{(int)cMode}"); DictExec.Add("UID", reqUid); - // FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!! - DictExec.Add("RUID", GenerateId()); - DictExec.Add("SubMode", $"{(int)Egw.Window.Data.Enums.QuestionHwSubModes.LIST}"); - DictExec.Add("Manufacturer", $"{(int)Egw.Window.Data.Enums.HardwareManufacturers.AGB}"); + // creo registrazione richiesta... + var ruid = await CRService.AddRequestAsync($"{cEnvir}", $"{cMode}-{cSubMode}", reqUid); + // aggiungo RUID effettivo + DictExec.Add("RUID", ruid); + DictExec.Add("SubMode", $"{(int)cSubMode}"); + DictExec.Add("Manufacturer", $"{(int)cManufact}"); CalcRequestDTO req = new CalcRequestDTO() { - EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, + EnvType = cEnvir, DictExec = DictExec }; // svuotiamo cache dati... @@ -168,17 +178,6 @@ namespace Lux.UI.Components.Compo.Config await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{reqUid}", req); } - 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}"; - } - /// /// Ricevuto update da Calc x elenco HW: aggiorno! /// @@ -194,7 +193,7 @@ namespace Lux.UI.Components.Compo.Config private void ReloadData() { isLoading = true; - AllRecords = CDService.HwModelList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, confHw); + AllRecords = CDService.HwModelList(cEnvir, confHw); // se ho ricerca testuale faccio filtro ulteriore... if (string.IsNullOrEmpty(SearchVal)) { diff --git a/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs b/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs index 4a7ab7eb..6b99b6cf 100644 --- a/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs +++ b/Lux.UI/Components/Compo/Config/ProfileMan.razor.cs @@ -2,6 +2,7 @@ using EgwCoreLib.Lux.Data.DbModel.Config; using EgwCoreLib.Lux.Data.Services; using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.JSInterop; using System.ComponentModel; @@ -29,6 +30,9 @@ namespace Lux.UI.Components.Compo.Config [Inject] protected IConfiguration Config { get; set; } = null!; + [Inject] + protected CalcRuidService CRService { get; set; } = null!; + [Inject] protected CalcRequestService CService { get; set; } = null!; @@ -105,6 +109,8 @@ namespace Lux.UI.Components.Compo.Config private string calcTag = "calc"; + private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + /// /// Per eventuale gestione multi-profilo su multi tenant /// @@ -144,18 +150,20 @@ namespace Lux.UI.Components.Compo.Config private async Task callRefreshProfList() { Dictionary DictExec = new Dictionary(); - DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.CONFIG}"); - // preparo args + var cMode = Egw.Window.Data.Enums.QuestionModes.CONFIG; + var cSubMode = Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST; + // compongo righiesta string reqUid = "Default"; + DictExec.Add("Mode", $"{(int)cMode}"); DictExec.Add("UID", reqUid); - - // FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!! - DictExec.Add("RUID", GenerateId()); - - DictExec.Add("SubMode", $"{(int)Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST}"); + // creo registrazione richiesta... + var ruid = await CRService.AddRequestAsync($"{cEnvir}", $"{cMode}-{cSubMode}", reqUid); + // aggiungo RUID effettivo + DictExec.Add("RUID", ruid); + DictExec.Add("SubMode", $"{(int)cSubMode}"); CalcRequestDTO req = new CalcRequestDTO() { - EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, + EnvType = cEnvir, DictExec = DictExec }; // svuotiamo cache dati... @@ -166,17 +174,6 @@ namespace Lux.UI.Components.Compo.Config await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{reqUid}", req); } - 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}"; - } - private void FullUpdate() { ReloadData(); @@ -197,7 +194,7 @@ namespace Lux.UI.Components.Compo.Config private void ReloadData() { isLoading = true; - AllRecords = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, confProf); + AllRecords = CDService.ProfileList(cEnvir, confProf); // se ho ricerca testuale faccio filtro ulteriore... if (string.IsNullOrEmpty(SearchVal)) { diff --git a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs index b45d4a5b..ff749be8 100644 --- a/Lux.UI/Components/Compo/OfferCommonPar.razor.cs +++ b/Lux.UI/Components/Compo/OfferCommonPar.razor.cs @@ -29,6 +29,9 @@ namespace Lux.UI.Components.Compo [Inject] protected IConfiguration Config { get; set; } = null!; + [Inject] + protected CalcRuidService CRService { get; set; } = null!; + [Inject] protected CalcRequestService CService { get; set; } = null!; @@ -118,6 +121,7 @@ namespace Lux.UI.Components.Compo private string apiUrl = ""; private string calcTag = "calc"; + private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; private ParamDict CurrSel = new ParamDict(""); private string genericBasePath = ""; @@ -142,36 +146,26 @@ namespace Lux.UI.Components.Compo private async Task callRefreshProfList() { Dictionary DictExec = new Dictionary(); - DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.CONFIG}"); - // preparo args + var cMode = Egw.Window.Data.Enums.QuestionModes.CONFIG; + var cSubMode = Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST; + // compongo righiesta string reqUid = "Default"; + DictExec.Add("Mode", $"{(int)cMode}"); DictExec.Add("UID", reqUid); - - // FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!! - DictExec.Add("RUID", GenerateId()); - - DictExec.Add("SubMode", $"{(int)Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST}"); + // creo registrazione richiesta... + var ruid = await CRService.AddRequestAsync($"{cEnvir}", $"{cMode}-{cSubMode}", reqUid); + // aggiungo RUID effettivo + DictExec.Add("RUID", ruid); + DictExec.Add("SubMode", $"{(int)cSubMode}"); CalcRequestDTO req = new CalcRequestDTO() { - EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, + EnvType = cEnvir, DictExec = DictExec }; // chiamo la chiamata POST alla API, che manda la richiesta via REDIS await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{reqUid}", req); } - - 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}"; - } - private void ConfInit() { apiUrl = Config.GetValue("ServerConf:Prog.ApiUrl") ?? ""; diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor.cs b/Lux.UI/Components/Compo/OfferRowMan.razor.cs index c415eed7..2ffd1adc 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OfferRowMan.razor.cs @@ -8,6 +8,7 @@ using EgwCoreLib.Lux.Data.Services; using Lux.UI.Components.Pages; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.IdentityModel.Tokens; using Microsoft.JSInterop; using Newtonsoft.Json; @@ -110,6 +111,9 @@ namespace Lux.UI.Components.Compo [Inject] protected IConfiguration Config { get; set; } = null!; + [Inject] + protected CalcRuidService CRService { get; set; } = null!; + [Inject] protected CalcRequestService CService { get; set; } = null!; @@ -668,6 +672,8 @@ namespace Lux.UI.Components.Compo private string calcTag = "calc"; + private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + /// /// Channel update HwOptions /// @@ -759,36 +765,26 @@ namespace Lux.UI.Components.Compo private async Task callRefreshProfList() { Dictionary DictExec = new Dictionary(); - DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.CONFIG}"); - // preparo args + var cMode = Egw.Window.Data.Enums.QuestionModes.CONFIG; + var cSubMode = Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST; + // compongo righiesta string reqUid = "Default"; + DictExec.Add("Mode", $"{(int)cMode}"); DictExec.Add("UID", reqUid); - - // FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!! - DictExec.Add("RUID", GenerateId()); - - DictExec.Add("SubMode", $"{(int)Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST}"); + // creo registrazione richiesta... + var ruid = await CRService.AddRequestAsync($"{cEnvir}", $"{cMode}-{cSubMode}", reqUid); + // aggiungo RUID effettivo + DictExec.Add("RUID", ruid); + DictExec.Add("SubMode", $"{(int)cSubMode}"); CalcRequestDTO req = new CalcRequestDTO() { - EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, + EnvType = cEnvir, DictExec = DictExec }; // chiamo la chiamata POST alla API, che manda la richiesta via REDIS await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{reqUid}", req); } - - 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}"; - } - /// /// Chiude edit andando eventualmente a salvare /// @@ -1212,17 +1208,17 @@ namespace Lux.UI.Components.Compo // lettura config setup varie da DB/Cache Redis AllConfEnvir = await DLService.ConfEnvirParamGetAllAsync(); AllConfGlass = await DLService.ConfGlassGetAllAsync(); - var rawProfiles = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); + var rawProfiles = CDService.ProfileList(cEnvir, "Default"); // se fosse vuoto chiamo update... if (rawProfiles == null || rawProfiles.Count == 0) { await callRefreshProfList(); // aspetto 200ms... e richiedo! await Task.Delay(200); - rawProfiles = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); + rawProfiles = CDService.ProfileList(cEnvir, "Default"); } AvailProfileList = rawProfiles; - var rawHw = CDService.HwModelList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "HW.AGB"); + var rawHw = CDService.HwModelList(cEnvir, "HW.AGB"); // hw filtro solo validi... AllConfHardware = rawHw .Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase)) diff --git a/Lux.UI/Components/Compo/OrderRowMan.razor.cs b/Lux.UI/Components/Compo/OrderRowMan.razor.cs index e8aeeea2..625465c3 100644 --- a/Lux.UI/Components/Compo/OrderRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OrderRowMan.razor.cs @@ -4,15 +4,16 @@ using EgwCoreLib.Lux.Data.DbModel.Config; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.DbModel.Utils; using EgwCoreLib.Lux.Data.Services; +using Lux.UI.Components.Compo.WorkLoad; using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.JSInterop; using Newtonsoft.Json; using NLog; using System.Xml; using WebWindowComplex; using WebWindowComplex.DTO; -using Lux.UI.Components.Compo.WorkLoad; using static EgwCoreLib.Lux.Core.Enums; namespace Lux.UI.Components.Compo @@ -135,6 +136,9 @@ namespace Lux.UI.Components.Compo [Inject] protected IConfiguration Config { get; set; } = null!; + [Inject] + protected CalcRuidService CRService { get; set; } = null!; + [Inject] protected CalcRequestService CService { get; set; } = null!; @@ -814,6 +818,8 @@ namespace Lux.UI.Components.Compo private string calcTag = "calc"; + private EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS cEnvir = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW; + /// /// Channel update HwOptions /// @@ -909,36 +915,27 @@ namespace Lux.UI.Components.Compo private async Task callRefreshProfList() { Dictionary DictExec = new Dictionary(); - DictExec.Add("Mode", $"{(int)Egw.Window.Data.Enums.QuestionModes.CONFIG}"); - // preparo args + var cMode = Egw.Window.Data.Enums.QuestionModes.CONFIG; + var cSubMode = Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST; + // compongo righiesta string reqUid = "Default"; + DictExec.Add("Mode", $"{(int)cMode}"); DictExec.Add("UID", reqUid); + // creo registrazione richiesta... + var ruid = await CRService.AddRequestAsync($"{cEnvir}", $"{cMode}-{cSubMode}", reqUid); + // aggiungo RUID effettivo + DictExec.Add("RUID", ruid); + DictExec.Add("SubMode", $"{(int)cSubMode}"); - // FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!! - DictExec.Add("RUID", GenerateId()); - - DictExec.Add("SubMode", $"{(int)Egw.Window.Data.Enums.QuestionConfSubModes.PROFILELIST}"); CalcRequestDTO req = new CalcRequestDTO() { - EnvType = EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, + EnvType = cEnvir, DictExec = DictExec }; // chiamo la chiamata POST alla API, che manda la richiesta via REDIS await CService.CallRestPost($"{apiUrl}/{genericBasePath}", $"{calcTag}/{reqUid}", req); } - - 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}"; - } - /// /// Chiude edit andando eventualmente a salvare /// @@ -1362,17 +1359,17 @@ namespace Lux.UI.Components.Compo // lettura config setup varie da DB/Cache Redis AllConfEnvir = await DLService.ConfEnvirParamGetAllAsync(); AllConfGlass = await DLService.ConfGlassGetAllAsync(); - var rawProfiles = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); + var rawProfiles = CDService.ProfileList(cEnvir, "Default"); // se fosse vuoto chiamo update... if (rawProfiles == null || rawProfiles.Count == 0) { await callRefreshProfList(); // aspetto 200ms... e richiedo! await Task.Delay(200); - rawProfiles = CDService.ProfileList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "Default"); + rawProfiles = CDService.ProfileList(cEnvir, "Default"); } AvailProfileList = rawProfiles; - var rawHw = CDService.HwModelList(EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, "HW.AGB"); + var rawHw = CDService.HwModelList(cEnvir, "HW.AGB"); // hw filtro solo validi... AllConfHardware = rawHw .Where(x => !x.FamilyName.Equals(x.Description, StringComparison.OrdinalIgnoreCase)) diff --git a/Lux.UI/Components/Pages/Offers.razor.cs b/Lux.UI/Components/Pages/Offers.razor.cs index 08547162..a67eadb1 100644 --- a/Lux.UI/Components/Pages/Offers.razor.cs +++ b/Lux.UI/Components/Pages/Offers.razor.cs @@ -7,8 +7,11 @@ using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; using EgwCoreLib.Razor; using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Cors.Infrastructure; using Microsoft.JSInterop; +using Newtonsoft.Json; using NLog.LayoutRenderers; +using StackExchange.Redis; using static EgwCoreLib.Lux.Core.Enums; namespace Lux.UI.Components.Pages @@ -54,6 +57,9 @@ namespace Lux.UI.Components.Pages [Inject] protected IConfiguration Config { get; set; } = null!; + [Inject] + protected CalcRuidService CRService { get; set; } = null!; + protected string DivMainCss { get => SelRecord != null ? "col-6" : "col-12"; @@ -165,21 +171,27 @@ namespace Lux.UI.Components.Pages return; // creazione nuovo ordine da offerta - int orderId = await DLService.OrderFromOffer(currRec); - + var newOrd = await DLService.OrderFromOffer(currRec); +#if false + int orderId = await DLService.OrderFromOffer(currRec); if (orderId > 0) +#endif + + if (newOrd !=null) { // aggiunge una richiesta di CREAZIONE del file progetto NGE in coda esecuzione per ogni riga d'ordine... - var listOrdRow = await DLService.OrderById(orderId); +#if false + var newOrd = await DLService.OrderById(orderId, true); +#endif // processo riga ordine x riga ordine creando per ogni riga una richiesta... - if (listOrdRow.OrderRowNav != null && listOrdRow.OrderRowNav.Count > 0) + if (newOrd.OrderRowNav != null && newOrd.OrderRowNav.Count > 0) { // verifico parametri da conf envir... - var envRec = AllConfEnvir.FirstOrDefault(x => x.EnvirID == listOrdRow.Envir); - Egw.Window.Data.Enums.QuestionModes rMode = Egw.Window.Data.Enums.QuestionModes.ORDER; - Egw.Window.Data.Enums.QuestionOrderSubModes rSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.CREATE; + var envRec = AllConfEnvir.FirstOrDefault(x => x.EnvirID == newOrd.Envir); + Egw.Window.Data.Enums.QuestionModes cMode = Egw.Window.Data.Enums.QuestionModes.ORDER; + Egw.Window.Data.Enums.QuestionOrderSubModes cSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.CREATE; string reqKey = ""; - foreach (var rigaOrd in listOrdRow.OrderRowNav) + foreach (var rigaOrd in newOrd.OrderRowNav) { // preparo le 2 richieste (creazione, stima) CalcRequestDTO calcReq = new CalcRequestDTO(); @@ -191,17 +203,18 @@ namespace Lux.UI.Components.Pages string serTagList = string.Join(",", TagsList); // preparo richiesta serializzata e la accodo (viene inviata richiesta calcolo) Dictionary dictArgs = new Dictionary(); + // compongo righiesta dictArgs.Add("UID", rigaOrd.OrderRowUID); - - // FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!! - dictArgs.Add("RUID", GenerateId()); - + // creo registrazione richiesta... + var ruid = await CRService.AddRequestAsync($"{newOrd.Envir}", $"{cMode}-{cSubMode}", rigaOrd.OrderRowUID); + // aggiungo RUID effettivo + dictArgs.Add("RUID", ruid); dictArgs.Add("OrderUID", rigaOrd.OrderNav.OrderCode); - dictArgs.Add("Mode", $"{(int)rMode}"); + dictArgs.Add("Mode", $"{(int)cMode}"); dictArgs.Add("TagsList", serTagList); // aggiungo file secondo ambiente... string serKey = envRec != null ? envRec.SerStrucKey : "SerializedData"; - switch (listOrdRow.Envir) + switch (newOrd.Envir) { case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW: dictArgs.Add(serKey, rigaOrd.SerStruct); @@ -212,7 +225,7 @@ namespace Lux.UI.Components.Pages case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WALL: case EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.CABINET: // rileggo da file... 2check, spostare?!? - string folderPath = $"SO-{listOrdRow.OfferID:X8}"; + string folderPath = $"SO-{newOrd.OfferID:X8}"; string rawData = FileUtils.LoadFileContent(Path.Combine(basePath, folderPath), rigaOrd.FileResource); dictArgs.Add(serKey, rawData); dictArgs.Add("FileName", rigaOrd.FileName); @@ -227,18 +240,17 @@ namespace Lux.UI.Components.Pages if (needCalc) { // mando richiesta "create" preliminare con tutti i dati - rSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.CREATE; - dictArgs.Add("SubMode", $"{(int)rSubMode}"); + dictArgs.Add("SubMode", $"{(int)cSubMode}"); calcReq = new CalcRequestDTO() { DictExec = dictArgs, - EnvType = listOrdRow.Envir + EnvType = newOrd.Envir }; - reqKey = $"{rMode}:{rSubMode}:{rigaOrd.OrderRowUID}"; + reqKey = $"{cMode}:{cSubMode}:{rigaOrd.OrderRowUID}"; await PService.EnqueueRequest("Estimation", reqKey, calcReq); // parto dalla history attuale - var currHist = listOrdRow.LogHistory; + var currHist = newOrd.LogHistory; // aggiungo evento... currHist.Add(new TaskHistDTO() { @@ -247,9 +259,9 @@ namespace Lux.UI.Components.Pages Message = $"{reqKey}", IconCss = "fa-solid fa-hourglass-start" }); - listOrdRow.LogHistory = currHist; + newOrd.LogHistory = currHist; //OrderHist = listOrdRow.LogHistory; - await DLService.OrderUpsert(listOrdRow); + await DLService.OrderUpsert(newOrd); } } } @@ -262,17 +274,6 @@ namespace Lux.UI.Components.Pages UpdateTable(); } - 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}"; - } - #endregion Protected Methods #region Private Fields diff --git a/Lux.UI/Components/Pages/Orders.razor.cs b/Lux.UI/Components/Pages/Orders.razor.cs index 8edcdb3b..7f7c437f 100644 --- a/Lux.UI/Components/Pages/Orders.razor.cs +++ b/Lux.UI/Components/Pages/Orders.razor.cs @@ -5,6 +5,8 @@ using EgwCoreLib.Lux.Data.DbModel.Config; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Cors.Infrastructure; +using Microsoft.EntityFrameworkCore.Migrations; using Microsoft.JSInterop; using NLog; @@ -34,6 +36,9 @@ namespace Lux.UI.Components.Pages [Inject] protected IConfiguration Config { get; set; } = null!; + [Inject] + protected CalcRuidService CRService { get; set; } = null!; + protected string DivMainCss { get => SelRecord != null ? "col-6" : "col-12"; @@ -195,8 +200,8 @@ namespace Lux.UI.Components.Pages { // verifico parametri da conf envir... var envRec = AllConfEnvir.FirstOrDefault(x => x.EnvirID == currRec.Envir); - Egw.Window.Data.Enums.QuestionModes rMode = Egw.Window.Data.Enums.QuestionModes.ORDER; - Egw.Window.Data.Enums.QuestionOrderSubModes rSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.ESTIMATE; + Egw.Window.Data.Enums.QuestionModes cMode = Egw.Window.Data.Enums.QuestionModes.ORDER; + Egw.Window.Data.Enums.QuestionOrderSubModes cSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.ESTIMATE; string reqKey = ""; foreach (var rigaOrd in currRec.OrderRowNav) { @@ -211,12 +216,12 @@ namespace Lux.UI.Components.Pages // preparo richiesta serializzata e la accodo (viene inviata richiesta calcolo) Dictionary dictArgs = new Dictionary(); dictArgs.Add("UID", rigaOrd.OrderRowUID); - - // FixMe! todo! gestire con VERE richieste ID da servizio ReqIndexServicer!!!! - dictArgs.Add("RUID", GenerateId()); - + // creo registrazione richiesta... + var ruid = await CRService.AddRequestAsync($"{currRec.Envir}", $"{cMode}-{cSubMode}", rigaOrd.OrderRowUID); + // aggiungo RUID effettivo + dictArgs.Add("RUID", ruid); dictArgs.Add("OrderUID", rigaOrd.OrderNav.OrderCode); - dictArgs.Add("Mode", $"{(int)rMode}"); + dictArgs.Add("Mode", $"{(int)cMode}"); dictArgs.Add("TagsList", serTagList); // aggiungo file secondo ambiente... string serKey = envRec != null ? envRec.SerStrucKey : "SerializedData"; @@ -245,32 +250,35 @@ namespace Lux.UI.Components.Pages // solo SE va calcolato... if (needCalc) { + // tolta richiesta create +#if false // mando richiesta "create" preliminare con tutti i dati - rSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.CREATE; - dictArgs.Add("SubMode", $"{(int)rSubMode}"); + cSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.CREATE; + dictArgs.Add("SubMode", $"{(int)cSubMode}"); calcReq = new CalcRequestDTO() { DictExec = dictArgs, EnvType = currRec.Envir }; - reqKey = $"{rMode}:{rSubMode}:{rigaOrd.OrderRowUID}"; + reqKey = $"{cMode}:{cSubMode}:{rigaOrd.OrderRowUID}"; await PService.EnqueueRequest("Estimation", reqKey, calcReq); +#endif // ora richiedo la stima, rimuovendo serializzato (serKey), fileName e tagsList... dictArgs.Remove(serKey); - dictArgs.Remove("TagsList"); + dictArgs.Remove("FileName"); dictArgs.Remove("TagsList"); //... e infine cambio il submode... dictArgs.Remove("SubMode"); - rSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.ESTIMATE; - dictArgs.Add("SubMode", $"{(int)rSubMode}"); + cSubMode = Egw.Window.Data.Enums.QuestionOrderSubModes.ESTIMATE; + dictArgs.Add("SubMode", $"{(int)cSubMode}"); calcReq = new CalcRequestDTO() { DictExec = dictArgs, EnvType = currRec.Envir }; - // chiave: composta da rMode, submode, UID riga... - reqKey = $"{rMode}:{rSubMode}:{rigaOrd.OrderRowUID}"; + // chiave: composta da cMode, submode, UID riga... + reqKey = $"{cMode}:{cSubMode}:{rigaOrd.OrderRowUID}"; await PService.EnqueueRequest("Estimation", reqKey, calcReq); // parto dalla history attuale var currHist = currRec.LogHistory; @@ -292,19 +300,6 @@ namespace Lux.UI.Components.Pages await UpdateJobQueue(); } - 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}"; - } - - - #endregion Protected Methods #region Private Fields diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index e9dd88e0..a860efa1 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.2512.1311 + 0.9.2512.1514 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index b481b732..d6dfd31c 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 0.9.2512.1311

+

Versione: 0.9.2512.1514


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 36a18e1b..3ae8fbf6 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -0.9.2512.1311 +0.9.2512.1514 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 7b2d06ce..694426dc 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 0.9.2512.1311 + 0.9.2512.1514 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false