From ebe082fb88d4e75b1e343eece10217e2aa311663 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 7 Mar 2026 09:40:21 +0100 Subject: [PATCH] Completato review metodo x trace Otel --- .../Services/DataLayerServices.cs | 574 +++++++++--------- Resources/VersNum.txt | 1 + 2 files changed, 292 insertions(+), 283 deletions(-) diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index c9e98418..348f89e4 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -77,8 +77,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ConfEnvirParamGetAllAsync() { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ConfEnvir"; @@ -99,8 +99,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ConfEnvirParamGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -123,8 +123,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ConfGlassGetAllAsync() { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ConfGlass"; @@ -145,8 +145,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ConfGlassGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -181,8 +181,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ConfProfileGetAllAsync() { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ConfProfile"; @@ -203,8 +203,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ConfProfileGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -239,8 +239,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ConfWoodGetAllAsync() { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ConfWood"; @@ -261,8 +261,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ConfWoodGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -284,9 +284,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> CostDriverGetAllAsync() { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:CostDrivers:ALL"; @@ -307,8 +306,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"CostDriverGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -319,9 +318,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> CountersGetAllAsync(int? yearRef = null) { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ConfEnvir"; @@ -342,8 +340,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"CountersGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -365,9 +363,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public List CustomersGetAll() { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Customers:ALL"; @@ -388,8 +385,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"CustomersGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -400,8 +397,7 @@ namespace EgwCoreLib.Lux.Data.Services public List DealersGetAll() { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Dealers:ALL"; @@ -422,8 +418,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"DealersGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -432,13 +428,13 @@ namespace EgwCoreLib.Lux.Data.Services /// public bool FlushCache() { + using var activity = StartActivity(); + string source = "REDIS"; bool answ = false; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); RedisValue pattern = new RedisValue($"{redisBaseKey}:*"); answ = ExecFlushRedisPattern(pattern); - stopWatch.Stop(); - Log.Debug($"FlushCache in {stopWatch.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } @@ -447,13 +443,13 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task FlushCacheAsync() { + using var activity = StartActivity(); + string source = "REDIS"; bool answ = false; - Stopwatch sw = new Stopwatch(); - sw.Start(); RedisValue pattern = new RedisValue($"{redisBaseKey}:*"); answ = await ExecFlushRedisPatternAsync(pattern); - sw.Stop(); - Log.Debug($"FlushCacheAsync in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } @@ -462,13 +458,13 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task FlushCacheOffersAsync() { + using var activity = StartActivity(); + string source = "REDIS"; bool answ = false; - Stopwatch sw = new Stopwatch(); - sw.Start(); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"FlushCacheOffersAsync in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } @@ -477,13 +473,13 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task FlushCacheOrdersAsync() { + using var activity = StartActivity(); + string source = "REDIS"; bool answ = false; - Stopwatch sw = new Stopwatch(); - sw.Start(); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); - sw.Stop(); - Log.Debug($"FlushCacheOrdersAsync in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } @@ -507,8 +503,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> GenClassGetAllAsync() { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:GenClass"; @@ -529,8 +525,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"GenClassGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -568,8 +564,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> GenValGetFiltAsync(string codClass) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:GenVal:{codClass}"; @@ -590,8 +586,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"GenValGetFiltAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -644,8 +640,8 @@ namespace EgwCoreLib.Lux.Data.Services public List ItemGetAlt(int ItemId) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Item:ListAlt:{ItemId}"; @@ -666,8 +662,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ItemGetAlt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -680,8 +676,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ItemGetFiltAsync(string CodGroup, ItemClassType ItemType) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string groupTok = string.IsNullOrEmpty(CodGroup) ? "ALL" : CodGroup; @@ -703,8 +699,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ItemGetFiltAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -716,8 +712,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ItemGetSearchAsync(string term) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string token = string.IsNullOrEmpty(term) ? "ALL" : term; @@ -739,8 +735,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ItemGetSearchAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -751,8 +747,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ItemGroupGetAllAsync() { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ItemGroup:ALL"; @@ -773,8 +769,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ItemGroupGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -829,8 +825,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> JobStepGetAsync(int jobID) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:JobStep:{jobID}"; @@ -851,8 +847,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"JobStepGetAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -905,8 +901,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> JobTaskGetAllAsync() { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:JobTaskList:ALL"; @@ -927,8 +923,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"JobTaskGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -953,9 +949,13 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task JobTaskUpsertAsync(JobTaskModel currRec) { + using var activity = StartActivity(); + string source = "DB+REDIS"; bool result = await dbController.JobTaskUpsertAsync(currRec); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:JobTaskList:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:JobStep:*"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -966,15 +966,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OfferClone(OfferModel rec2clone) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OfferClone(rec2clone); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OfferClone in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -984,9 +984,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> OfferGetAll() { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Offers:ALL"; @@ -1008,8 +1007,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"OfferGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1022,8 +1021,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> OfferGetFilt(DateTime inizio, DateTime fine) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Offers:Filt:{inizio:yyMMdd-HHmm}:{fine:yyMMdd-HHmm}"; @@ -1044,8 +1043,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"OfferGetFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1057,8 +1056,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> OfferRowGetByOffer(int OfferID) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:OfferRows:{OfferID}"; @@ -1080,8 +1079,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"OfferRowGetByOffer | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1092,9 +1091,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OfferRowGetByUID(string OfferRowUID) { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); OfferRowModel? result = null; // cerco in redis... string currKey = $"{redisBaseKey}:OfferRows:ByUID:{OfferRowUID}"; @@ -1112,8 +1110,8 @@ namespace EgwCoreLib.Lux.Data.Services rawData = JsonConvert.SerializeObject(result); await redisDb.StringSetAsync(currKey, rawData, LongCache); } - sw.Stop(); - Log.Debug($"OfferRowGetByUID | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1122,15 +1120,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffersCheckExpired() { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OffersCheckExpired(); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffersCheckExpired in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1157,15 +1155,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffertRowDelete(OfferRowModel updRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OffertRowDelete(updRec); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffertRowDelete in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1176,16 +1174,16 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> OffertRowFixUid(int OffertID) { + using var activity = StartActivity(); + string source = "DB+REDIS"; List answ = new List(); - Stopwatch sw = new Stopwatch(); - sw.Start(); // calcolo answ = dbController.OffertRowFixUid(OffertID); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffertRowFixUid in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } @@ -1199,8 +1197,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffertRowUpdateAwaitStateAsync(int offerRowID, 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.OffertRowUpdateAwaitStateAsync(offerRowID, awaitBom, awaitPrice); if (flushCache) @@ -1208,8 +1206,8 @@ namespace EgwCoreLib.Lux.Data.Services // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); } - sw.Stop(); - Log.Debug($"OffertRowUpdateAwaitStateAsync in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1221,15 +1219,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffertRowUpdateBom(int OfferRowID, List newBomList) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OffertRowUpdateBom(OfferRowID, newBomList); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffertRowUpdateBom in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1240,15 +1238,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffertRowUpdateFileData(OfferRowModel updRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OffertRowUpdateFileData(updRec); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffertRowUpdateFileData in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1260,15 +1258,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffertRowUpdateSerStruct(int OfferRowID, string serStruct) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OffertRowUpdateSerStruct(OfferRowID, serStruct); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffertRowUpdateSerStruct in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1279,8 +1277,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffertRowUpsert(OfferRowModel updRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OffertRowUpsert(updRec); if (fatto) @@ -1291,8 +1289,8 @@ namespace EgwCoreLib.Lux.Data.Services // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffertRowUpsert in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1303,15 +1301,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffertUpdateCost(int OfferID) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OffertUpdateCost(OfferID); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffertUpdateCost in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1322,15 +1320,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OffertUpsert(OfferModel updRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OffertUpsert(updRec); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); - sw.Stop(); - Log.Debug($"OffertUpsert in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1342,9 +1340,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderById(int orderId, bool doForce) { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); OrderModel? result = new OrderModel(); // cerco in redis... string currKey = $"{redisBaseKey}:Orders:ById:{orderId}"; @@ -1365,8 +1362,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new OrderModel(); } - sw.Stop(); - Log.Debug($"OrderById | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1379,8 +1376,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderFromOffer(OfferModel rec2clone) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo OrderModel? newOrd = await dbController.OrderFromOffer(rec2clone); if (newOrd != null) @@ -1390,8 +1387,8 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); } - sw.Stop(); - Log.Debug($"OrderFromOffer in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return newOrd; } @@ -1419,9 +1416,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> OrderGetFilt(DateTime inizio, DateTime fine) { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Orders:Filt:{inizio:yyMMdd-HHmm}:{fine:yyMMdd-HHmm}"; @@ -1442,8 +1438,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"OrderGetFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1454,16 +1450,16 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderRowDelete(OrderRowModel updRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OrderRowDelete(updRec); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"OrderRowDelete in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1474,17 +1470,17 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> OrderRowFixUid(int OrderID) { + using var activity = StartActivity(); + string source = "DB+REDIS"; List answ = new List(); - Stopwatch sw = new Stopwatch(); - sw.Start(); // calcolo answ = dbController.OrderRowFixUid(OrderID); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"OrderRowFixUid in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } @@ -1495,9 +1491,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> OrderRowGetByOffer(int OrderID) { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:OrderRows:{OrderID}"; @@ -1519,8 +1514,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"OrderRowGetByOffer | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1532,8 +1527,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> OrderRowGetByState(OrderStates reqState, DateTime dtStart, DateTime dtEnd) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:OrderRows:ByState:{reqState}"; @@ -1555,8 +1550,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"OrderRowGetByState | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1568,8 +1563,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> OrderRowGetByStateMin(OrderStates reqState, DateTime dtStart, DateTime dtEnd) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:OrderRows:ByStateMin:{reqState}"; @@ -1591,8 +1586,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"OrderRowGetByStateMin | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1604,8 +1599,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task OrderRowGetByUID(string OrderRowUID) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + OrderRowModel? result = null; // cerco in redis... string currKey = $"{redisBaseKey}:OrderRows:ByUID:{OrderRowUID}"; @@ -1623,8 +1618,8 @@ namespace EgwCoreLib.Lux.Data.Services rawData = JsonConvert.SerializeObject(result); await redisDb.StringSetAsync(currKey, rawData, LongCache); } - sw.Stop(); - Log.Debug($"OrderRowGetByUID | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1636,16 +1631,16 @@ namespace EgwCoreLib.Lux.Data.Services /// Elenco record da verificare public async Task OrderRowListValidate(List list2chk) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo int numDone = await dbController.OrderRowListValidate(list2chk); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"OrderRowListValidate in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return numDone; } @@ -1659,8 +1654,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderRowUpdateAwaitState(int orderRowID, 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.OrderRowUpdateAwaitState(orderRowID, awaitBom, awaitPrice); if (flushCache) @@ -1669,8 +1664,8 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); } - sw.Stop(); - Log.Debug($"OrderRowUpdateAwaitState in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1681,15 +1676,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderRowUpdateFileData(OrderRowModel updRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OrderRowUpdateFileData(updRec); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); - sw.Stop(); - Log.Debug($"OrderRowUpdateFileData in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1701,16 +1696,16 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderRowUpdateSerStruct(int OrderRowID, string serStruct) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OrderRowUpdateSerStruct(OrderRowID, serStruct); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"OrderRowUpdateSerStruct in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1722,16 +1717,16 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderRowUpdateState(int orderRowID, OrderStates reqState) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OrderRowUpdateState(orderRowID, reqState); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdGroup:*"); - sw.Stop(); - Log.Debug($"OrderRowUpdateState in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1742,16 +1737,16 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderRowUpsert(OrderRowModel updRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OrderRowUpsert(updRec); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"OrderRowUpsert in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1762,16 +1757,16 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task OrderUpsert(OrderModel updRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo bool fatto = await dbController.OrderUpsert(updRec); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Orders:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"OrderUpsert in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1781,9 +1776,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> PhasesGetAllAsync() { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Phases:ALL"; @@ -1804,8 +1798,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"PhasesGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1817,9 +1811,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task>?> PlannerGetEvents(DateTime dtStart, DateTime dtEnd) { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); Dictionary>? result = null; // cerco in redis... string currKey = $"{redisBaseKey}:PlannerData:{dtStart:yyyyMMdd}:{dtEnd:yyyyMMdd}"; @@ -1837,8 +1830,8 @@ namespace EgwCoreLib.Lux.Data.Services rawData = JsonConvert.SerializeObject(result); await redisDb.StringSetAsync(currKey, rawData, LongCache); } - sw.Stop(); - Log.Debug($"PlannerGetEvents | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1850,8 +1843,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ProdGroupByOrderRow(int OrderRowID) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ProdGroup:OrdRowId:{OrderRowID}"; @@ -1872,8 +1865,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ProdGroupByOrderRow | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1885,8 +1878,8 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ProdGroupByOrderState(OrderStates reqState) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ProdGroup:OrdRowState:{reqState}"; @@ -1907,8 +1900,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ProdGroupByOrderState | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -1920,8 +1913,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ProdItem2ODL_AssignAsync(List dbList, Dictionary<(int phaseId, int resId, string machine, int index), List> dictParts) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo int fatto = await dbController.ProdItem2ODL_AssignAsync(dbList, dictParts); // svuoto cache... @@ -1930,8 +1923,8 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdGroup:OrdRowId:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"ProdItem2ODL_AssignAsync in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1943,8 +1936,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ProdItemBulkAssignProdBatch(int OrderRowId, int ProdBatchId) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo int fatto = await dbController.ProdItemBulkAssignProdBatch(OrderRowId, ProdBatchId); // svuoto cache... @@ -1953,8 +1946,8 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdGroup:OrdRowId:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"ProdItemBulkAssignProdBatch in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1965,8 +1958,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ProdItemBulkAssignProdGroup(int OrderRowId, int ProdAssignId, Dictionary itemsToAssign) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo int fatto = await dbController.ProdItemBulkAssignProdGroup(OrderRowId, ProdAssignId, itemsToAssign); // svuoto cache... @@ -1975,8 +1968,8 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdGroup:OrdRowId:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); - sw.Stop(); - Log.Debug($"ProdItemBulkAssignProdGroup in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -1988,8 +1981,7 @@ namespace EgwCoreLib.Lux.Data.Services public async Task> ProdItemByOrderRow(int OrderRowId) { string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ProdItems:OrdRowId:{OrderRowId}"; @@ -2010,8 +2002,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ProdItemByOrderRow | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2022,11 +2014,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ProdItemResetOrderAssign(int orderRowID) { + using var activity = StartActivity(); + string source = "DB+REDIS"; int result = await dbController.ProdItemResetProdGroup(orderRowID); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdItems:OrdRowId:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdAssign:OrdRowId:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRows:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OrderRowsByState:*"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2036,9 +2032,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task?> ProdOdlAssignGetAsync() { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ProdOdl:Unassigned"; @@ -2059,8 +2054,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ProdOdlAssignGetAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2071,9 +2066,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ProdOdlGetByUidAsync(string uID) { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); ProductionODLModel? result = null; // cerco in redis... string currKey = $"{redisBaseKey}:ProdOdl:{uID}"; @@ -2090,8 +2084,8 @@ namespace EgwCoreLib.Lux.Data.Services rawData = JsonConvert.SerializeObject(result, JSSettings); await redisDb.StringSetAsync(currKey, rawData, LongCache); } - sw.Stop(); - Log.Debug($"ProdOdlGetByUidAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2103,8 +2097,12 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ProdOdlUpdateItemRawAsync(string uID, string itemListRaw) { + using var activity = StartActivity(); + string source = "DB+REDIS"; bool result = await dbController.ProdOdlUpdateItemRawAsync(uID, itemListRaw); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ProdOdl:*"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2114,9 +2112,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> ProdPlantGetAllAsync() { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:ProdPlantList"; @@ -2137,8 +2134,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ProdPlantGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2149,15 +2146,15 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ProductionBatchCreateAsync(ProductionBatchModel newRec) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo var dbResult = await dbController.ProductionBatchCreateAsync(newRec); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Batch:*"); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ODL:*"); - sw.Stop(); - Log.Debug($"ProductionBatchCreateAsync in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return dbResult; } @@ -2168,14 +2165,14 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> ProductionOdlCreateAsync(List listOdl2ins) { - Stopwatch sw = new Stopwatch(); - sw.Start(); + using var activity = StartActivity(); + string source = "DB+REDIS"; // calcolo var dbResult = await dbController.ProductionOdlCreateAsync(listOdl2ins); // svuoto cache... await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:ODL:*"); - sw.Stop(); - Log.Debug($"ProductionOdlCreateAsync in {sw.Elapsed.TotalMilliseconds} ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return dbResult; } @@ -2185,8 +2182,12 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ResourcesDeleteAsync(ResourceModel upsRec) { + using var activity = StartActivity(); + string source = "DB+REDIS"; bool result = await dbController.ResourcesDeleteAsync(upsRec); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Resources:*"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2196,9 +2197,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task> ResourcesGetAllAsync() { + using var activity = StartActivity(); string source = "DB"; - Stopwatch sw = new Stopwatch(); - sw.Start(); List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:Resources:ALL"; @@ -2219,8 +2219,8 @@ namespace EgwCoreLib.Lux.Data.Services { result = new List(); } - sw.Stop(); - Log.Debug($"ResourcesGetAllAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2231,8 +2231,12 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task ResourcesUpsertAsync(ResourceModel upsRec) { + using var activity = StartActivity(); + string source = "DB+REDIS"; bool result = await dbController.ResourcesUpsertAsync(upsRec); await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Resources:*"); + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2246,6 +2250,8 @@ namespace EgwCoreLib.Lux.Data.Services /// public async Task SaveBomAsync(string uID, Egw.Window.Data.Enums.QuestionModes qMode, Constants.EXECENVIRONMENTS execEnvironment, string bomContent) { + using var activity = StartActivity(); + string source = "DB"; // salvo sul DB il risultato della BOM if (!string.IsNullOrEmpty(bomContent)) { @@ -2295,6 +2301,8 @@ namespace EgwCoreLib.Lux.Data.Services } } } + activity?.SetTag("data.source", source); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); } /// @@ -2330,7 +2338,7 @@ namespace EgwCoreLib.Lux.Data.Services } } activity?.SetTag("data.source", source); - LogTrace($"SaveHmlAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); } /// @@ -2352,7 +2360,7 @@ namespace EgwCoreLib.Lux.Data.Services await dbController.ProdGroupUpsertBalance(uID, rGroup, balance); } activity?.SetTag("data.source", source); - LogTrace($"SaveProdBalanceAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); } /// @@ -2373,7 +2381,7 @@ namespace EgwCoreLib.Lux.Data.Services await dbController.OrderRowUpsertProdEst(uID, prodEstim); } activity?.SetTag("data.source", source); - LogTrace($"SaveProdEstimateAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); } /// @@ -2408,7 +2416,7 @@ namespace EgwCoreLib.Lux.Data.Services })); } activity?.SetTag("data.source", source); - LogTrace($"SaveProfileListAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); } } @@ -2444,7 +2452,7 @@ namespace EgwCoreLib.Lux.Data.Services })); } activity?.SetTag("data.source", source); - LogTrace($"SaveProfileThreshAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); } } @@ -2478,7 +2486,7 @@ namespace EgwCoreLib.Lux.Data.Services result = new List(); } activity?.SetTag("data.source", source); - LogTrace($"SellingItemsByEnvirAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2513,7 +2521,7 @@ namespace EgwCoreLib.Lux.Data.Services } // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TagsGetAllAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2533,7 +2541,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRows:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateCloneAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2553,7 +2561,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRows:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateDeleteAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2588,7 +2596,7 @@ namespace EgwCoreLib.Lux.Data.Services } // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateGetAllAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2624,7 +2632,7 @@ namespace EgwCoreLib.Lux.Data.Services } // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowByParentAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2644,7 +2652,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowCloneAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2664,7 +2672,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowDeleteAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2685,7 +2693,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowFixUid | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } @@ -2720,7 +2728,7 @@ namespace EgwCoreLib.Lux.Data.Services } // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowGetAllAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return result; } @@ -2745,7 +2753,7 @@ namespace EgwCoreLib.Lux.Data.Services } // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowUpdateAwaitStateAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2765,7 +2773,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowUpdateFileDataAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2786,7 +2794,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowUpdateSerStructAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2806,7 +2814,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateRowUpsertAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2826,7 +2834,7 @@ namespace EgwCoreLib.Lux.Data.Services await ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:TemplateRow:*"); // aggiunta tags + log activity?.SetTag("data.source", source); - LogTrace($"TemplateUpdateCostAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2847,7 +2855,7 @@ namespace EgwCoreLib.Lux.Data.Services // aggiunta tags + log activity?.SetTag("data.source", source); activity?.Stop(); - LogTrace($"TemplateUpsertAsync | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return fatto; } @@ -2942,7 +2950,7 @@ namespace EgwCoreLib.Lux.Data.Services // aggiunta tags + log activity?.SetTag("data.source", source); activity?.SetTag("param.pat2Flush", pat2Flush); - LogTrace($"ExecFlushRedisPattern | {pat2Flush} | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{pat2Flush} | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } @@ -3021,7 +3029,7 @@ namespace EgwCoreLib.Lux.Data.Services // aggiunta tags + log activity?.SetTag("data.source", source); activity?.SetTag("param.pat2Flush", pat2Flush); - LogTrace($"ExecFlushRedisPatternAsync | {pat2Flush} | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"{pat2Flush} | {source} | trace: {activity?.TraceId} | {activity?.Duration.TotalMilliseconds}ms"); return answ; } diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 21f815e0..7661d288 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1,2 @@ 1.1.2603.0709 +1.1.2603.0709