Ancora update componenti con review tags
This commit is contained in:
@@ -215,7 +215,7 @@ namespace MP.SPEC.Components
|
||||
ListRecords = null;
|
||||
isLoading = true;
|
||||
|
||||
var list = await MDService.OdlGetCurrentAsync();
|
||||
var list = await MDService.MachineWithOdlAsync();
|
||||
_odlCurrSet = list.ToHashSet();
|
||||
|
||||
var machines = await MDService.MacchineGetFiltAsync("*");
|
||||
@@ -610,7 +610,7 @@ namespace MP.SPEC.Components
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// verifica se sia avviabile ODL x idxMaccSel
|
||||
/// Verifica se sia avviabile ODL x idxMaccSel
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
@@ -621,7 +621,7 @@ namespace MP.SPEC.Components
|
||||
|
||||
private async Task UpdateOdlList()
|
||||
{
|
||||
var list = await MDService.OdlGetCurrentAsync();
|
||||
var list = await MDService.MachineWithOdlAsync();
|
||||
_odlCurrSet = list.ToHashSet();
|
||||
}
|
||||
|
||||
|
||||
@@ -159,22 +159,15 @@ namespace MP.SPEC.Data
|
||||
/// <returns></returns>
|
||||
public async Task<List<vSelEventiBCodeModel>> AnagEventiGeneralAsync()
|
||||
{
|
||||
string redisKey = $"{Utils.redisEventList}:VSEB:GENERAL";
|
||||
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "AnagEventiGeneralAsync",
|
||||
cacheKey: redisKey,
|
||||
cacheKey: $"{Utils.redisEventList}:VSEB:GENERAL",
|
||||
expiration: getRandTOut(redisLongTimeCache),
|
||||
fetchFunc: async () =>
|
||||
{
|
||||
RedisValue rawData = await redisDb.StringGetAsync(redisKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<List<vSelEventiBCodeModel>>($"{rawData}") ?? new List<vSelEventiBCodeModel>();
|
||||
}
|
||||
|
||||
return await dbController.AnagEventiGeneralAsync() ?? new List<vSelEventiBCodeModel>();
|
||||
}
|
||||
},
|
||||
tagList: [Utils.redisEventList]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -292,7 +285,8 @@ namespace MP.SPEC.Data
|
||||
cacheKey: Utils.redisStatoCom,
|
||||
expiration: TimeSpan.FromMinutes(redisLongTimeCache),
|
||||
fetchFunc: async () =>
|
||||
await dbController.AnagStatiCommAsync() ?? new List<ListValuesModel>()
|
||||
await dbController.AnagStatiCommAsync() ?? new List<ListValuesModel>(),
|
||||
tagList: [Utils.redisStatoCom]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -395,8 +389,8 @@ namespace MP.SPEC.Data
|
||||
cacheKey: redisKey,
|
||||
expiration: TimeSpan.FromMinutes(2),
|
||||
fetchFunc: async () =>
|
||||
await dbController.ArticoliGetByTipoAsync(tipo, azienda)
|
||||
?? new List<AnagArticoliModel>()
|
||||
await dbController.ArticoliGetByTipoAsync(tipo, azienda) ?? new List<AnagArticoliModel>(),
|
||||
tagList: [Utils.redisArtList, $"{Utils.redisArtList}:Tipo"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -417,8 +411,8 @@ namespace MP.SPEC.Data
|
||||
cacheKey: redisKey,
|
||||
expiration: TimeSpan.FromMinutes(redisLongTimeCache),
|
||||
fetchFunc: async () =>
|
||||
await dbController.ArticoliGetSearchAsync(numRecord, tipoArt, azienda, searchVal)
|
||||
?? new List<AnagArticoliModel>()
|
||||
await dbController.ArticoliGetSearchAsync(numRecord, tipoArt, azienda, searchVal) ?? new List<AnagArticoliModel>(),
|
||||
tagList: [Utils.redisArtList, $"{Utils.redisArtList}:Search"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -480,7 +474,7 @@ namespace MP.SPEC.Data
|
||||
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"ArticoloDelEnabled | Cod: {codArticolo} | Source: {source}");
|
||||
LogTrace($"ArticoloDelEnabled | Cod: {codArticolo} | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return !usato;
|
||||
}
|
||||
|
||||
@@ -796,7 +790,8 @@ namespace MP.SPEC.Data
|
||||
cacheKey: $"{Utils.redisAnagGruppi}:Aziende",
|
||||
expiration: TimeSpan.FromMinutes(redisLongTimeCache * 2),
|
||||
fetchFunc: async () =>
|
||||
await dbController.AnagGruppiAziendeAsync() ?? new List<AnagGruppiModel>()
|
||||
await dbController.AnagGruppiAziendeAsync() ?? new List<AnagGruppiModel>(),
|
||||
tagList: [Utils.redisAnagGruppi, $"{Utils.redisAnagGruppi}:Aziende"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1086,11 +1081,9 @@ namespace MP.SPEC.Data
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCacheAsync()
|
||||
{
|
||||
bool fatto = false;
|
||||
await _cache.ClearAsync();
|
||||
await _cache.ClearAsync(allowFailSafe: false);
|
||||
_configData.Clear();
|
||||
fatto = true;
|
||||
return fatto;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1099,11 +1092,11 @@ namespace MP.SPEC.Data
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCacheByTagAsync(string tag)
|
||||
{
|
||||
bool fatto = false;
|
||||
if (string.IsNullOrWhiteSpace(tag)) return false;
|
||||
|
||||
await _cache.RemoveByTagAsync(tag);
|
||||
_configData.Clear();
|
||||
fatto = true;
|
||||
return fatto;
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -1112,14 +1105,17 @@ namespace MP.SPEC.Data
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCacheByTagsAsync(List<string> listTags)
|
||||
{
|
||||
bool fatto = false;
|
||||
foreach (var item in listTags)
|
||||
{
|
||||
await _cache.RemoveByTagAsync(item);
|
||||
}
|
||||
if (listTags == null || listTags.Count == 0) return false;
|
||||
|
||||
// Generiamo i Task di rimozione ed eseguiamoli in parallelo su Redis/L1
|
||||
var tasks = listTags
|
||||
.Where(tag => !string.IsNullOrWhiteSpace(tag))
|
||||
.Select(tag => _cache.RemoveByTagAsync(tag).AsTask());
|
||||
|
||||
await Task.WhenAll(tasks);
|
||||
|
||||
_configData.Clear();
|
||||
fatto = true;
|
||||
return fatto;
|
||||
return true;
|
||||
}
|
||||
|
||||
public async Task<bool> FlushCacheFluxLog()
|
||||
@@ -1681,9 +1677,7 @@ namespace MP.SPEC.Data
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
string keyGrp = codGruppo != "*" ? codGruppo : "ALL";
|
||||
|
||||
string redisKey = $"{Utils.redisMacList}:{keyGrp}";
|
||||
string memKey = $"MACCHINE_MEM:{keyGrp}";
|
||||
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "MacchineGetFiltAsync",
|
||||
@@ -1691,7 +1685,8 @@ namespace MP.SPEC.Data
|
||||
expiration: TimeSpan.FromMinutes(5),
|
||||
fetchFunc: async () =>
|
||||
await dbController.MacchineGetFiltAsync(codGruppo)
|
||||
?? new List<MacchineModel>()
|
||||
?? new List<MacchineModel>(),
|
||||
tagList: [Utils.redisMacList]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2005,13 +2000,12 @@ namespace MP.SPEC.Data
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public async Task<List<string>> OdlGetCurrentAsync()
|
||||
public async Task<List<string>> MachineWithOdlAsync()
|
||||
{
|
||||
string redisKey = Utils.redisOdlCurrByMac;
|
||||
string memKey = $"MEM:{redisKey}";
|
||||
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "OdlGetCurrentAsync",
|
||||
operationName: "MachineWithOdlAsync",
|
||||
cacheKey: redisKey,
|
||||
expiration: TimeSpan.FromSeconds(3),
|
||||
fetchFunc: async () =>
|
||||
@@ -2023,7 +2017,8 @@ namespace MP.SPEC.Data
|
||||
.ToList();
|
||||
|
||||
return dbResult ?? new List<string>();
|
||||
}
|
||||
},
|
||||
tagList: [Utils.redisOdlCurrByMac]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -2448,7 +2443,7 @@ namespace MP.SPEC.Data
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "POdlToKitListGetFiltAsync",
|
||||
cacheKey: redisKey,
|
||||
expiration: TimeSpan.FromSeconds(redisShortTimeCache),
|
||||
expiration: TimeSpan.FromSeconds(redisShortTimeCache * 5),
|
||||
fetchFunc: async () =>
|
||||
await dbController.ListPODL_KitFiltAsync(
|
||||
lanciato,
|
||||
@@ -2457,7 +2452,8 @@ namespace MP.SPEC.Data
|
||||
codGruppo,
|
||||
startDate,
|
||||
endDate
|
||||
) ?? new List<PODLExpModel>()
|
||||
) ?? new List<PODLExpModel>(),
|
||||
tagList: [Utils.redisPOdlList, $"{Utils.redisPOdlList}_kit"]
|
||||
);
|
||||
}
|
||||
|
||||
@@ -3273,7 +3269,7 @@ namespace MP.SPEC.Data
|
||||
/// <param name="fetchFunc"></param>
|
||||
/// <param name="expiration"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<T> GetOrFetchAsync<T>(string operationName, string cacheKey, Func<Task<T>> fetchFunc, TimeSpan expiration, params string[] tags)
|
||||
private async Task<T> GetOrFetchAsync<T>(string operationName, string cacheKey, Func<Task<T>> fetchFunc, TimeSpan expiration, params string[] tagList)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity(operationName);
|
||||
string source;
|
||||
@@ -3289,6 +3285,13 @@ namespace MP.SPEC.Data
|
||||
return result;
|
||||
}
|
||||
bool fromDb = false;
|
||||
// cache in redis
|
||||
var cacheOptions = new FusionCacheEntryOptions()
|
||||
.SetDuration(expiration)
|
||||
.SetFailSafe(true);
|
||||
// cache in RAM per 1/3 del tempo x risparmiare risorse
|
||||
cacheOptions.MemoryCacheDuration = expiration / 3;
|
||||
|
||||
var final = await _cache.GetOrSetAsync<T>(
|
||||
cacheKey,
|
||||
async _ =>
|
||||
@@ -3296,19 +3299,26 @@ namespace MP.SPEC.Data
|
||||
fromDb = true;
|
||||
return await fetchFunc();
|
||||
},
|
||||
opt =>
|
||||
{
|
||||
opt.SetDuration(expiration)
|
||||
.SetFailSafe(true);
|
||||
|
||||
//if (tags != null && tags.Length > 0)
|
||||
// opt.SetTags(tags);
|
||||
});
|
||||
options: cacheOptions,
|
||||
tags: tagList
|
||||
);
|
||||
|
||||
source = fromDb ? "DB" : "REDIS";
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.Stop();
|
||||
LogTrace($"{operationName} | {source} | {activity?.Duration.TotalMilliseconds:F4} ms");
|
||||
// switch log in base a source..
|
||||
switch (source)
|
||||
{
|
||||
case "DB":
|
||||
LogTrace($"{operationName} | {source} | {activity?.Duration.TotalMilliseconds:F4} ms", reqLevel: NLog.LogLevel.Info);
|
||||
break;
|
||||
case "REDIS":
|
||||
LogTrace($"{operationName} | {source} | {activity?.Duration.TotalMilliseconds:F4} ms", reqLevel: NLog.LogLevel.Debug);
|
||||
break;
|
||||
default:
|
||||
LogTrace($"{operationName} | {source} | {activity?.Duration.TotalMilliseconds:F4} ms");
|
||||
break;
|
||||
}
|
||||
return final!;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>8.16.2605.2716</Version>
|
||||
<Version>8.16.2605.2719</Version>
|
||||
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2605.2716</h4>
|
||||
<h4>Versione: 8.16.2605.2719</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2605.2716
|
||||
8.16.2605.2719
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2605.2716</version>
|
||||
<version>8.16.2605.2719</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