Ancora update ART
This commit is contained in:
@@ -656,20 +656,20 @@ namespace MP.Data.Controllers
|
||||
/// Update record config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ConfigUpdate(ConfigModel updRec)
|
||||
public async Task<bool> ConfigUpdateAsync(ConfigModel updRec)
|
||||
{
|
||||
bool fatto = false;
|
||||
ConfigModel dbResult = new ConfigModel();
|
||||
using (var dbCtx = new MoonProContext(options))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
dbResult = await dbCtx
|
||||
.DbSetConfig
|
||||
.Where(x => x.Chiave == updRec.Chiave)
|
||||
.FirstOrDefault();
|
||||
.FirstOrDefaultAsync();
|
||||
if (dbResult != null)
|
||||
{
|
||||
dbResult.Valore = updRec.Valore;
|
||||
dbCtx.SaveChanges();
|
||||
await dbCtx.SaveChangesAsync();
|
||||
fatto = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -631,14 +631,14 @@ namespace MP.SPEC.Data
|
||||
/// Update chiave config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ConfigUpdate(ConfigModel updRec)
|
||||
public async Task<bool> ConfigUpdateAsync(ConfigModel updRec)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("ConfigUpdate");
|
||||
using var activity = ActivitySource.StartActivity("ConfigUpdateAsync");
|
||||
string source = "DB";
|
||||
var updRes = dbController.ConfigUpdate(updRec);
|
||||
var updRes = await dbController.ConfigUpdateAsync(updRec);
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"ConfigUpdate Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
LogTrace($"ConfigUpdateAsync Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
return updRes;
|
||||
}
|
||||
|
||||
|
||||
@@ -19,10 +19,10 @@
|
||||
<div class="px-0 align-content-center">
|
||||
<div class="input-group">
|
||||
<span class="input-group-text"><i class="fa fa-search"></i></span>
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Cerca (3+ char)" aria-label="Ricerca" title="Ricerca (3+ char)" @bind="@SearchVal">
|
||||
<input type="text" class="form-control form-control-sm" placeholder="Cerca (3+ char)" aria-label="Ricerca" title="Ricerca (3+ char)" @bind="@SearchVal" @bind:after="ReloadDataAsync">
|
||||
<button class="btn @searchCss" @onclick="() => resetSearch()"><i class="fa fa-ban"></i></button>
|
||||
<label class="input-group-text" for="maxRecord" title="Selezionare l'azienda da visualizzare"><i class="fa-solid fa-industry"></i></label>
|
||||
<select @bind="@selAzienda" class="form-select form-select-sm" title="Selezionare l'azienda da visualizzare">
|
||||
<select @bind="@selAzienda" class="form-select form-select-sm" title="Selezionare l'azienda da visualizzare" @bind:after="ReloadAziendaAsync">
|
||||
@if (ListAziende != null)
|
||||
{
|
||||
foreach (var item in ListAziende)
|
||||
@@ -32,7 +32,7 @@
|
||||
}
|
||||
</select>
|
||||
<span class="input-group-text"><i class="fa fa-database"></i></span>
|
||||
<input type="number" class="form-control form-control-sm" aria-label="Num record" title="NUm massimo record da recuperare" @bind="@maxNumRecord" width="5">
|
||||
<input type="number" inputmode="numeric" min="10" max="100000" class="form-control form-control-sm text-end" style="width: 6rem; flex: 0 0 auto;" aria-label="Num record" title="Num massimo record da recuperare" @bind="@maxNumRecord" @bind:after="ReloadDataAsync">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -65,13 +65,15 @@ namespace MP.SPEC.Pages
|
||||
if (searchVal != value)
|
||||
{
|
||||
searchVal = value;
|
||||
#if false
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
ListRecords = null;
|
||||
await Task.Delay(1);
|
||||
await ReloadData();
|
||||
});
|
||||
pUpd.Wait();
|
||||
{
|
||||
ListRecords = null;
|
||||
await Task.Delay(1);
|
||||
await ReloadDataAsync();
|
||||
});
|
||||
pUpd.Wait();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -117,7 +119,7 @@ namespace MP.SPEC.Pages
|
||||
protected async Task cancel()
|
||||
{
|
||||
currRecord = null;
|
||||
await ReloadData();
|
||||
await ReloadDataAsync();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
@@ -151,7 +153,7 @@ namespace MP.SPEC.Pages
|
||||
await Task.Delay(1);
|
||||
var done = await MDService.ArticoliDeleteRecord(selRec);
|
||||
currRecord = null;
|
||||
await ReloadData();
|
||||
await ReloadDataAsync();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
@@ -173,7 +175,7 @@ namespace MP.SPEC.Pages
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
await ReloadDataAsync();
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
@@ -185,7 +187,7 @@ namespace MP.SPEC.Pages
|
||||
protected async Task resetSearch()
|
||||
{
|
||||
SearchVal = "";
|
||||
await ReloadData();
|
||||
await ReloadDataAsync();
|
||||
}
|
||||
|
||||
protected async Task resetSel()
|
||||
@@ -209,14 +211,14 @@ namespace MP.SPEC.Pages
|
||||
await Task.Delay(1);
|
||||
var done = await MDService.ArticoliUpdateRecord(selRec);
|
||||
currRecord = null;
|
||||
await ReloadData();
|
||||
await ReloadDataAsync();
|
||||
await Task.Delay(1);
|
||||
}
|
||||
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
currRecord = null;
|
||||
await ReloadData();
|
||||
await ReloadDataAsync();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
@@ -230,6 +232,7 @@ namespace MP.SPEC.Pages
|
||||
private List<AnagGruppiModel>? ListAziende;
|
||||
private List<AnagArticoliModel>? ListRecords;
|
||||
private List<ListValuesModel>? ListTipoArt;
|
||||
private int maxNumRecord = 5000;
|
||||
private List<AnagArticoliModel>? SearchRecords;
|
||||
|
||||
#endregion Private Fields
|
||||
@@ -278,24 +281,41 @@ namespace MP.SPEC.Pages
|
||||
if (value != _selAzienda)
|
||||
{
|
||||
_selAzienda = value;
|
||||
#if false
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
// svuoto cache redis...
|
||||
ConfigModel updRec = new ConfigModel()
|
||||
{
|
||||
Chiave = "AZIENDA",
|
||||
Valore = value
|
||||
};
|
||||
MDService.ConfigUpdate(updRec);
|
||||
await MDService.ConfigResetCache();
|
||||
// ricarico
|
||||
await Task.Delay(1);
|
||||
await ReloadData();
|
||||
});
|
||||
pUpd.Wait();
|
||||
{
|
||||
// svuoto cache redis...
|
||||
ConfigModel updRec = new ConfigModel()
|
||||
{
|
||||
Chiave = "AZIENDA",
|
||||
Valore = value
|
||||
};
|
||||
MDService.ConfigUpdate(updRec);
|
||||
await MDService.ConfigResetCache();
|
||||
// ricarico
|
||||
await Task.Delay(1);
|
||||
await ReloadDataAsync();
|
||||
});
|
||||
pUpd.Wait();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
private async Task ReloadAziendaAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
// svuoto cache redis...
|
||||
ConfigModel updRec = new ConfigModel()
|
||||
{
|
||||
Chiave = "AZIENDA",
|
||||
Valore = selAzienda
|
||||
};
|
||||
await MDService.ConfigUpdateAsync(updRec);
|
||||
await MDService.ConfigResetCache();
|
||||
// ricarico
|
||||
await ReloadDataAsync();
|
||||
}
|
||||
|
||||
|
||||
private bool ShowCharts { get; set; } = false;
|
||||
|
||||
@@ -325,16 +345,16 @@ namespace MP.SPEC.Pages
|
||||
ListTipoArt = await MDService.AnagTipoArtLvAsync();
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
private async Task ReloadDataAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
SearchRecords = await MDService.ArticoliGetSearchAsync(100000, selAzienda, SearchVal);
|
||||
SearchRecords = await MDService.ArticoliGetSearchAsync(maxNumRecord, selAzienda, SearchVal);
|
||||
UpdateTable();
|
||||
}
|
||||
|
||||
private void UpdateTable()
|
||||
{
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
ListRecords = SearchRecords?.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList() ?? new();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user