diff --git a/MP.IOC/Controllers/RecipeArchiveController.cs b/MP.IOC/Controllers/RecipeArchiveController.cs new file mode 100644 index 00000000..405040f9 --- /dev/null +++ b/MP.IOC/Controllers/RecipeArchiveController.cs @@ -0,0 +1,79 @@ +using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc; +using MP.IOC.Data; +using NLog; + +namespace MP.IOC.Controllers +{ + [Route("api/[controller]")] + [ApiController] + public class RecipeArchiveController : ControllerBase + { + #region Public Constructors + + public RecipeArchiveController(IConfiguration configuration, MpDataService DataService) + { + Log.Info("Starting RecipeArchiveController"); + _configuration = configuration; + DService = DataService; + Log.Info("Avviata classe RecipeArchiveController"); + } + + #endregion Public Constructors + + #region Public Methods + + [HttpGet("GetByPODL")] + public async Task GetByPODL(string idxMacc, int idxPODL) + { + string answ = ""; + string archPath = await DService.MacchineRecipeArchive(idxMacc); + var podlData = await DService.POdlGetByKey(idxPODL); + if (podlData != null) + { + string fileName = podlData?.Recipe ?? ""; + string fullPath = Path.Combine(archPath, fileName); + if (!string.IsNullOrEmpty(fullPath)) + { + answ = System.IO.File.ReadAllText(fullPath); + } + } + return answ; + } + + [HttpGet("GetFile")] + public async Task GetFile(string idxMacc, string fileName) + { + string answ = ""; + string archPath = await DService.MacchineRecipeArchive(idxMacc); + if (!string.IsNullOrEmpty(archPath)) + { + string fullPath = Path.Combine(archPath, fileName); + if (!string.IsNullOrEmpty(fullPath)) + { + answ = System.IO.File.ReadAllText(fullPath); + } + } + return answ; + } + + #endregion Public Methods + + #region Protected Properties + + /// + /// Dataservice x accesso DB + /// + protected MpDataService DService { get; set; } + + #endregion Protected Properties + + #region Private Fields + + private static IConfiguration _configuration = null!; + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs index a9cb16bf..87970b06 100644 --- a/MP.IOC/Data/MpDataService.cs +++ b/MP.IOC/Data/MpDataService.cs @@ -818,109 +818,6 @@ namespace MP.IOC.Data return result; } - /// - /// elenco TUTTI gli ODL - /// - /// - /// - public List ListOdlAll() - { - List? result = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string readType = "DB"; - result = SpecDbController.ListOdlAll(); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ListOdlAll | Read from {readType}: {ts.TotalMilliseconds}ms"); - return result; - } - - /// - /// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato) - /// - /// Stato ODL: true=in corso/completato - /// Cod articolo - /// KeyRich (parziale) da cercare (es cod stato x yacht) - /// Reparto selezionato - /// Macchina selezionata - /// Data inizio - /// Data fine - /// - public async Task> ListODLFilt(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate) - { - List? result = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string readType = "DB"; - string currKey = $"{Utils.redisOdlList}:{inCorso}:{codArt}:{keyRichPart}:{Reparto}:{IdxMacchina}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}"; - // cerco in redis dato valore sel macchina... - RedisValue rawData = redisDb.StringGet(currKey); - if (rawData.HasValue) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - readType = "REDIS"; - } - else - { - result = await Task.FromResult(SpecDbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate)); - // serializzo e salvo... - rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache)); - } - if (result == null) - { - result = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ListODLFilt | Read from {readType}: {ts.TotalMilliseconds}ms"); - return result; - - //return await Task.FromResult(SpecDbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate)); - } - - /// - /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato) - /// - /// Solo lanciati (1) o ancora disponibili (0) - /// KeyRich (parziale) da cercare (es cod stato x yacht) - /// Macchina - /// Gruppo - /// Data inizio - /// Data fine - /// - public async Task> ListPODLFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate) - { - List? result = new List(); - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string readType = "DB"; - string currKey = $"{Utils.redisPOdlList}:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}"; - // cerco in redis dato valore sel macchina... - RedisValue rawData = redisDb.StringGet(currKey); - if (rawData.HasValue) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - readType = "REDIS"; - } - else - { - result = await Task.FromResult(SpecDbController.ListPODLFilt(lanciato, keyRichPart, idxMacchina, codGruppo, startDate, endDate)); - // serializzo e salvo... - rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache)); - } - if (result == null) - { - result = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ListPODLFilt | Read from {readType}: {ts.TotalMilliseconds}ms"); - return result; - } - /// /// Elenco completo valori Macchine 2 Slave /// @@ -994,17 +891,52 @@ namespace MP.IOC.Data } /// - /// Verifica se la macchina abbia un codice ricetta associato + /// Verifica se la macchina abbia un codice PATH ricette associato /// /// /// - public async Task MacchineRecipe(string idxMacchina) + public async Task MacchineRecipeArchive(string idxMacchina) { string? result = ""; Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); string readType = "DB"; - string currKey = $"{Utils.redisMacRecipe}:{idxMacchina}"; + string currKey = $"{Utils.redisMacRecipePath}:{idxMacchina}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject($"{rawData}"); + readType = "REDIS"; + } + else + { + //recupero elenco macchine... + var machineList = await MacchineGetFilt("*"); + var currMach = machineList.Where(x => x.IdxMacchina == idxMacchina).FirstOrDefault(); + result = currMach != null ? currMach.RecipeArchivePath : null; + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache)); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"MacchineRecipeArchive | Read from {readType}: {ts.TotalMilliseconds}ms"); + return result ?? ""; + } + + /// + /// Verifica se la macchina abbia un codice ricetta associato + /// + /// + /// + public async Task MacchineRecipeConf(string idxMacchina) + { + string? result = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + string currKey = $"{Utils.redisMacRecipeConf}:{idxMacchina}"; // cerco in redis dato valore sel macchina... RedisValue rawData = redisDb.StringGet(currKey); if (rawData.HasValue) @@ -1271,6 +1203,68 @@ namespace MP.IOC.Data return dbResult; } + /// + /// elenco TUTTI gli ODL + /// + /// + /// + public List OdlListAll() + { + List? result = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + result = SpecDbController.OdlListAll(); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"OdlListAll | Read from {readType}: {ts.TotalMilliseconds}ms"); + return result; + } + + /// + /// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato) + /// + /// Stato ODL: true=in corso/completato + /// Cod articolo + /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// Reparto selezionato + /// Macchina selezionata + /// Data inizio + /// Data fine + /// + public async Task> OdlListGetFilt(bool inCorso, string codArt, string keyRichPart, string Reparto, string IdxMacchina, DateTime startDate, DateTime endDate) + { + List? result = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + string currKey = $"{Utils.redisOdlList}:{inCorso}:{codArt}:{keyRichPart}:{Reparto}:{IdxMacchina}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + readType = "REDIS"; + } + else + { + result = await Task.FromResult(SpecDbController.ListODLFilt(inCorso, codArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate)); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache)); + } + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + 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)); + } + /// /// Elenco di tutti i parametri filtrati x macchina /// @@ -1307,12 +1301,42 @@ namespace MP.IOC.Data return result; } + /// + /// Eliminazione record selezionato + /// + /// + /// + 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 Task.Delay(1); + return dbResult; + } + + /// + /// Avvio fase setup per il record selezionato + /// + /// + /// + public async Task POdlDoSetup(PODLExpModel currRec) + { + 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 Task.Delay(1); + return dbResult; + } + /// /// Recupero PODL da chiave /// /// /// - public async Task PODL_getByKey(int idxPODL) + public async Task POdlGetByKey(int idxPODL) { PODLModel result = new PODLModel(); if (idxPODL != 0) @@ -1345,7 +1369,7 @@ namespace MP.IOC.Data } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"PODL_getByKey | Read from {readType}: {ts.TotalMilliseconds}ms"); + Log.Trace($"POdlGetByKey | Read from {readType}: {ts.TotalMilliseconds}ms"); } else { @@ -1359,7 +1383,7 @@ namespace MP.IOC.Data /// /// /// - public PODLModel PODL_getByOdl(int idxODL) + public PODLModel POdlGetByOdl(int idxODL) { PODLModel result = new PODLModel(); if (idxODL != 0) @@ -1392,7 +1416,7 @@ namespace MP.IOC.Data } stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"PODL_getByOdl | Read from {readType}: {ts.TotalMilliseconds}ms"); + Log.Trace($"POdlGetByOdl | Read from {readType}: {ts.TotalMilliseconds}ms"); } else { @@ -1402,33 +1426,44 @@ namespace MP.IOC.Data } /// - /// Eliminazione record selezionato + /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato) /// - /// + /// Solo lanciati (1) o ancora disponibili (0) + /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// Macchina + /// Gruppo + /// Data inizio + /// Data fine /// - public async Task PODLDeleteRecord(PODLExpModel currRec) + public async Task> POdlListGetFilt(bool lanciato, string keyRichPart, string idxMacchina, string codGruppo, DateTime startDate, DateTime endDate) { - var dbResult = await SpecDbController.PODLDeleteRecord(currRec); - // elimino cache redis... - RedisValue pattern = new RedisValue($"{Utils.redisXdlData}:*"); - bool answ = await RedisFlushPatternAsync(pattern); - await Task.Delay(1); - return dbResult; - } - - /// - /// Avvio fase setup per il record selezionato - /// - /// - /// - public async Task POdlDoSetup(PODLExpModel currRec) - { - 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 Task.Delay(1); - return dbResult; + List? result = new List(); + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + string currKey = $"{Utils.redisPOdlList}:{codGruppo}:{idxMacchina}:{keyRichPart}:{lanciato}:{startDate:yyyyMMdd_HHmmss}:{endDate:yyyyMMdd_HHmmss}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + readType = "REDIS"; + } + else + { + result = await Task.FromResult(SpecDbController.ListPODLFilt(lanciato, keyRichPart, idxMacchina, codGruppo, startDate, endDate)); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(redisShortTimeCache)); + } + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"POdlListGetFilt | Read from {readType}: {ts.TotalMilliseconds}ms"); + return result; } /// diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 4a96ee4e..b29f55cb 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -10,9 +10,11 @@ <_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS01.pubxml" /> <_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS02.pubxml" /> <_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS04.pubxml" /> + <_WebToolingArtifacts Remove="Properties\PublishProfiles\IISProfile.pubxml" /> + diff --git a/MP.IOC/Properties/PublishProfiles/IISProfile.pubxml b/MP.IOC/Properties/PublishProfiles/IISProfile.pubxml index c17755f0..d8fe1a06 100644 --- a/MP.IOC/Properties/PublishProfiles/IISProfile.pubxml +++ b/MP.IOC/Properties/PublishProfiles/IISProfile.pubxml @@ -12,9 +12,9 @@ by editing this MSBuild file. In order to learn more about this please visit htt True False d9901b50-e61c-400c-b62c-fa060cf72c29 - bin\publish\MP.SPEC.zip + bin\publish\MP.IOC.zip true - Default Web Site/MP/SPEC + Default Web Site/MP/IOC net6.0 false diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 83800b55..b9e37537 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2302.1609

+

Versione: 6.16.2304.416


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 3537d8b3..bef5cf35 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2302.1609 +6.16.2304.416 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 04385cb0..3ccb7490 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2302.1609 + 6.16.2304.416 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false diff --git a/MP.SPEC/Controllers/RecipeArchiveController.cs b/MP.SPEC/Controllers/RecipeArchiveController.cs index bacf8a06..79e8751e 100644 --- a/MP.SPEC/Controllers/RecipeArchiveController.cs +++ b/MP.SPEC/Controllers/RecipeArchiveController.cs @@ -1,12 +1,7 @@ using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using MP.Data.MgModels; using MP.SPEC.Data; -using Newtonsoft.Json; using NLog; -using System.Xml; namespace MP.SPEC.Controllers { @@ -15,10 +10,7 @@ namespace MP.SPEC.Controllers [AllowAnonymous] public class RecipeArchiveController : ControllerBase { - /// - /// Dataservice x accesso DB - /// - protected MpDataService DService { get; set; } + #region Public Constructors public RecipeArchiveController(IConfiguration configuration, MpDataService DataService) { @@ -26,27 +18,12 @@ namespace MP.SPEC.Controllers _configuration = configuration; DService = DataService; Log.Info("Avviata classe RecipeArchiveController"); - } - private static IConfiguration _configuration = null!; - private static Logger Log = LogManager.GetCurrentClassLogger(); + #endregion Public Constructors + + #region Public Methods - [HttpGet("GetFile")] - public async Task GetFile(string idxMacc, string fileName) - { - string answ = ""; - string archPath = await DService.MacchineRecipeArchive(idxMacc); - if (!string.IsNullOrEmpty(archPath)) - { - string fullPath = Path.Combine(archPath, fileName); - if (!string.IsNullOrEmpty(fullPath)) - { - answ = System.IO.File.ReadAllText(fullPath); - } - } - return answ; - } [HttpGet("GetByPODL")] public async Task GetByPODL(string idxMacc, int idxPODL) { @@ -65,5 +42,39 @@ namespace MP.SPEC.Controllers return answ; } + [HttpGet("GetFile")] + public async Task GetFile(string idxMacc, string fileName) + { + string answ = ""; + string archPath = await DService.MacchineRecipeArchive(idxMacc); + if (!string.IsNullOrEmpty(archPath)) + { + string fullPath = Path.Combine(archPath, fileName); + if (!string.IsNullOrEmpty(fullPath)) + { + answ = System.IO.File.ReadAllText(fullPath); + } + } + return answ; + } + + #endregion Public Methods + + #region Protected Properties + + /// + /// Dataservice x accesso DB + /// + protected MpDataService DService { get; set; } + + #endregion Protected Properties + + #region Private Fields + + private static IConfiguration _configuration = null!; + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields } -} +} \ No newline at end of file diff --git a/MP.SPEC/Controllers/RecipeController.cs b/MP.SPEC/Controllers/RecipeController.cs index 9d05d85d..680e1fff 100644 --- a/MP.SPEC/Controllers/RecipeController.cs +++ b/MP.SPEC/Controllers/RecipeController.cs @@ -1,8 +1,5 @@ using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; -using Microsoft.Extensions.Configuration; -using MP.Data.MgModels; using MP.SPEC.Data; using Newtonsoft.Json; using NLog; @@ -15,22 +12,19 @@ namespace MP.SPEC.Controllers [AllowAnonymous] public class RecipeController : ControllerBase { - /// - /// Dataservice x accesso DB - /// - protected MpDataService DService { get; set; } + #region Public Constructors public RecipeController(IConfiguration configuration, MpDataService DataService) { Log.Info("Starting RecipeController"); _configuration = configuration; DService = DataService; - Log.Info("Avviata classe Recipe"); - + Log.Info("Avviata classe RecipeController"); } - private static IConfiguration _configuration = null!; - private static Logger Log = LogManager.GetCurrentClassLogger(); + #endregion Public Constructors + + #region Public Methods [HttpGet("GetRecipe")] public async Task GetRecipe(int idxPODL) @@ -43,6 +37,7 @@ namespace MP.SPEC.Controllers } return answ; } + [HttpGet("GetRecipeXML")] public async Task GetRecipeXML(int idxPODL) { @@ -58,5 +53,24 @@ namespace MP.SPEC.Controllers } return answ; } + + #endregion Public Methods + + #region Protected Properties + + /// + /// Dataservice x accesso DB + /// + protected MpDataService DService { get; set; } + + #endregion Protected Properties + + #region Private Fields + + private static IConfiguration _configuration = null!; + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + #endregion Private Fields } -} +} \ No newline at end of file diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index bb2d440a..2c9984e2 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -1679,7 +1679,7 @@ namespace MP.SPEC.Data answ = await RedisFlushPatternAsync(pattern); pattern = new RedisValue($"{Utils.redisPOdlList}:*"); answ = await RedisFlushPatternAsync(pattern); - + return answ; }