Ancora update metodi x trace diffuso

This commit is contained in:
Samuele Locatelli
2026-03-06 19:03:31 +01:00
parent 566f80526b
commit ffbcde2bf0
7 changed files with 59 additions and 103 deletions
@@ -5152,7 +5152,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
/// </summary>
/// <param name="TemplateID"></param>
/// <returns></returns>
internal async Task<bool> TemplateUpdateCost(int TemplateID)
internal async Task<bool> TemplateUpdateCostAsync(int TemplateID)
{
bool answ = false;
//using (DataLayerContext dbCtx = new DataLayerContext(_config))
@@ -5217,7 +5217,7 @@ namespace EgwCoreLib.Lux.Data.Controllers
}
catch (Exception exc)
{
Log.Error($"Eccezione durante TemplateUpdateCost{Environment.NewLine}{exc}");
Log.Error($"Eccezione durante TemplateUpdateCostAsync{Environment.NewLine}{exc}");
}
}
return answ;
@@ -2445,7 +2445,6 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<List<TagsModel>> TagsGetAllAsync()
{
//using var activity = ActivitySource.StartActivity("TagsGetAllAsync");
using var activity = StartActivity();
string source = "DB";
List<TagsModel>? result = new List<TagsModel>();
@@ -2481,7 +2480,6 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateCloneAsync(TemplateModel rec2clone)
{
//using var activity = ActivitySource.StartActivity("TemplateCloneAsync");
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
@@ -2490,7 +2488,6 @@ namespace EgwCoreLib.Lux.Data.Services
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRows:*");
activity?.SetTag("data.source", source);
//activity?.Stop();
LogTrace($"TemplateCloneAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2502,15 +2499,15 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateDeleteAsync(TemplateModel updRec)
{
using var activity = ActivitySource.StartActivity("TemplateDeleteAsync");
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
bool fatto = await dbController.TemplateDeleteAsync(updRec);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRows:*");
activity?.Stop();
LogTrace($"TemplateDeleteAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateDeleteAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2520,9 +2517,8 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<List<TemplateModel>> TemplateGetAllAsync()
{
using var activity = StartActivity();
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<TemplateModel>? result = new List<TemplateModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:Template:ALL";
@@ -2544,8 +2540,8 @@ namespace EgwCoreLib.Lux.Data.Services
{
result = new List<TemplateModel>();
}
sw.Stop();
Log.Debug($"TemplateGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateGetAllAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2556,9 +2552,8 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<List<TemplateRowModel>> TemplateRowByParentAsync(int templateID)
{
using var activity = StartActivity();
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<TemplateRowModel>? result = new List<TemplateRowModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:TemplateRow:{templateID}";
@@ -2580,8 +2575,8 @@ namespace EgwCoreLib.Lux.Data.Services
{
result = new List<TemplateRowModel>();
}
sw.Stop();
Log.Debug($"TemplateRowByParentAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowByParentAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2592,15 +2587,15 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateRowCloneAsync(TemplateRowModel rec2clone)
{
Stopwatch sw = new Stopwatch();
sw.Start();
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
bool fatto = await dbController.TemplateRowCloneAsync(rec2clone);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*");
sw.Stop();
Log.Debug($"TemplateRowCloneAsync in {sw.Elapsed.TotalMilliseconds} ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowCloneAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2611,15 +2606,15 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateRowDeleteAsync(TemplateRowModel updRec)
{
Stopwatch sw = new Stopwatch();
sw.Start();
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
bool fatto = await dbController.TemplateRowDeleteAsync(updRec);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*");
sw.Stop();
Log.Debug($"TemplateRowDeleteAsync in {sw.Elapsed.TotalMilliseconds} ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowDeleteAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2630,16 +2625,16 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<List<string>> TemplateRowFixUid(int TemplateID)
{
using var activity = StartActivity();
string source = "DB+REDIS";
List<string> answ = new List<string>();
Stopwatch sw = new Stopwatch();
sw.Start();
// calcolo
answ = dbController.TemplateRowFixUid(TemplateID);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*");
sw.Stop();
Log.Debug($"TemplateRowFixUid in {sw.Elapsed.TotalMilliseconds} ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowFixUid | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2649,9 +2644,8 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<List<TemplateRowModel>> TemplateRowGetAllAsync()
{
using var activity = StartActivity();
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<TemplateRowModel>? result = new List<TemplateRowModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:TemplateRow:ALL";
@@ -2673,8 +2667,8 @@ namespace EgwCoreLib.Lux.Data.Services
{
result = new List<TemplateRowModel>();
}
sw.Stop();
Log.Debug($"TemplateRowGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowGetAllAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return result;
}
@@ -2688,8 +2682,8 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateRowUpdateAwaitStateAsync(int TemplateRowID, bool? awaitBom, bool? awaitPrice, bool flushCache = false)
{
Stopwatch sw = new Stopwatch();
sw.Start();
using var activity = StartActivity();
string source = "DB+REDIS";
// aggiorno
bool fatto = await dbController.TemplateRowUpdateAwaitStateAsync(TemplateRowID, awaitBom, awaitPrice);
if (flushCache)
@@ -2697,8 +2691,8 @@ namespace EgwCoreLib.Lux.Data.Services
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*");
}
sw.Stop();
Log.Debug($"TemplateRowUpdateAwaitStateAsync in {sw.Elapsed.TotalMilliseconds} ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowUpdateAwaitStateAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2709,15 +2703,15 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateRowUpdateFileDataAsync(TemplateRowModel updRec)
{
Stopwatch sw = new Stopwatch();
sw.Start();
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
bool fatto = await dbController.TemplateRowUpdateFileDataAsync(updRec);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*");
sw.Stop();
Log.Debug($"TemplateRowUpdateFileDataAsync in {sw.Elapsed.TotalMilliseconds} ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowUpdateFileDataAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2729,15 +2723,15 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateRowUpdateSerStructAsync(int TemplateRowID, string serStruct)
{
Stopwatch sw = new Stopwatch();
sw.Start();
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
bool fatto = await dbController.TemplateRowUpdateSerStructAsync(TemplateRowID, serStruct);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*");
sw.Stop();
Log.Debug($"TemplateRowUpdateSerStructAsync in {sw.Elapsed.TotalMilliseconds} ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowUpdateSerStructAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2748,15 +2742,15 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateRowUpsertAsync(TemplateRowModel updRec)
{
Stopwatch sw = new Stopwatch();
sw.Start();
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
bool fatto = await dbController.TemplateRowUpsertAsync(updRec);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*");
sw.Stop();
Log.Debug($"TemplateRowUpsertAsync in {sw.Elapsed.TotalMilliseconds} ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateRowUpsertAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2765,17 +2759,17 @@ namespace EgwCoreLib.Lux.Data.Services
/// </summary>
/// <param name="TemplateID">Key</param>
/// <returns></returns>
public async Task<bool> TemplateUpdateCost(int TemplateID)
public async Task<bool> TemplateUpdateCostAsync(int TemplateID)
{
Stopwatch sw = new Stopwatch();
sw.Start();
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
bool fatto = await dbController.TemplateUpdateCost(TemplateID);
bool fatto = await dbController.TemplateUpdateCostAsync(TemplateID);
// svuoto cache...
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Template:*");
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*");
sw.Stop();
Log.Debug($"TemplateUpdateCost in {sw.Elapsed.TotalMilliseconds} ms");
activity?.SetTag("data.source", source);
LogTrace($"TemplateUpdateCostAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2786,7 +2780,7 @@ namespace EgwCoreLib.Lux.Data.Services
/// <returns></returns>
public async Task<bool> TemplateUpsertAsync(TemplateModel updRec)
{
using var activity = ActivitySource.StartActivity("TemplateUpsertAsync");
using var activity = StartActivity();
string source = "DB+REDIS";
// calcolo
bool fatto = await dbController.TemplateUpsertAsync(updRec);
@@ -2795,7 +2789,7 @@ namespace EgwCoreLib.Lux.Data.Services
await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRows:*");
activity?.SetTag("data.source", source);
activity?.Stop();
LogTrace($"TemplateUpsertAsync | {source} | {activity?.Duration.TotalMilliseconds}ms");
LogTrace($"TemplateUpsertAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return fatto;
}
@@ -2821,7 +2815,7 @@ namespace EgwCoreLib.Lux.Data.Services
protected bool ExecFlushRedisPattern(RedisValue pat2Flush)
{
bool answ = false;
using var activity = ActivitySource.StartActivity("ExecFlushRedisPattern");
using var activity = StartActivity();
string source = "REDIS";
/*******************************
* Recupero elenco dei server da cui cancellare le chiavi:
@@ -2889,8 +2883,7 @@ namespace EgwCoreLib.Lux.Data.Services
}
activity?.SetTag("data.source", source);
activity?.SetTag("param.pat2Flush", pat2Flush);
//activity?.Stop();
LogTrace($"ExecFlushRedisPattern | {pat2Flush} | {source} | {activity?.Duration.TotalMilliseconds}ms");
LogTrace($"ExecFlushRedisPattern | {pat2Flush} | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2902,7 +2895,7 @@ namespace EgwCoreLib.Lux.Data.Services
protected async Task<bool> ExecFlushRedisPatternAsync(RedisValue pat2Flush)
{
bool answ = false;
using var activity = ActivitySource.StartActivity("ExecFlushRedisPatternAsync");
using var activity = StartActivity();
string source = "REDIS";
/*******************************
* Recupero elenco dei server da cui cancellare le chaivi:
@@ -2968,8 +2961,7 @@ namespace EgwCoreLib.Lux.Data.Services
}
activity?.SetTag("data.source", source);
activity?.SetTag("param.pat2Flush", pat2Flush);
//activity?.Stop();
LogTrace($"ExecFlushRedisPatternAsync | {pat2Flush} | {source} | {activity?.Duration.TotalMilliseconds}ms");
LogTrace($"ExecFlushRedisPatternAsync | {pat2Flush} | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms");
return answ;
}
@@ -2989,41 +2981,5 @@ namespace EgwCoreLib.Lux.Data.Services
#endregion Private Properties
#if false
/// <summary>
/// Elenco item Child da ParentId (per sostituzione) async
/// </summary>
/// <param name="ItemId">ID corrente di cui cercare parent + fratelli</param>
/// <returns></returns>
public List<ItemModel> ItemGetChild(int ItemId)
{
string source = "DB";
Stopwatch sw = new Stopwatch();
sw.Start();
List<ItemModel>? result = new List<ItemModel>();
// cerco in redis...
string currKey = $"{redisBaseKey}:Item:ListChild:{ItemId}";
RedisValue rawData = redisDb.StringGet(currKey);
if (rawData.HasValue)
{
result = JsonConvert.DeserializeObject<List<ItemModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = dbController.ItemGetChild(ItemId);
// serializzo e salvo con config x evitare loop...
rawData = JsonConvert.SerializeObject(result, JSSettings);
redisDb.StringSet(currKey, rawData, FastCache);
}
if (result == null)
{
result = new List<ItemModel>();
}
sw.Stop();
Log.Debug($"ItemGetChild | {source} | {sw.Elapsed.TotalMilliseconds}ms");
return result;
}
#endif
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2603.0618</Version>
<Version>1.1.2603.0619</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>1.1.2603.0618</Version>
<Version>1.1.2603.0619</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 1.1.2603.0618</h4>
<h4>Versione: 1.1.2603.0619</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2603.0618
1.1.2603.0619
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2603.0618</version>
<version>1.1.2603.0619</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>