diff --git a/SMGen.Core/Constants.cs b/SMGen.Core/Constants.cs
new file mode 100644
index 0000000..88528c3
--- /dev/null
+++ b/SMGen.Core/Constants.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SMGen.Core
+{
+ ////
+ //// This is here so CodeMaid doesn't reorganize this document
+ ////
+ ///
+ public class Constants
+ {
+
+ public static readonly string BASE_HASH = "SMGEN";
+ public static readonly string BASE_PATH = Directory.GetCurrentDirectory();
+
+ public const string redisBaseAddr = "SMGEN";
+ public const string rKeyFiles = $"{redisBaseAddr}:Files";
+
+ }
+}
diff --git a/SMGen.Core/Enum.cs b/SMGen.Core/Enum.cs
new file mode 100644
index 0000000..0b9b3d8
--- /dev/null
+++ b/SMGen.Core/Enum.cs
@@ -0,0 +1,11 @@
+namespace SMGen.Core
+{
+ public class Enum
+ {
+ public enum LEVELS
+ {
+ LIVELLO_INGRESSI = 1,
+ LIVELLO_TRANSIZIONI = 2
+ }
+ }
+}
diff --git a/SMGen.Data/Services/SMGDataService.cs b/SMGen.Data/Services/SMGDataService.cs
index ee09137..87c3df8 100644
--- a/SMGen.Data/Services/SMGDataService.cs
+++ b/SMGen.Data/Services/SMGDataService.cs
@@ -2,9 +2,14 @@
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using NLog;
+using Org.BouncyCastle.Asn1.Pkcs;
+using SMGen.Core;
+using SMGen.UI;
using SMGen.Data.Controllers;
using SMGen.Data.DbModels;
using StackExchange.Redis;
+using System.Diagnostics;
+using SMGen.UI.Data;
namespace SMGen.Data.Services
{
@@ -40,12 +45,12 @@ namespace SMGen.Data.Services
private Random rnd = new Random();
- public SMGDataService(IConfiguration configuration)
+ public SMGDataService(IConfiguration configuration, IConnectionMultiplexer redisConnMult)
{
_configuration = configuration;
// Conf cache
- //redisConn = redisConnMult;
- //redisDb = this.redisConn.GetDatabase();
+ redisConn = redisConnMult;
+ redisDb = this.redisConn.GetDatabase();
// json serializer... FIX errore loop circolare https://www.ryadel.com/en/jsonserializationexception-self-referencing-loop-detected-error-fix-entity-framework-asp-net-core/
JSSettings = new JsonSerializerSettings()
@@ -82,6 +87,23 @@ namespace SMGen.Data.Services
var dbResult = await dbController.AnagEventinInsert(newEvList);
return dbResult;
}
+ public async Task FilesLoadRedis(List filesList)
+ {
+ bool fatto = false;
+ string currKey = $"{Constants.rKeyFiles}";
+ Stopwatch stopWatch = new Stopwatch();
+ stopWatch.Start();
+ string? rawData = await redisDb.StringGetAsync(currKey);
+ if (string.IsNullOrEmpty(rawData))
+ {
+ rawData = JsonConvert.SerializeObject(filesList, JSSettings);
+ fatto = await redisDb.StringSetAsync(currKey, rawData, LongCache);
+ }
+ stopWatch.Stop();
+ TimeSpan ts = stopWatch.Elapsed;
+ Log.Debug($"FilesLoad | REDIS in: {ts.TotalMilliseconds} ms");
+ return fatto;
+ }
#region Private Properties