Fix scrittura clone dossier

This commit is contained in:
Samuele Locatelli
2022-11-04 10:10:56 +01:00
parent 3f1a3aa2ce
commit 76c49d1eea
11 changed files with 202 additions and 190 deletions
+9 -9
View File
@@ -110,7 +110,7 @@ namespace MP.Data.Controllers
dbResult = dbCtx
.DbSetDossiers
.AsNoTracking()
.Select(i => i.OdlNav.CodArticolo)
.Select(i => i.CodArticolo)
.Distinct()
.ToList();
}
@@ -302,7 +302,7 @@ namespace MP.Data.Controllers
/// </summary>
/// <param name="currRec">record dossier da eliminare</param>
/// <returns></returns>
public async Task<bool> DossiersDeleteRecord(Dossiers currRec)
public async Task<bool> DossiersDeleteRecord(DossierModel currRec)
{
bool answ = false;
using (var dbCtx = new MoonProContext(_configuration))
@@ -336,18 +336,18 @@ namespace MP.Data.Controllers
/// <param name="DtStart">Data minima per estrazione records</param>
/// <param name="DtEnd">Data Massima per estrazione records</param>
/// <returns></returns>
public List<Dossiers> DossiersGetLastFilt(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd)
public List<DossierModel> DossiersGetLastFilt(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd)
{
List<Dossiers> dbResult = new List<Dossiers>();
List<DossierModel> dbResult = new List<DossierModel>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetDossiers
.AsNoTracking()
.Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodArticolo == "*" || x.OdlNav.CodArticolo == CodArticolo) && (x.DtRif >= DtStart && x.DtRif <= DtEnd))
.Where(x => (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) && (CodArticolo == "*" || x.CodArticolo == CodArticolo) && (x.DtRif >= DtStart && x.DtRif <= DtEnd))
.Include(m => m.MachineNav)
.Include(o => o.OdlNav)
.Include(a => a.OdlNav.ArticoloNav)
//.Include(o => o.OdlNav)
.Include(a => a.ArticoloNav)
.OrderByDescending(x => x.DtRif)
.ToList();
}
@@ -359,7 +359,7 @@ namespace MP.Data.Controllers
/// </summary>
/// <param name="editRec">record dossier da modificare</param>
/// <returns></returns>
public async Task<bool> DossiersInsert(Dossiers newRec)
public async Task<bool> DossiersInsert(DossierModel newRec)
{
bool fatto = false;
using (var dbCtx = new MoonProContext(_configuration))
@@ -431,7 +431,7 @@ namespace MP.Data.Controllers
/// </summary>
/// <param name="editRec">record dossier da modificare</param>
/// <returns></returns>
public async Task<bool> DossiersUpdateValore(Dossiers editRec)
public async Task<bool> DossiersUpdateValore(DossierModel editRec)
{
bool fatto = false;
using (var dbCtx = new MoonProContext(_configuration))
@@ -10,7 +10,7 @@ using System.ComponentModel.DataAnnotations.Schema;
namespace MP.Data.DatabaseModels
{
[Table("Dossiers")]
public partial class Dossiers
public partial class DossierModel
{
#region Public Properties
@@ -31,6 +31,9 @@ namespace MP.Data.DatabaseModels
public string Valore { get; set; } = "";
[MaxLength(50)]
public string KeyRichiesta { get; set; } = "";
/// <summary>
/// Navigazione oggetto Machine
/// </summary>
@@ -43,6 +46,12 @@ namespace MP.Data.DatabaseModels
[ForeignKey("IdxODL")]
public virtual ODLModel OdlNav { get; set; } = null!;
/// <summary>
/// Navigazione oggetto Articolo
/// </summary>
[ForeignKey("CodArticolo")]
public virtual AnagArticoli ArticoloNav { get; set; } = null!;
#endregion Public Properties
}
}
+1 -1
View File
@@ -47,7 +47,7 @@ namespace MP.Data
public virtual DbSet<ODLModel> DbSetODL { get; set; }
public virtual DbSet<PODLModel> DbSetPODL { get; set; }
public virtual DbSet<FluxLog> DbSetFluxLog { get; set; }
public virtual DbSet<Dossiers> DbSetDossiers { get; set; }
public virtual DbSet<DossierModel> DbSetDossiers { get; set; }
public virtual DbSet<StatODLModel> DbSetStatOdl { get; set; }
public virtual DbSet<StatoProdModel> DbSetStatoProd { get; set; }
public virtual DbSet<EventListModel> DbSetEvList { get; set; }
+5 -5
View File
@@ -207,11 +207,11 @@ else
}
</td>
<td>
@record.OdlNav.CodArticolo
<div class="small textConsensed text-secondary">@record.OdlNav.ArticoloNav.DescArticolo</div>
@record.CodArticolo
<div class="small textConsensed text-secondary">@record.ArticoloNav.DescArticolo</div>
</td>
<td>
@tradFase(record.OdlNav.KeyRichiesta)
@tradFase(record.KeyRichiesta)
</td>
<td>
@record.IdxMacchina
@@ -277,8 +277,8 @@ else
@record.dtEvento
</td>
<td>
@record.CodFlux
<div class="small text-dark" title="Valore Registrato"><i>@traduci(record.CodFlux)</i></div>
@traduci(record.CodFlux)
<div class="small textConsensed text-secondary" title="Valore Registrato">@record.CodFlux</div>
</td>
<td style="text-align: right;">
@if (record.ValoreEdit != record.Valore)
+163 -160
View File
@@ -1,5 +1,4 @@
using Microsoft.AspNetCore.Components;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.Data.DTO;
@@ -13,7 +12,7 @@ namespace MP.SPEC.Components
#region Public Properties
[Parameter]
public EventCallback<Dossiers> RecordSel { get; set; }
public EventCallback<DossierModel> RecordSel { get; set; }
[Parameter]
public EventCallback<FluxLogDTO> RecordSelFlux { get; set; }
@@ -23,15 +22,25 @@ namespace MP.SPEC.Components
[Parameter]
public EventCallback<int> TotRecordChanged { get; set; }
[Inject]
private NavigationManager NavManager { get; set; } = null!;
#endregion Public Properties
#region Public Methods
private FluxLogDTO? currFluxLogDto = null;
public string checkSelect(DossierModel recordSel)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.IdxMacchina == recordSel.IdxMacchina && currRecord.DtRif == recordSel.DtRif) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public string checkSelPar(FluxLogDTO recordSel)
{
@@ -48,21 +57,6 @@ namespace MP.SPEC.Components
return answ;
}
public string checkSelect(Dossiers recordSel)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.IdxMacchina == recordSel.IdxMacchina && currRecord.DtRif == recordSel.DtRif) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
currRecord = null;
@@ -70,40 +64,72 @@ namespace MP.SPEC.Components
ListRecords = null;
GC.Collect();
}
private SelectDossierParams lastFilter { get; set; } = new SelectDossierParams() { CurrPage = -1 };
protected override async Task OnParametersSetAsync()
{
if (!lastFilter.Equals(SelFilter))
{
lastFilter = SelFilter.clone();
await reloadData(true);
}
}
#endregion Public Methods
#region Protected Properties
private string traduci(string lemma)
{
var answ = MDService.Traduci(lemma, "IT");
return answ;
}
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MpDataService MDService { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected async Task cancel()
{
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler annullare TUTTE le modifiche? i dati saranno ricaricati.");
if (alert)
{
currFluxLogDto = null;
isEditing = false;
await Task.Delay(1);
if (currRecord != null)
{
listaFlux = MDService.getFluxLog(currRecord.Valore);
}
StateHasChanged();
}
}
protected async Task cancelNewDoss()
{
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler annullare l'aggiunta di un nuovo dossier? i dati saranno ricaricati.");
if (alert)
{
currRecordClone = null;
isEditing = false;
await Task.Delay(1);
StateHasChanged();
}
}
protected async Task cloneRecord(DossierModel selRec)
{
// creo record duplicato...
DossierModel newRec = new DossierModel()
{
IdxDossier = 0,
DataType = selRec.DataType,
DtRif = DateTime.Now,
IdxMacchina = selRec.IdxMacchina,
CodArticolo = selRec.CodArticolo,
IdxODL = 0,
Valore = selRec.Valore,
};
currRecordClone = newRec;
await Task.Delay(1);
}
/// <summary>
/// Eliminazione record selezionato (previa conferma)
/// </summary>
/// <param name="selRec"></param>
/// <returns></returns>
protected async Task deleteRecord(Dossiers selRec)
protected async Task deleteRecord(DossierModel selRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Eliminazione Dossier: sei sicuro di voler procedere?"))
return;
@@ -122,45 +148,78 @@ namespace MP.SPEC.Components
await RecordSelFlux.InvokeAsync(selRec);
}
private void enableEditing()
protected async Task newDossier(DossierModel selRec)
{
isEditing = true;
}
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler creare un nuovo Dossier per l'impianto/articolo selezioanto?");
protected async Task cancel()
{
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler annullare TUTTE le modifiche? i dati saranno ricaricati.");
if (alert)
{
currFluxLogDto = null;
isEditing = false;
await Task.Delay(1);
if (currRecord != null)
if (currRecordClone != null)
{
listaFlux = MDService.getFluxLog(currRecord.Valore);
// serializzo valore x flux log...
DossierFluxLogDTO updatedResult = new DossierFluxLogDTO() { ODL = listaFlux };
string newVal = JsonConvert.SerializeObject(updatedResult);
// preparo x insert
currRecordClone.DtRif = DateTime.Now;
currRecordClone.Valore = newVal;
// METODO PER UPDATE FLUX
await MDService.DossiersInsert(currRecordClone);
currRecordClone = null;
isEditing = false;
await Task.Delay(1);
StateHasChanged();
}
StateHasChanged();
return;
}
}
protected async Task cancelNewDoss()
{
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler annullare l'aggiunta di un nuovo dossier? i dati saranno ricaricati.");
if (alert)
else
{
currRecordClone = null;
isEditing = false;
await Task.Delay(1);
StateHasChanged();
// TOGLIERE!!!!!
await JSRuntime.InvokeAsync<bool>("location.reload");
}
}
protected override async Task OnInitializedAsync()
{
ListGruppiFase = await MDService.ElencoGruppiFase();
ListStati = await MDService.AnagStatiComm();
await reloadData(true);
}
protected override async Task OnParametersSetAsync()
{
if (!lastFilter.Equals(SelFilter))
{
lastFilter = SelFilter.clone();
await reloadData(true);
}
}
protected async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
currPage = 1;
StateHasChanged();
});
}
protected async Task selRecord(DossierModel selRec)
{
currRecord = selRec;
await RecordSel.InvokeAsync(selRec);
listaFlux = MDService.getFluxLog(selRec.Valore);
await toggleTableFlux();
}
protected async Task update(FluxLogDTO selRec)
{
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler salvare TUTTE le modifiche? queste saranno parte del dossier inviato all'impianto");
if (alert)
{
await Task.Delay(1);
if (currRecord != null)
{
@@ -184,106 +243,13 @@ namespace MP.SPEC.Components
// rimando a pagina corrente
NavManager.NavigateTo(NavManager.Uri, true);
}
}
protected async Task newDossier(Dossiers selRec)
{
var alert = await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler salvare TUTTE le modifiche? queste saranno parte del dossier inviato all'impianto");
if (alert)
{
await Task.Delay(1);
if (currRecordClone != null)
{
// serializzo valore x flux log...
DossierFluxLogDTO updatedResult = new DossierFluxLogDTO() { ODL = listaFlux };
string newVal = JsonConvert.SerializeObject(updatedResult);
currRecordClone.DataType = selRec.DataType;
currRecordClone.DtRif = DateTime.Now;
currRecordClone.IdxMacchina = selRec.IdxMacchina;
currRecordClone.CodArticolo = selRec.CodArticolo;
currRecordClone.IdxODL = selRec.IdxODL;
currRecordClone.Valore = selRec.Valore;
// METODO PER UPDATE FLUX
await MDService.DossiersInsert(currRecordClone);
currRecordClone = null;
isEditing = false;
await Task.Delay(1);
StateHasChanged();
}
return;
}
else
{
currRecordClone = null;
await Task.Delay(1);
await JSRuntime.InvokeAsync<bool>("location.reload");
}
}
protected override async Task OnInitializedAsync()
{
ListGruppiFase = await MDService.ElencoGruppiFase();
ListStati = await MDService.AnagStatiComm();
await reloadData(true);
}
protected async void OnSeachUpdated()
{
await InvokeAsync(() =>
{
currPage = 1;
StateHasChanged();
});
}
protected async Task selRecord(Dossiers selRec)
{
currRecord = selRec;
await RecordSel.InvokeAsync(selRec);
listaFlux = MDService.getFluxLog(selRec.Valore);
await toggleTableFlux();
}
protected async Task cloneRecord(Dossiers selRec)
{
// creo record duplicato...
Dossiers newRec = new Dossiers()
{
IdxDossier = selRec.IdxDossier,
DataType = selRec.DataType,
DtRif = selRec.DtRif,
IdxMacchina = selRec.IdxMacchina,
CodArticolo = selRec.CodArticolo,
IdxODL = selRec.IdxODL,
Valore = selRec.Valore,
};
currRecordClone = selRec;
await Task.Delay(1);
}
private List<AnagGruppi>? ListGruppiFase;
protected async Task UpdateData()
{
currRecord = null;
await reloadData(true);
}
private string css()
{
string answ = "";
if (isEditing)
{
answ = "visible";
}
else
{
answ = "hidden";
}
return answ;
}
#endregion Protected Methods
@@ -291,13 +257,19 @@ namespace MP.SPEC.Components
private int _totalCount = 0;
private Dossiers? currRecord = null;
private Dossiers? currRecordClone = null;
private FluxLogDTO? currFluxLogDto = null;
private DossierModel? currRecord = null;
private DossierModel? currRecordClone = null;
private List<AnagGruppi>? ListGruppiFase;
private List<DossierModel>? ListRecords;
private List<Dossiers>? ListRecords;
private List<ListValues>? ListStati;
private List<Dossiers>? SearchRecords;
private List<DossierModel>? SearchRecords;
#endregion Private Fields
@@ -317,6 +289,8 @@ namespace MP.SPEC.Components
private bool isLoading { get; set; } = false;
private SelectDossierParams lastFilter { get; set; } = new SelectDossierParams() { CurrPage = -1 };
private List<FluxLogDTO>? listaFlux { get; set; } = null;
private int MaxRecord
@@ -324,6 +298,9 @@ namespace MP.SPEC.Components
get => SelFilter.MaxRecord;
}
[Inject]
private NavigationManager NavManager { get; set; } = null!;
private int numRecord
{
get => SelFilter.NumRec;
@@ -339,6 +316,7 @@ namespace MP.SPEC.Components
{
get => SelFilter.DtEnd;
}
private DateTime SelDtStart
{
get => SelFilter.DtStart;
@@ -368,6 +346,35 @@ namespace MP.SPEC.Components
#region Private Methods
private async Task closeTableFlux()
{
currFluxLogDto = null;
currRecord = null;
visualizzaFlux = true;
isEditing = false;
await RecordSelFlux.InvokeAsync(currFluxLogDto);
await Task.Delay(1);
}
private string css()
{
string answ = "";
if (isEditing)
{
answ = "visible";
}
else
{
answ = "hidden";
}
return answ;
}
private void enableEditing()
{
isEditing = true;
}
private async Task reloadData(bool setChanged)
{
isLoading = true;
@@ -402,14 +409,10 @@ namespace MP.SPEC.Components
return answ;
}
private async Task closeTableFlux()
private string traduci(string lemma)
{
currFluxLogDto = null;
currRecord = null;
visualizzaFlux = true;
isEditing = false;
await RecordSelFlux.InvokeAsync(currFluxLogDto);
await Task.Delay(1);
var answ = MDService.Traduci(lemma, "IT");
return answ;
}
#endregion Private Methods
+8 -8
View File
@@ -338,7 +338,7 @@ namespace MP.SPEC.Data
/// </summary>
/// <param name="selRecord">record dossier da eliminare</param>
/// <returns></returns>
public async Task<bool> DossiersDeleteRecord(Dossiers selRecord)
public async Task<bool> DossiersDeleteRecord(DossierModel selRecord)
{
bool result = false;
Stopwatch stopWatch = new Stopwatch();
@@ -361,9 +361,9 @@ namespace MP.SPEC.Data
/// <param name="DtStart">Data minima per estrazione records</param>
/// <param name="DtEnd">Data Massima per estrazione records</param>
/// <returns></returns>
public async Task<List<Dossiers>> DossiersGetLastFilt(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd)
public async Task<List<DossierModel>> DossiersGetLastFilt(string IdxMacchina, string CodArticolo, DateTime DtStart, DateTime DtEnd)
{
List<Dossiers>? result = new List<Dossiers>();
List<DossierModel>? result = new List<DossierModel>();
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string readType = "DB";
@@ -372,7 +372,7 @@ namespace MP.SPEC.Data
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<Dossiers>>($"{rawData}");
result = JsonConvert.DeserializeObject<List<DossierModel>>($"{rawData}");
readType = "REDIS";
}
else
@@ -384,7 +384,7 @@ namespace MP.SPEC.Data
}
if (result == null)
{
result = new List<Dossiers>();
result = new List<DossierModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
@@ -397,7 +397,7 @@ namespace MP.SPEC.Data
/// </summary>
/// <param name="currDoss"></param>
/// <returns></returns>
public async Task<bool> DossiersInsert(Dossiers currDoss)
public async Task<bool> DossiersInsert(DossierModel currDoss)
{
// aggiorno record sul DB
bool answ = await dbController.DossiersInsert(currDoss);
@@ -451,7 +451,7 @@ namespace MP.SPEC.Data
/// </summary>
/// <param name="currDoss"></param>
/// <returns></returns>
public async Task<bool> DossiersUpdateValore(Dossiers currDoss)
public async Task<bool> DossiersUpdateValore(DossierModel currDoss)
{
// aggiorno record sul DB
bool answ = await dbController.DossiersUpdateValore(currDoss);
@@ -910,7 +910,7 @@ namespace MP.SPEC.Data
return answ;
}
public async Task<bool> updateDossierValue(Dossiers currDoss, FluxLogDTO editFL)
public async Task<bool> updateDossierValue(DossierModel currDoss, FluxLogDTO editFL)
{
bool answ = false;
// recupero intero set valori dossier deserializzando...
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2211.409</Version>
<Version>6.16.2211.410</Version>
</PropertyGroup>
<ItemGroup>
+2 -2
View File
@@ -50,7 +50,7 @@ namespace MP.SPEC.Pages
isFiltering = false;
}
protected async Task selRecordDoss(Dossiers selDoss)
protected async Task selRecordDoss(DossierModel selDoss)
{
currRecordDoss = selDoss;
await Task.Delay(1);
@@ -78,7 +78,7 @@ namespace MP.SPEC.Pages
set => currFilter.CurrPage = value;
}
private Dossiers? currRecordDoss { get; set; } = null;
private DossierModel? currRecordDoss { get; set; } = null;
private bool isEditing
{
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2211.409</h4>
<h4>Versione: 6.16.2211.410</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2211.409
6.16.2211.410
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2211.409</version>
<version>6.16.2211.410</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>