|
|
|
@@ -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
|
|
|
|
|
}
|
|
|
|
|
}
|