FluxLogDTO:

- Update modello dati x gestione nuovo DTO
- bozza udpatre DB e servizio
This commit is contained in:
Samuele Locatelli
2022-10-12 06:20:54 +02:00
parent a4810826f8
commit d5f5cf9b11
12 changed files with 169 additions and 89 deletions
+7 -5
View File
@@ -86,7 +86,9 @@ else
@foreach (var record in listaFlux)
{
<tr>
<td><button @onclick="() => cloneRecord(record)" class="btn btn-info btn-sm" title="Duplica Record"><i class="bi bi-clipboard-check"></i></button></td>
<td>
<button @onclick="() => editRecord(record)" class="btn btn-info btn-sm" title="Duplica Record"><i class="bi bi-clipboard-check"></i></button>
</td>
<td>
@record.IdxMacchina
</td>
@@ -97,12 +99,12 @@ else
@record.CodFlux
</td>
<td style="text-align: right;">
<b>@record.Valore</b>
@if (ListRecordsMod != null)
<div><b>@record.Valore</b></div>
<div class="small text-secondary"><i>@record.Valore</i></div>
@*@if (ListRecordsMod != null)
{
<div>@findRec(record)</div>
}
}*@
</td>
</tr>
}
+11 -22
View File
@@ -13,7 +13,7 @@ namespace MP.SPEC.Components
[Parameter]
public EventCallback<Dossiers> RecordSel { get; set; }
[Parameter]
public EventCallback<FluxLog> RecordSelFlux { get; set; }
public EventCallback<FluxLogDTO> RecordSelFlux { get; set; }
[Parameter]
public SelectDossierParams SelFilter { get; set; } = null!;
@@ -72,31 +72,22 @@ namespace MP.SPEC.Components
await reloadData(true);
await Task.Delay(1);
}
protected async Task cloneRecord(FluxLog selRec)
protected async Task editRecord(FluxLogDTO selRec)
{
// creo record duplicato...
FluxLog newRec = new FluxLog()
{
IdxMacchina = selRec.IdxMacchina,
dtEvento = selRec.dtEvento,
CodFlux = selRec.CodFlux,
Valore = $"{selRec.Valore} - OLD"
};
currRecordFlux = selRec;
if (selRec != null)
{
ListRecordsMod.Add(newRec);
}
await RecordSelFlux.InvokeAsync(newRec);
// indico record selezionato
await RecordSelFlux.InvokeAsync(selRec);
}
protected string findRec(FluxLog record)
{
string answ = "";
#if false
if (ListRecordsMod != null)
{
answ = ListRecordsMod.Where(l => l.IdxMacchina == record.IdxMacchina && l.CodFlux == record.CodFlux).Select(x => x.Valore).SingleOrDefault();
}
}
#endif
return answ;
}
@@ -127,7 +118,7 @@ namespace MP.SPEC.Components
{
currRecord = selRec;
await RecordSel.InvokeAsync(selRec);
listaFlux = MDService.getOrigToFluxLog(selRec.Valore);
listaFlux = MDService.getFluxLog(selRec.Valore);
await toggleTableFlux();
}
@@ -147,9 +138,7 @@ namespace MP.SPEC.Components
private List<Dossiers>? ListRecords;
private List<FluxLog>? ListRecordsMod { get; set; } = new List<FluxLog>();
private FluxLog? currRecordFlux;
private FluxLogDTO? currRecordFlux;
private List<ListValues>? ListStati;
@@ -167,7 +156,7 @@ namespace MP.SPEC.Components
private bool isLoading { get; set; } = false;
private List<FluxLog>? listaFlux { get; set; } = null;
private List<FluxLogDTO>? listaFlux { get; set; } = null;
private int MaxRecord
{
+26 -20
View File
@@ -274,9 +274,9 @@ namespace MP.SPEC.Data
return await Task.FromResult(dbController.ConfigUpdate(updRec));
}
public List<FluxLog> getOrigToFluxLog(string Valore)
public List<FluxLogDTO> getFluxLog(string Valore)
{
List<FluxLog> answ = new List<FluxLog>();
List<FluxLogDTO> answ = new List<FluxLogDTO>();
DossierFluxLogDTO? result = JsonConvert.DeserializeObject<DossierFluxLogDTO>(Valore);
if (result != null)
{
@@ -286,33 +286,39 @@ namespace MP.SPEC.Data
.ODL
.OrderBy(x => x.CodFlux)
.ToList();
// inizializzo SE necessario
foreach (var item in answ)
{
item.ValoreEdit = String.IsNullOrEmpty(item.ValoreEdit) ? item.Valore : item.ValoreEdit;
}
}
}
return answ;
}
public List<FluxLog> getSendFluxLog(string Valore)
public async Task<bool> updateDossierValue(Dossiers currDoss, FluxLogDTO editFL)
{
List<FluxLog> answ = new List<FluxLog>();
DossierFluxLogDTO? result = JsonConvert.DeserializeObject<DossierFluxLogDTO>(Valore);
if (result != null)
bool answ = false;
// recupero intero set valori dossier deserializzando...
var fluxLogList = getFluxLog(currDoss.Valore);
await Task.Delay(1);
// se tutto ok
if (fluxLogList != null)
{
// se NON avessi SEND --> duplico da ODL...
if (result.SEND == null)
// aggiorno recordo corrente
var currRec = fluxLogList.FirstOrDefault(x => x.CodFlux == editFL.CodFlux && x.dtEvento == editFL.dtEvento);
if (currRec != null)
{
result.SEND = new List<FluxLog>();
foreach (var item in result.ODL)
{
result.SEND.Add(item);
}
}
if (result.SEND != null)
{
answ = result
.SEND
.OrderBy(x => x.CodFlux)
.ToList();
currRec = editFL;
}
// serializzo nuovamente valore
string rawVal = JsonConvert.SerializeObject(fluxLogList);
currDoss.Valore = rawVal;
// aggiorno record sul DB
await dbController.DossiersUpdateValore(currDoss);
}
return answ;
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2210.1120</Version>
<Version>6.16.2210.1206</Version>
</PropertyGroup>
<ItemGroup>
+7 -7
View File
@@ -21,7 +21,7 @@
</div>
</div>
<div class="card-body">
@if (currRecord != null)
@if (currDetFluxLogRecord != null)
{
<div class="row">
<div class="col-12">
@@ -32,25 +32,25 @@
<div class="col-3 pe-0">
<div class="input-group input-group-sm">
<span class="input-group-text" id="inputGroup-sizing-sm">MACCHINA</span>
<input type="text" class="form-control" disabled aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currRecord.IdxMacchina">
<input type="text" class="form-control" disabled aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currDetFluxLogRecord.IdxMacchina">
</div>
</div>
<div class="col-3 pe-0">
<div class="input-group input-group-sm">
<span class="input-group-text" id="inputGroup-sizing-sm">DATA</span>
<input type="text" class="form-control" disabled aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currRecord.dtEvento">
<input type="text" class="form-control" disabled aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currDetFluxLogRecord.dtEvento">
</div>
</div>
<div class="col-3 pe-0">
<div class="input-group input-group-sm">
<span class="input-group-text" id="inputGroup-sizing-sm">DATA TYPE</span>
<input type="text" class="form-control" disabled aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currRecord.CodFlux">
<input type="text" class="form-control" disabled aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currDetFluxLogRecord.CodFlux">
</div>
</div>
<div class="col-3 pe-0">
<div class="input-group input-group-sm">
<span class="input-group-text" id="inputGroup-sizing-sm">VALORE</span>
<input type="text" class="form-control" aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currRecord.Valore">
<input type="text" class="form-control" aria-label="Art search" aria-describedby="inputGroup-sizing-sm" @bind-value="@currDetFluxLogRecord.Valore">
</div>
</div>
</div>
@@ -66,7 +66,7 @@
</div>
<div class="col-3 pe-0">
<div class="d-grid gap-2">
<button @onclick="() => update(currRecord)" class="btn btn-success">Save <i class="bi bi-save"></i></button>
<button @onclick="() => update(currDetFluxLogRecord)" class="btn btn-success">Save <i class="bi bi-save"></i></button>
</div>
</div>
</div>
@@ -82,7 +82,7 @@
}
else
{
<ListDossiers SelFilter="@currFilter" RecordSelFlux="@selRecordFlux" TotRecordChanged="updateTotal"></ListDossiers>
<ListDossiers SelFilter="@currFilter" RecordSel="@selRecordDoss" RecordSelFlux="@selRecordFlux" TotRecordChanged="updateTotal"></ListDossiers>
}
</div>
<div class="card-footer py-1">
+50 -29
View File
@@ -1,6 +1,7 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
using MP.Data.DatabaseModels;
using MP.Data.DTO;
using MP.SPEC.Components;
using MP.SPEC.Data;
@@ -16,6 +17,12 @@ namespace MP.SPEC.Pages
#region Protected Properties
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
[Inject]
protected MpDataService MDService { get; set; } = null!;
[Inject]
protected MessageService MsgService { get; set; } = null!;
@@ -23,6 +30,12 @@ namespace MP.SPEC.Pages
#region Protected Methods
protected async Task cancel()
{
currDetFluxLogRecord = null;
await Task.Delay(1);
}
protected void ForceReload(int newNum)
{
numRecord = newNum;
@@ -33,34 +46,7 @@ namespace MP.SPEC.Pages
currPage = newNum;
StateHasChanged();
}
private FluxLog? _currRecord = null;
private FluxLog? currRecord
{
get => _currRecord;
set
{
_currRecord = value;
}
}
protected async Task cancel()
{
currRecord = null;
await Task.Delay(1);
}
protected async Task update(FluxLog selRec)
{
//if (!await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler salvare le modifiche?"))
// return;
await Task.Delay(1);
//METODO PER UPDATE FLUX
#if false
var done = await
await callSyncDb(selRec);
currRecord = null;
# endif
await Task.Delay(1);
}
protected override async Task OnInitializedAsync()
{
isLoading = true;
@@ -76,11 +62,33 @@ namespace MP.SPEC.Pages
await Task.Delay(1);
isFiltering = false;
}
protected async Task selRecordFlux(FluxLog selRec)
protected async Task selRecordDoss(Dossiers selDoss)
{
currRecord = selRec;
currRecordDoss = selDoss;
await Task.Delay(1);
}
protected async Task selRecordFlux(FluxLogDTO selRec)
{
currDetFluxLogRecord = selRec;
await Task.Delay(1);
}
protected async Task update(FluxLogDTO selRec)
{
if (!await JSRuntime.InvokeAsync<bool>("confirm", "Confermi di voler salvare le modifiche? queste saranno parte del dossier inviato all'impianto"))
return;
await Task.Delay(1);
if (currRecordDoss != null)
{
// METODO PER UPDATE FLUX
await MDService.updateDossierValue(currRecordDoss, selRec);
}
await Task.Delay(1);
}
protected void updateTotal(int newTotCount)
{
totalCount = newTotCount;
@@ -88,8 +96,20 @@ namespace MP.SPEC.Pages
#endregion Protected Methods
#region Private Fields
private FluxLogDTO? _currDetFluxLogRecord = null;
#endregion Private Fields
#region Private Properties
private FluxLogDTO? currDetFluxLogRecord
{
get => _currDetFluxLogRecord;
set { _currDetFluxLogRecord = value; }
}
private SelectDossierParams currFilter { get; set; } = new SelectDossierParams();
private int currPage
@@ -98,6 +118,7 @@ namespace MP.SPEC.Pages
set => MsgService.currPage = value;
}
private Dossiers? currRecordDoss { get; set; } = null;
private bool isFiltering { get; set; } = false;
private bool isLoading { get; set; } = true;
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2210.1120</h4>
<h4>Versione: 6.16.2210.1206</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2210.1120
6.16.2210.1206
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2210.1120</version>
<version>6.16.2210.1206</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>