diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs index 0bdd8bfa..0b1e64fa 100644 --- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs +++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs @@ -21,49 +21,6 @@ namespace EgwCoreLib.Lux.Data.Controllers { // manca costruttore parametrico contoller... - #region Public Methods - - /// - /// Esegue assegnazione bulk dei ProdItem ad un unico ProdAssign parent - /// - /// - /// - /// - public async Task ProdItemBulkAssignItems(int ProdAssignId, Dictionary itemsToAssign) - { - int totalUpdated = 0; - //using (DataLayerContext dbCtx = new DataLayerContext(_config)) - using (DataLayerContext dbCtx = new DataLayerContext()) - { - using var transaction = await dbCtx.Database.BeginTransactionAsync(); - try - { - foreach (var entry in itemsToAssign) - { - // Esegue un UPDATE diretto: UPDATE production_item SET ProdAssignID = x, EstimTime = y WHERE ProdLabel = z - int rowsAffected = await dbCtx.DbSetProdItem - .Where(p => p.ProdLabel == entry.Key) - .ExecuteUpdateAsync(setters => setters - .SetProperty(p => p.ProdAssignID, ProdAssignId) - .SetProperty(p => p.EstimTime, entry.Value) - ); - - totalUpdated += rowsAffected; - } - await transaction.CommitAsync(); - } - catch (Exception exc) - { - await transaction.RollbackAsync(); - Log.Error($"Eccezione durante ProdItemBulkAssignItems{Environment.NewLine}{exc}"); - //throw; - } - } - return totalUpdated; - } - - #endregion Public Methods - #region Internal Methods internal async Task> ConfEnvirParamGetAllAsync() @@ -3339,6 +3296,46 @@ namespace EgwCoreLib.Lux.Data.Controllers return removed; } + /// + /// Esegue assegnazione bulk dei ProdItem ad un unico ProdAssign parent + /// + /// + /// + /// + /// + internal async Task ProdItemBulkAssignItems(int OrderRowId, int ProdAssignId, Dictionary itemsToAssign) + { + int totalUpdated = 0; + //using (DataLayerContext dbCtx = new DataLayerContext(_config)) + using (DataLayerContext dbCtx = new DataLayerContext()) + { + using var transaction = await dbCtx.Database.BeginTransactionAsync(); + try + { + foreach (var entry in itemsToAssign) + { + // Esegue un UPDATE diretto: UPDATE production_item SET ProdAssignID = x, EstimTime = y WHERE ProdLabel = z + int rowsAffected = await dbCtx.DbSetProdItem + .Where(p => p.OrderRowID == OrderRowId && p.ProdLabel == entry.Key) + .ExecuteUpdateAsync(setters => setters + .SetProperty(p => p.ProdAssignID, ProdAssignId) + .SetProperty(p => p.EstimTime, entry.Value) + ); + + totalUpdated += rowsAffected; + } + await transaction.CommitAsync(); + } + catch (Exception exc) + { + await transaction.RollbackAsync(); + Log.Error($"Eccezione durante ProdItemBulkAssignItems{Environment.NewLine}{exc}"); + //throw; + } + } + return totalUpdated; + } + /// /// Elenco ProdItem dato OrderRow /// diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index 29f0fe9a..d1437b14 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -1637,6 +1637,21 @@ namespace EgwCoreLib.Lux.Data.Services return result; } + + public async Task ProdItemBulkAssignItems(int OrderRowId, int ProdAssignId, Dictionary itemsToAssign) + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + // calcolo + int fatto = await dbController.ProdItemBulkAssignItems(OrderRowId, ProdAssignId, itemsToAssign); + // svuoto cache... + await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdItems:*"); + sw.Stop(); + Log.Debug($"ProdItemBulkAssignItems in {sw.Elapsed.TotalMilliseconds} ms"); + return fatto; + } + + /// Esegue Delete del record ricevuto /// /// diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index deae0c72..a9fb082e 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 0.9.2512.2411 + 0.9.2512.2412 diff --git a/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor b/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor index 4a350d38..a1f55cd2 100644 --- a/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor +++ b/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor @@ -67,7 +67,7 @@
  • Non producibili: @DetailRecord.NumKo
    - +
  • } diff --git a/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor.cs b/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor.cs index 8d55eae8..d387ce6e 100644 --- a/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor.cs +++ b/Lux.UI/Components/Compo/WorkLoad/TimeEstim.razor.cs @@ -1,5 +1,6 @@ using EgwCoreLib.Lux.Core.Generic; using EgwCoreLib.Lux.Core.RestPayload; +using EgwCoreLib.Lux.Data.Services; using Microsoft.AspNetCore.Components; using NLog.Targets.Wrappers; @@ -9,6 +10,9 @@ namespace Lux.UI.Components.Compo.WorkLoad { #region Public Properties + [Parameter] + public int OrderRowId { get; set; } = 0; + [Parameter] public WorkLoadDetailDTO DetailRecord { get; set; } = null!; @@ -24,6 +28,8 @@ namespace Lux.UI.Components.Compo.WorkLoad #endregion Public Properties #region Protected Fields + [Inject] + protected DataLayerServices DLService { get; set; } = null!; protected BalanceReqDto cBalanceReq = new BalanceReqDto(); @@ -104,7 +110,30 @@ namespace Lux.UI.Components.Compo.WorkLoad /// protected async Task SendUnworkExt() { - // + // recupero ProdAssignId x EXT... da elenco record mostrati... + int ProdAssignId = 0; + if (OrderRowId > 0 && ProdAssignId > 0) + { + // recupero elenco e converto in Dict + var dictUnwokr = DetailRecord + .ListUnWorkable + .ToDictionary(x => x, x => 0.0); + + // chiamo update! + await DLService.ProdItemBulkAssignItems(OrderRowId, ProdAssignId, dictUnwokr); + + } + // rileggo! + await ReloadData(); + } + + /// + /// Rilettura dati da DB associazioni + /// + /// + protected async Task ReloadData() + { + await Task.Delay(500); } #endregion Protected Methods diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index 3c1667a9..59068f4a 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.2318 + 0.9.2512.2412 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 7e72b26c..28af4873 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

    Versione: 0.9.2512.2411

    +

    Versione: 0.9.2512.2412


    Note di rilascio:
    • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index b7f6c91e..9a0a342f 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -0.9.2512.2411 +0.9.2512.2412 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 6d400441..2382bba5 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 0.9.2512.2411 + 0.9.2512.2412 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false