update editing fasi

This commit is contained in:
Samuele Locatelli
2025-10-29 19:27:16 +01:00
parent c6571b6314
commit 13534fe676
11 changed files with 246 additions and 18 deletions
@@ -1,5 +1,6 @@
using EgwCoreLib.Lux.Core.RestPayload;
using EgwCoreLib.Lux.Data.DbModel.Config;
using EgwCoreLib.Lux.Data.DbModel.Cost;
using EgwCoreLib.Lux.Data.DbModel.Items;
using EgwCoreLib.Lux.Data.DbModel.Sales;
using EgwCoreLib.Lux.Data.DbModel.Task;
@@ -1228,9 +1229,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
return dbResult;
}
/// <summary>
/// Esegue spostamento nell'ordinamento
/// NB: verifica spostamento sia ammissibile: se primo rec non "sale", se ultimo non "scende"...
@@ -1337,12 +1335,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
return answ;
}
/// <summary>
/// Eliminazione record richiesto
/// </summary>
@@ -1362,7 +1354,6 @@ namespace EgwCoreLib.Lux.Data.Controllers
.FirstOrDefaultAsync();
if (dbResult != null)
{
// cerco righe successive
var list2move = dbCtx
.DbSetJobTask
@@ -2127,6 +2118,54 @@ namespace EgwCoreLib.Lux.Data.Controllers
return answ;
}
/// <summary>
/// Elenco record Fasi da DB
/// </summary>
/// <returns></returns>
internal async Task<List<PhaseModel>> PhasesGetAllAsync()
{
List<PhaseModel> dbResult = new List<PhaseModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
{
dbResult = await dbCtx
.DbSetPhase
.ToListAsync();
}
catch (Exception exc)
{
Log.Error($"Eccezione durante PhasesGetAllAsync{Environment.NewLine}{exc}");
}
}
return dbResult;
}
/// <summary>
/// Elenco record risorse da DB
/// </summary>
/// <returns></returns>
internal async Task<List<ResourceModel>> ResourcesGetAllAsync()
{
List<ResourceModel> dbResult = new List<ResourceModel>();
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
using (DataLayerContext dbCtx = new DataLayerContext())
{
try
{
dbResult = await dbCtx
.DbSetResource
.ToListAsync();
}
catch (Exception exc)
{
Log.Error($"Eccezione durante ResourcesGetAllAsync{Environment.NewLine}{exc}");
}
}
return dbResult;
}
#endregion Internal Methods
#region Private Fields
@@ -19,6 +19,7 @@ using static System.Runtime.InteropServices.JavaScript.JSType;
using EgwCoreLib.Lux.Data.DbModel.Items;
using EgwCoreLib.Lux.Data.DbModel.Config;
using EgwCoreLib.Lux.Data.DbModel.Task;
using EgwCoreLib.Lux.Data.DbModel.Cost;
namespace EgwCoreLib.Lux.Data.Services
{
@@ -737,6 +738,19 @@ namespace EgwCoreLib.Lux.Data.Services
return result;
}
/// <summary>
/// Esegue Upsert del record ricevuto
/// </summary>
/// <param name="currRec"></param>
/// <returns></returns>
public async Task<bool> JobStepUpsertAsync(JobStepModel currRec)
{
bool result = await dbController.JobStepUpsertAsync(currRec);
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:JobTaskList:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:JobStep:*");
return result;
}
/// <summary>
/// Esegue eliminazione + refresh cache
/// </summary>
@@ -1080,6 +1094,74 @@ namespace EgwCoreLib.Lux.Data.Services
return fatto;
}
/// <summary>
/// Elenco completo Fasi
/// </summary>
/// <returns></returns>
public async Task<List<PhaseModel>> PhasesGetAllAsync()
{
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<PhaseModel>? result = new List<PhaseModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:GenClass";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<PhaseModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = await dbController.PhasesGetAllAsync();
// serializzo e salvo con config x evitare loop...
rawData = JsonConvert.SerializeObject(result, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
}
if (result == null)
{
result = new List<PhaseModel>();
}
sw.Stop();
Log.Debug($"PhasesGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Elenco completo Risorse
/// </summary>
/// <returns></returns>
public async Task<List<ResourceModel>> ResourcesGetAllAsync()
{
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<ResourceModel>? result = new List<ResourceModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:GenClass";
RedisValue rawData = await redisDb.StringGetAsync(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<ResourceModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = await dbController.ResourcesGetAllAsync();
// serializzo e salvo con config x evitare loop...
rawData = JsonConvert.SerializeObject(result, JSSettings);
await redisDb.StringSetAsync(currKey, rawData, LongCache);
}
if (result == null)
{
result = new List<ResourceModel>();
}
sw.Stop();
Log.Debug($"ResourcesGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Esegue salvataggio BOM sul DB
/// </summary>
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2510.2918</Version>
<Version>0.9.2510.2919</Version>
</PropertyGroup>
<ItemGroup>
@@ -1,4 +1,68 @@
<div class="card border-info shadow">
@if (addVisible)
{
<div class="modal" tabindex="-1" style="display:block; background-color: rgba(10,10,10,.6);" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<div class="modal-title fs-4">Aggiunta Ciclo di Lavoro</div>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" @onclick="ToggleAdd">
</button>
</div>
<div class="modal-body">
@if (newRecord != null)
{
<div class="row">
<div class="col-12">
<div class="form-floating mb-1">
<input type="text" class="form-control" @bind="@newRecord.Description" />
<label class="small">Descrizione</label>
</div>
</div>
<div class="col-6">
<div class="form-floating mb-1">
<select @bind="@newRecord.PhaseID" class="form-select">
@foreach (var itemAlt in ListPhases)
{
<option value="@itemAlt.PhaseID">@itemAlt.Name | @itemAlt.Description</option>
}
</select>
<label class="small">Fase</label>
</div>
</div>
<div class="col-6">
<div class="form-floating mb-1">
<select @bind="@newRecord.ResourceID" class="form-select">
<option value="">--- Nessuna Selezione ---</option>
@foreach (var itemAlt in ListResources)
{
<option value="@itemAlt.ResourceID">@itemAlt.Name</option>
}
</select>
<label class="small">Risorsa</label>
</div>
</div>
</div>
}
@if (!string.IsNullOrEmpty(errorMsg))
{
<div class="alert alert-danger my-3">
@errorMsg
</div>
}
<div class="row">
<div class="col">
<button class="btn btn-success w-100" @onclick="DoAdd"><i class="fa-solid fa-save"></i> Save</button>
</div>
<div class="col">
<button class="btn btn-warning w-100" @onclick="ToggleAdd">Cancel <i class="fa-solid fa-ban"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
}
<div class="card border-info shadow">
<div class="card-header bg-info bg-opacity-50 bg-gradient">
Dettaglio <b>Fasi</b> job
</div>
@@ -1,3 +1,4 @@
using EgwCoreLib.Lux.Data.DbModel.Cost;
using EgwCoreLib.Lux.Data.DbModel.Task;
using EgwCoreLib.Lux.Data.Services;
using Microsoft.AspNetCore.Components;
@@ -21,6 +22,12 @@ namespace Lux.UI.Components.Compo.JobTask
[Parameter]
public EventCallback<bool> EC_Updated { get; set; }
[Parameter]
public List<PhaseModel> ListPhases { get; set; }
[Parameter]
public List<ResourceModel> ListResources { get; set; }
#endregion Public Properties
#region Protected Fields
@@ -38,6 +45,35 @@ namespace Lux.UI.Components.Compo.JobTask
[Inject]
protected DataLayerServices DLService { get; set; } = null!;
private string errorMsg = "";
/// <summary>
/// Genera nuovo record e lo salva
/// </summary>
protected async Task DoAdd()
{
if (newRecord != null)
{
// verifico non sia duplicato...
var recExist = CurrRecords.Count(x => x.Description == newRecord.Description);
if (recExist > 0)
{
errorMsg = $"Errore: record già esistente | {newRecord.Description}";
}
else
{
errorMsg = "";
// faccio upsert record...
await DLService.JobStepUpsertAsync(newRecord);
// segnalo update x reload
await EC_Updated.InvokeAsync(true);
newRecord = null;
addVisible = false;
// rileggo
ReloadData();
}
}
}
/// <summary>
/// Eliminazione record
/// </summary>
@@ -118,7 +154,9 @@ namespace Lux.UI.Components.Compo.JobTask
newRecord = new JobStepModel()
{
Index = totalCount + 1,
Description = $"Fase {totalCount + 1} | {DateTime.Now:yyyy.MM.dd-HH.mm.ss}"
Description = $"Fase {totalCount + 1}",
PhaseID = 1,
ResourceID = 1
};
}
}
+1 -1
View File
@@ -31,7 +31,7 @@
@if (selRecord != null)
{
<div class="col-8 ps-0">
<JobStepMan CurrRecords="ListStep"></JobStepMan>
<JobStepMan CurrRecords="ListStep" ListPhases="ListPhases" ListResources="ListResources"></JobStepMan>
</div>
}
}
@@ -1,3 +1,4 @@
using EgwCoreLib.Lux.Data.DbModel.Cost;
using EgwCoreLib.Lux.Data.DbModel.Items;
using EgwCoreLib.Lux.Data.DbModel.Task;
using EgwCoreLib.Lux.Data.DbModel.Utils;
@@ -66,6 +67,8 @@ namespace Lux.UI.Components.Pages
private async Task ReloadData()
{
isLoading = true;
ListPhases = await DLService.PhasesGetAllAsync();
ListResources = await DLService.ResourcesGetAllAsync();
ListJobTask = await DLService.JobTaskGetAllAsync();
ListStep = null;
isLoading = false;
@@ -92,6 +95,8 @@ namespace Lux.UI.Components.Pages
private List<JobStepModel>? ListStep = null;
private List<PhaseModel> ListPhases = new List<PhaseModel>();
private List<ResourceModel> ListResources = new List<ResourceModel>();
#endregion Private Methods
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>0.9.2510.2918</Version>
<Version>0.9.2510.2919</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2510.2918</h4>
<h4>Versione: 0.9.2510.2919</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2510.2918
0.9.2510.2919
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2510.2918</version>
<version>0.9.2510.2919</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>