diff --git a/MP.Data/Controllers/MpMongoController.cs b/MP.Data/Controllers/MpMongoController.cs index c51bd878..939a5768 100644 --- a/MP.Data/Controllers/MpMongoController.cs +++ b/MP.Data/Controllers/MpMongoController.cs @@ -22,7 +22,7 @@ namespace MP.Data.Controllers public MpMongoController(IConfiguration configuration) { _configuration = configuration; - string mongoConf = _configuration.GetConnectionString("MongoConnect"); + string mongoConf = _configuration.GetConnectionString("mdbConnString"); client = new MongoClient(mongoConf); mongoDb = client.GetDatabase("MAPO"); Log.Info("Avviata classe MpMongoController"); diff --git a/MP.IOC/Controllers/RecipeController.cs b/MP.IOC/Controllers/RecipeController.cs index e245c688..6ebf6944 100644 --- a/MP.IOC/Controllers/RecipeController.cs +++ b/MP.IOC/Controllers/RecipeController.cs @@ -45,7 +45,7 @@ namespace MP.IOC.Controllers string rawData = await GetRecipe(idxPODL); if (!string.IsNullOrEmpty(rawData)) { - XmlDocument doc = (XmlDocument)JsonConvert.DeserializeXmlNode(rawData); + XmlDocument doc = (XmlDocument)(JsonConvert.DeserializeXmlNode(rawData) ?? new XmlDocument()); answ += doc.InnerXml; } return answ; diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs index 87970b06..9a0650c5 100644 --- a/MP.IOC/Data/MpDataService.cs +++ b/MP.IOC/Data/MpDataService.cs @@ -45,7 +45,7 @@ namespace MP.IOC.Data } // conf mongo... - connStr = _configuration.GetConnectionString("MongoConnect"); + connStr = _configuration.GetConnectionString("mdbConnString"); if (string.IsNullOrEmpty(connStr)) { _logger.LogError("MongoController: ConnString empty!"); @@ -322,7 +322,7 @@ namespace MP.IOC.Data // cerco in cache redis... string redKeyArtUsed = $"{Utils.redKeyArtUsed}:{codArticolo}"; string redKeyTabCheckArt = Utils.redKeyTabCheckArt; - string rawData = redisDb.StringGet(redKeyArtUsed); + var rawData = redisDb.StringGet(redKeyArtUsed); if (!string.IsNullOrEmpty(rawData)) { bool.TryParse(rawData, out answ); @@ -333,11 +333,11 @@ namespace MP.IOC.Data try { // cerco in cache se ci sia la tabella con gli articoli impiegati... - string rawTable = redisDb.StringGet(redKeyTabCheckArt); + var rawTable = redisDb.StringGet(redKeyTabCheckArt); List? artList = new List(); if (!string.IsNullOrEmpty(rawTable)) { - artList = JsonConvert.DeserializeObject>(rawTable); + artList = JsonConvert.DeserializeObject>($"{rawTable}"); } // rileggo... if (artList == null || artList.Count == 0) @@ -926,7 +926,7 @@ namespace MP.IOC.Data } /// - /// Verifica se la macchina abbia un codice ricetta associato + /// Verifica se la macchina abbia un codice CONF ricetta associato /// /// /// @@ -956,7 +956,7 @@ namespace MP.IOC.Data } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"MacchineRecipe | Read from {readType}: {ts.TotalMilliseconds}ms"); + Log.Debug($"MacchineRecipeConf | Read from {readType}: {ts.TotalMilliseconds}ms"); return result ?? ""; } @@ -1261,8 +1261,6 @@ namespace MP.IOC.Data TimeSpan ts = stopWatch.Elapsed; Log.Debug($"OdlListGetFilt | Read from {readType}: {ts.TotalMilliseconds}ms"); return result; - - //return await Task.FromResult(SpecDbController.OdlListGetFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate)); } /// @@ -1306,12 +1304,11 @@ namespace MP.IOC.Data /// /// /// - public async Task PODLDeleteRecord(PODLExpModel currRec) + public async Task POdlDeleteRecord(PODLExpModel currRec) { var dbResult = await SpecDbController.PODLDeleteRecord(currRec); // elimino cache redis... - RedisValue pattern = new RedisValue($"{Utils.redisXdlData}:*"); - bool answ = await RedisFlushPatternAsync(pattern); + await POdlFlushCache(); await Task.Delay(1); return dbResult; } @@ -1325,8 +1322,7 @@ namespace MP.IOC.Data { var dbResult = await SpecDbController.PODL_startSetup(currRec, 0, 1, 1, ""); // elimino cache redis... - RedisValue pattern = new RedisValue($"{Utils.redisXdlData}:*"); - bool answ = await RedisFlushPatternAsync(pattern); + await POdlFlushCache(); await Task.Delay(1); return dbResult; } @@ -1475,9 +1471,7 @@ namespace MP.IOC.Data { var dbResult = await SpecDbController.PODLUpdateRecord(currRec); // elimino cache redis... - RedisValue pattern = new RedisValue($"{Utils.redisXdlData}:*"); - bool answ = await RedisFlushPatternAsync(pattern); - await Task.Delay(1); + await POdlFlushCache(); return dbResult; } @@ -1508,6 +1502,10 @@ namespace MP.IOC.Data { bool answ = false; answ = await mongoController.RecipeSetByPODL(currRecord); + if (answ) + { + await POdlFlushCache(); + } return answ; } @@ -1615,14 +1613,14 @@ namespace MP.IOC.Data public KeyValuePair[] RedisGetHash(RedisKey redKey) { HashEntry[] rawData = redisDb.HashGetAll(redKey); - var result = rawData.Where(x => !x.Name.IsNull).Select(x => new KeyValuePair(x.Name, x.Value)).ToArray(); + var result = rawData.Where(x => !x.Name.IsNull).Select(x => new KeyValuePair($"{x.Name}", $"{x.Value}")).ToArray(); return result; } public async Task[]> RedisGetHashAsync(string redKey) { HashEntry[] rawData = await redisDb.HashGetAllAsync(redKey); - var result = rawData.Where(x => !x.Name.IsNull).Select(x => new KeyValuePair(x.Name, x.Value)).ToArray(); + var result = rawData.Where(x => !x.Name.IsNull).Select(x => new KeyValuePair($"{x.Name}", $"{x.Value}")).ToArray(); return result; } @@ -2153,6 +2151,21 @@ namespace MP.IOC.Data #region Private Methods + private async Task POdlFlushCache() + { + bool answ = false; + RedisValue pattern = new RedisValue($"{Utils.redisXdlData}:*"); + answ = await RedisFlushPatternAsync(pattern); + pattern = new RedisValue($"{Utils.redisPOdlByOdl}:*"); + answ = await RedisFlushPatternAsync(pattern); + pattern = new RedisValue($"{Utils.redisPOdlByPOdl}:*"); + answ = await RedisFlushPatternAsync(pattern); + pattern = new RedisValue($"{Utils.redisPOdlList}:*"); + answ = await RedisFlushPatternAsync(pattern); + + return answ; + } + private async Task resetCacheArticoli() { RedisValue pattern = new RedisValue($"{Utils.redisArtByDossier}:*"); diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 0fc49675..c1196beb 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -14,6 +14,8 @@ + + diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 7affedc3..05e7e91a 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2304.417

+

Versione: 6.16.2304.419


Note di rilascio: