Ancora update metodi + udpate async generico
This commit is contained in:
@@ -194,9 +194,9 @@ namespace MP.Data.Controllers
|
||||
/// Elenco Gruppi tipo Fasi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagGruppiModel> AnagGruppiFase()
|
||||
public Task<List<AnagGruppiModel>> AnagGruppiFaseAsync()
|
||||
{
|
||||
return AnagGruppiGetTipo("FASE");
|
||||
return AnagGruppiGetTipoAsync("FASE");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1352,24 +1352,15 @@ namespace MP.Data.Controllers
|
||||
/// </summary>
|
||||
/// <param name="IdxOdl">id odl da cercare</param>
|
||||
/// <returns></returns>
|
||||
public List<AnagGiacenzeModel> ListGiacenze(int IdxOdl)
|
||||
public async Task<List<AnagGiacenzeModel>> ListGiacenzeAsync(int IdxOdl)
|
||||
{
|
||||
List<AnagGiacenzeModel> dbResult = new List<AnagGiacenzeModel>();
|
||||
using (var dbCtx = new MoonPro_InveContext(_configuration))
|
||||
{
|
||||
try
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbGiacenzeData
|
||||
.AsNoTracking()
|
||||
.Where(x => x.IdxOdl == IdxOdl)
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione durante ListGiacenze{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
using var dbCtx = new MoonPro_InveContext(_configuration);
|
||||
dbResult = await dbCtx
|
||||
.DbGiacenzeData
|
||||
.Where(x => x.IdxOdl == IdxOdl)
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -230,7 +230,7 @@ namespace MP.SPEC.Components
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await MDService.ConfigResetCache();
|
||||
ListGruppiFase = MDService.ElencoGruppiFase();
|
||||
ListGruppiFase = await MDService.ElencoGruppiFaseAsync();
|
||||
ListStati = await MDService.AnagStatiCommAsync();
|
||||
selAzienda = await MDService.ConfigTryGetAsync("AZIENDA");
|
||||
giacenzeConf = await MDService.ConfigTryGetAsync("SPEC_ShowGiacenze");
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace MP.SPEC.Components
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
elencoGiacenze = await MDService.ListGiacenze(IdxOdl);
|
||||
elencoGiacenze = await MDService.ListGiacenzeAsync(IdxOdl);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
+19
-130
@@ -652,44 +652,21 @@ namespace MP.SPEC.Data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco Fasi
|
||||
/// Restituisce elenco Fasi
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagGruppiModel> ElencoGruppiFase()
|
||||
public async Task<List<AnagGruppiModel>> ElencoGruppiFaseAsync()
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("ElencoGruppiFase");
|
||||
List<AnagGruppiModel> result = new List<AnagGruppiModel>();
|
||||
string source = "DB";
|
||||
string currKey = $"{Utils.redisAnagGruppi}:FASE";
|
||||
// cerco in redis dato valore sel idxMaccSel...
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
var rawResult = JsonConvert.DeserializeObject<List<AnagGruppiModel>>($"{rawData}");
|
||||
if (rawResult != null)
|
||||
{
|
||||
result = rawResult;
|
||||
}
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.AnagGruppiFase();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache / 5));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagGruppiModel>();
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"ElencoGruppiFase | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "ElencoGruppiFaseAsync",
|
||||
cacheKey: $"{Utils.redisAnagGruppi}:FASE",
|
||||
expiration: TimeSpan.FromMinutes(redisLongTimeCache / 5),
|
||||
fetchFunc: async () => await dbController.AnagGruppiFaseAsync() ?? new List<AnagGruppiModel>(),
|
||||
tagList: [Utils.redisAnagGruppi]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elenco link validi per il menu
|
||||
/// </summary>
|
||||
@@ -1369,38 +1346,20 @@ namespace MP.SPEC.Data
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco giacenze filtrate x IdxOdl
|
||||
/// </summary>
|
||||
/// <param name="IdxOdl">id odl da cercare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagGiacenzeModel>> ListGiacenze(int IdxOdl)
|
||||
public async Task<List<AnagGiacenzeModel>> ListGiacenzeAsync(int IdxOdl)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("ListGiacenze");
|
||||
List<AnagGiacenzeModel>? result = new List<AnagGiacenzeModel>();
|
||||
string source = "DB";
|
||||
string currKey = $"{Utils.redisGiacenzaList}:{IdxOdl}";
|
||||
// cerco in redis dato valore sel idxMaccSel...
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AnagGiacenzeModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ListGiacenze(IdxOdl));
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagGiacenzeModel>();
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"ListGiacenze | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "ListGiacenzeAsync",
|
||||
cacheKey: currKey,
|
||||
expiration: TimeSpan.FromSeconds(redisShortTimeCache),
|
||||
fetchFunc: async () => await dbController.ListGiacenzeAsync(IdxOdl) ?? new List<AnagGiacenzeModel>(),
|
||||
tagList: [Utils.redisGiacenzaList]
|
||||
);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -3050,76 +3009,6 @@ namespace MP.SPEC.Data
|
||||
await FlushCacheByTagsAsync(tags2del);
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Update valore Dossier
|
||||
/// </summary>
|
||||
/// <param name="currDoss"></param>
|
||||
/// <param name="editFL"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> updateDossierValue(DossierModel currDoss, FluxLogDTO editFL)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("updateDossierValue");
|
||||
string source = "DB";
|
||||
bool answ = false;
|
||||
// recupero intero set valori dossier deserializzando...
|
||||
var fluxLogList = FluxLogDtoGetByFlux(currDoss.Valore);
|
||||
// se tutto ok
|
||||
if (fluxLogList != null)
|
||||
{
|
||||
// da provare...!!!!
|
||||
|
||||
// elimino vecchio record
|
||||
var currRec = fluxLogList.FirstOrDefault(x => x.CodFlux == editFL.CodFlux && x.dtEvento == editFL.dtEvento);
|
||||
if (currRec != null)
|
||||
{
|
||||
fluxLogList.Remove(currRec);
|
||||
// aggiungo nuovo
|
||||
fluxLogList.Add(editFL);
|
||||
}
|
||||
|
||||
// serializzo nuovamente valore
|
||||
DossierFluxLogDTO? result = new DossierFluxLogDTO();
|
||||
var ODLflux = result.ODL.ToList();
|
||||
foreach (var item in fluxLogList)
|
||||
{
|
||||
ODLflux.Add(item);
|
||||
}
|
||||
|
||||
DossierFluxLogDTO updatedResult = new DossierFluxLogDTO() { ODL = ODLflux };
|
||||
|
||||
string rawVal = JsonConvert.SerializeObject(updatedResult);
|
||||
currDoss.Valore = rawVal;
|
||||
// aggiorno record sul DB
|
||||
await dbController.DossiersUpdateValore(currDoss);
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"updateDossierValue | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Elimina i record associati al keyFilt indicato
|
||||
/// </summary>
|
||||
/// <param name="KeyFilt"></param>
|
||||
public bool WipKitDeleteGroup(string KeyFilt)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("WipKitDeleteGroup");
|
||||
string source = "DB";
|
||||
bool fatto = false;
|
||||
// salvo
|
||||
fatto = dbController.WipKitDeleteGroup(KeyFilt);
|
||||
// svuoto cache
|
||||
EmptyWipCache();
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"WipKitDeleteGroup Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
return fatto;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Reset macchine e gruppi
|
||||
/// </summary>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>8.16.2605.2808</Version>
|
||||
<Version>8.16.2605.2809</Version>
|
||||
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace MP.SPEC.Pages
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await getReparto();
|
||||
var allGruppiData = MDService.ElencoGruppiFase();
|
||||
var allGruppiData = await MDService.ElencoGruppiFaseAsync();
|
||||
if (allGruppiData != null)
|
||||
{
|
||||
ListGruppiFase = allGruppiData.Where(x => x.SelEnabled).ToList();
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace MP.SPEC.Pages
|
||||
{
|
||||
await getReparto();
|
||||
ListAziende = await MDService.ElencoAziendeAsync();
|
||||
var allGruppiData = MDService.ElencoGruppiFase();
|
||||
var allGruppiData = await MDService.ElencoGruppiFaseAsync();
|
||||
if (allGruppiData != null)
|
||||
{
|
||||
ListGruppiFase = allGruppiData.Where(x => x.SelEnabled).ToList();
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.Services;
|
||||
using MP.SPEC.Components;
|
||||
using MP.SPEC.Data;
|
||||
using NLog.Layouts;
|
||||
using System.Reflection.PortableExecutable;
|
||||
|
||||
namespace MP.SPEC.Pages
|
||||
{
|
||||
@@ -37,10 +33,6 @@ namespace MP.SPEC.Pages
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
#if false
|
||||
[Inject]
|
||||
protected ILocalStorageService localStorage { get; set; } = null!;
|
||||
#endif
|
||||
|
||||
[Inject]
|
||||
protected ILocalStorageService localStorage { get; set; } = null!;
|
||||
@@ -59,13 +51,17 @@ namespace MP.SPEC.Pages
|
||||
if (sCodComm != value)
|
||||
{
|
||||
sCodComm = value;
|
||||
currPage = 1;
|
||||
ListRecords = null;
|
||||
ReloadData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private async Task ResetDataAsync()
|
||||
{
|
||||
currPage = 1;
|
||||
ListRecords = null;
|
||||
await ReloadDataAsync();
|
||||
}
|
||||
|
||||
protected string sParentCss
|
||||
{
|
||||
get => string.IsNullOrEmpty(sCodComm) ? "btn-secondary" : "btn-primary";
|
||||
@@ -120,8 +116,7 @@ namespace MP.SPEC.Pages
|
||||
protected async Task DoCancel()
|
||||
{
|
||||
EditRecord = null;
|
||||
ReloadData();
|
||||
await Task.Delay(1);
|
||||
await ResetDataAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -137,8 +132,7 @@ namespace MP.SPEC.Pages
|
||||
await Task.Delay(1);
|
||||
var done = await MDService.IstKitDelete(selRec);
|
||||
EditRecord = null;
|
||||
ReloadData();
|
||||
await Task.Delay(1);
|
||||
await ResetDataAsync();
|
||||
}
|
||||
|
||||
protected async Task DoUpdate(IstanzeKitModel selRec)
|
||||
@@ -149,8 +143,7 @@ namespace MP.SPEC.Pages
|
||||
await Task.Delay(1);
|
||||
var done = await MDService.IstKitUpsert(selRec);
|
||||
EditRecord = null;
|
||||
ReloadData();
|
||||
await Task.Delay(1);
|
||||
await ResetDataAsync();
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
@@ -176,9 +169,9 @@ namespace MP.SPEC.Pages
|
||||
setBaseFilt();
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
ReloadData();
|
||||
await ReloadDataAsync();
|
||||
}
|
||||
|
||||
protected void ResetData()
|
||||
@@ -191,10 +184,10 @@ namespace MP.SPEC.Pages
|
||||
idxMaccSel = "*";
|
||||
}
|
||||
|
||||
protected void ResetParent()
|
||||
protected async Task ResetParent()
|
||||
{
|
||||
SearchComm = "";
|
||||
ReloadData();
|
||||
await ResetDataAsync();
|
||||
}
|
||||
|
||||
protected void resetReparto()
|
||||
@@ -228,10 +221,10 @@ namespace MP.SPEC.Pages
|
||||
numRecord = newNum;
|
||||
}
|
||||
|
||||
protected void UpdateData()
|
||||
protected async Task UpdateData()
|
||||
{
|
||||
EditRecord = null;
|
||||
ReloadData();
|
||||
await ResetDataAsync();
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
@@ -311,7 +304,7 @@ namespace MP.SPEC.Pages
|
||||
if (_currPage != value)
|
||||
{
|
||||
_currPage = value;
|
||||
ReloadData();
|
||||
UpdateTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -342,7 +335,7 @@ namespace MP.SPEC.Pages
|
||||
if (_numRecord != value)
|
||||
{
|
||||
_numRecord = value;
|
||||
ReloadData();
|
||||
UpdateTable();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -359,11 +352,11 @@ namespace MP.SPEC.Pages
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private void ReloadData()
|
||||
private async Task ReloadDataAsync()
|
||||
{
|
||||
isLoading = true;
|
||||
// leggo dati x filtro
|
||||
var allGruppiData = MDService.ElencoGruppiFase();
|
||||
var allGruppiData = await MDService.ElencoGruppiFaseAsync();
|
||||
if (allGruppiData != null)
|
||||
{
|
||||
ListGruppiFase = allGruppiData.Where(x => x.SelEnabled).ToList();
|
||||
@@ -373,10 +366,15 @@ namespace MP.SPEC.Pages
|
||||
totalCount = SearchRecords.Count;
|
||||
// conto i kit = distinct...
|
||||
kitCount = SearchRecords.GroupBy(x => x.CodArtParent).Count();
|
||||
ListRecords = SearchRecords
|
||||
.Skip(numRecord * (currPage - 1))
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
UpdateTable();
|
||||
}
|
||||
|
||||
private void UpdateTable()
|
||||
{
|
||||
ListRecords = SearchRecords?
|
||||
.Skip(numRecord * (currPage - 1))
|
||||
.Take(numRecord)
|
||||
.ToList() ?? new();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
@@ -423,7 +421,7 @@ namespace MP.SPEC.Pages
|
||||
currPage = 1;
|
||||
// salvo filtro reparto x utente... spostare in componente?
|
||||
await localStorage.SetItemAsync("reparto", repartoSel);
|
||||
ReloadData();
|
||||
await ReloadDataAsync();
|
||||
currFilter = newParams;
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2605.2808</h4>
|
||||
<h4>Versione: 8.16.2605.2809</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2605.2808
|
||||
8.16.2605.2809
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2605.2808</version>
|
||||
<version>8.16.2605.2809</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>
|
||||
|
||||
Reference in New Issue
Block a user