diff --git a/MP.Data/Controllers/MpIocController.cs b/MP.Data/Controllers/MpIocController.cs index 872e3880..2ad11b1d 100644 --- a/MP.Data/Controllers/MpIocController.cs +++ b/MP.Data/Controllers/MpIocController.cs @@ -55,6 +55,24 @@ namespace MP.Data.Controllers } return fatto; } + + /// + /// Restituisce l'anagrafica STATI per intero + /// + /// + public async Task> AnagStatiGetAllAsync() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = await dbCtx + .DbSetAnagStati + .AsNoTracking() + .ToListAsync(); + } + return dbResult; + } + /// /// Restitusice elenco ultimi articoli per macchina /// @@ -77,22 +95,6 @@ namespace MP.Data.Controllers } return dbResult; } - /// - /// Restituisce l'anagrafica STATI per intero - /// - /// - public async Task> AnagStatiGetAllAsync() - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = await dbCtx - .DbSetAnagStati - .AsNoTracking() - .ToListAsync(); - } - return dbResult; - } /// /// Record ConfFlux dato macchina (oppure tutti se vuoto) @@ -527,6 +529,31 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco valori ammessi x tabella/colonna con filtro parametrico + /// + /// Filtro tabella (se "" tutto) + /// Filtro colonna (se "" tutto) + /// + public async Task> ListValuesFilt(string tabName, string fieldName) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var query = dbCtx.DbSetListValues + .AsNoTracking() + .AsQueryable(); + + if (!string.IsNullOrEmpty(tabName)) + query = query.Where(x => x.TableName == tabName); + if (!string.IsNullOrEmpty(fieldName)) + query = query.Where(x => x.FieldName == fieldName); + + dbResult = await query.ToListAsync(); + } + return dbResult; + } + /// /// Intera tabella relazione master/slave in machine (gestione setup master --> slave) /// diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index ea56e9c2..1c58ef23 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -564,7 +564,6 @@ namespace MP.IOC.Controllers return Ok(answ); } - /// /// Recupera elenco articoli USATI per ultimi: /// - quelli dei PODL correnti @@ -593,6 +592,7 @@ namespace MP.IOC.Controllers } return Ok(answ); } + /// /// Recupera DATI dell'ultimo dossier dato articolo: /// @@ -622,6 +622,34 @@ namespace MP.IOC.Controllers return Ok(answ); } + /// + /// Recupera elenco ListValues data tabella: /// + /// GET: IOB/getListValByTable + /// + /// nome tabella x cui filtrare risultati, se "" mostra tutto + /// Json contenente lista oggetti ListValue serializzati + [HttpGet("getListValByTable/{id}")] + public async Task GetListValByTable(string id) + { + if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + // Multi: gestione carattere "|" trasformato in "#" + id = id.Replace("|", "#"); + + string answ = ""; + try + { + // recupero dati macchina... + var elencoOdl = DService.ListValuesFilt(id, ""); + answ = JsonConvert.SerializeObject(elencoOdl); + } + catch (Exception exc) + { + Log.Error($"Errore in GetListValByTable{Environment.NewLine}{exc}"); + return StatusCode(StatusCodes.Status500InternalServerError, "NO"); + } + return Ok(answ); + } + /// /// restituisce elenco parametri correnti come una List Json di oggetti objItem /// GET: IOB/getObjItems/SIMUL_03 @@ -660,14 +688,6 @@ namespace MP.IOC.Controllers return Ok(answ); } - /// - /// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di - /// oggetti objItem - /// GET: IOB/getObjItems2Write/SIMUL_03 - /// - /// ID dell'IOB - /// - [HttpGet("getObjItems2Write/{id}")] public async Task GetObjItems2Write(string id) { @@ -697,105 +717,6 @@ namespace MP.IOC.Controllers return Ok(answ); } - - /// - /// Recupera DATI PODL NEXT (=NON AVVIATI) x macchina: (copia di getCurrPODL) - /// - /// GET: IOB/getPOdlNext/SIMUL_03 - /// - /// id macchina, se "" mostra tutto - /// Json contenente lista oggetti PODL serializzati - - [HttpGet("getPOdlNext/{id}")] - public async Task GetPOdlNext(string id) - { - - if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); - // Multi: gestione carattere "|" trasformato in "#" - id = id.Replace("|", "#"); - - string answ = ""; - try - { - // recupero dati macchina... - var elencoOdl = await DService.POdlGetByMaccArtAsync(id, "", "", true); - answ = JsonConvert.SerializeObject(elencoOdl); - } - catch (Exception exc) - { - Log.Error($"Errore in GetPOdlNext{Environment.NewLine}{exc}"); - return StatusCode(StatusCodes.Status500InternalServerError, "NO"); - } - return Ok(answ); - } - -#if false - /// - /// Recupera DATI PODL x macchina e codice PODL: - /// - /// GET: IOB/getPODL/SIMUL_03?idxPODL=123 - /// - /// - /// idx del PDL da avviare - /// Json contenente lista oggetti PODL serializzati - public string getPODL(string id, int idxPODL) - { - // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il - // carattere "|" che poi trasformiamo ora in "#" - if (!string.IsNullOrEmpty(id)) - { - id = id.Replace("|", "#"); - } - string answ = ""; - - // init obj DataLayer - DataLayer DataLayerObj = new DataLayer(); - try - { - // recupero dati da chaive, ignorando info macchina... - var elencoOdl = DataLayerObj.taPODL.getByKey(idxPODL); - answ = JsonConvert.SerializeObject(elencoOdl); - } - catch - { } - return answ; - } - - /// - /// Recupera DATI PODL Running/Actual (AVVIATO e in corso) x macchina: - /// - /// GET: IOB/getPOdlAct/SIMUL_03 - /// - /// id macchina, se "" mostra tutto - /// Json contenente lista 1 oggetto PODL serializzato, se presente - public string getPOdlAct(string id) - { - // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il - // carattere "|" che poi trasformiamo ora in "#" - if (!string.IsNullOrEmpty(id)) - { - id = id.Replace("|", "#"); - } - string answ = ""; - - // init obj DataLayer - DataLayer DataLayerObj = new DataLayer(); - try - { - // recupero IdxOdl corrente - string sIdxOdl = DataLayerObj.currODL(id); - int IdxOdl = 0; - int.TryParse(sIdxOdl, out IdxOdl); - // recupero Podl running x macchina ... - DS_ProdTempi.PromesseODLDataTable elencoOdl = DataLayerObj.taPODL.getByIdxOdl(IdxOdl); - answ = JsonConvert.SerializeObject(elencoOdl); - } - catch - { } - return answ; - } -#endif - /// /// Recupera TASK richiesto x macchina: /// GET: IOB/getOptPar/SIMUL_03 @@ -823,6 +744,28 @@ namespace MP.IOC.Controllers return Ok(answ); } + [HttpGet("getPOdlNext/{id}")] + public async Task GetPOdlNext(string id) + { + if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + // Multi: gestione carattere "|" trasformato in "#" + id = id.Replace("|", "#"); + + string answ = ""; + try + { + // recupero dati macchina... + var elencoOdl = await DService.POdlGetByMaccArtAsync(id, "", "", true); + answ = JsonConvert.SerializeObject(elencoOdl); + } + catch (Exception exc) + { + Log.Error($"Errore in GetPOdlNext{Environment.NewLine}{exc}"); + return StatusCode(StatusCodes.Status500InternalServerError, "NO"); + } + return Ok(answ); + } + /// /// Recupera TASK richiesto x macchina: /// GET: IOB/getTask2Exe/SIMUL_03 @@ -1276,6 +1219,120 @@ namespace MP.IOC.Controllers } } + /// + /// Processa una chiamata POST per l'invio di una List Json di oggetti objItem + /// POST: IOB/setObjItems/SIMUL_03 + /// + /// ID dell'IOB + /// + [HttpPost("setObjItems/{id}")] + public async Task SetObjItems(string id, [FromBody] List currParams) + { + if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + + // Multi: gestione carattere "|" trasformato in "#" + id = id.Replace("|", "#"); + + string answ = ""; + + try + { + // se != null --> salvo! + if (currParams != null) + { + bool fatto = await DService.MachineParamListSetAsync(id, currParams); + answ = fatto ? "OK" : "KO"; + } + } + catch (Exception exc) + { + Log.Error($"Errore in GetObjItems2Write{Environment.NewLine}{exc}"); + return StatusCode(StatusCodes.Status500InternalServerError, "NO"); + } + return Ok(answ); + } + + /// + /// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di + /// oggetti objItem + /// GET: IOB/getObjItems2Write/SIMUL_03 + /// + /// ID dell'IOB + /// + /// + /// Recupera DATI PODL NEXT (=NON AVVIATI) x macchina: (copia di getCurrPODL) + /// + /// GET: IOB/getPOdlNext/SIMUL_03 + /// + /// id macchina, se "" mostra tutto + /// Json contenente lista oggetti PODL serializzati +#if false + /// + /// Recupera DATI PODL x macchina e codice PODL: + /// + /// GET: IOB/getPODL/SIMUL_03?idxPODL=123 + /// + /// + /// idx del PDL da avviare + /// Json contenente lista oggetti PODL serializzati + public string getPODL(string id, int idxPODL) + { + // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il + // carattere "|" che poi trasformiamo ora in "#" + if (!string.IsNullOrEmpty(id)) + { + id = id.Replace("|", "#"); + } + string answ = ""; + + // init obj DataLayer + DataLayer DataLayerObj = new DataLayer(); + try + { + // recupero dati da chaive, ignorando info macchina... + var elencoOdl = DataLayerObj.taPODL.getByKey(idxPODL); + answ = JsonConvert.SerializeObject(elencoOdl); + } + catch + { } + return answ; + } + + /// + /// Recupera DATI PODL Running/Actual (AVVIATO e in corso) x macchina: + /// + /// GET: IOB/getPOdlAct/SIMUL_03 + /// + /// id macchina, se "" mostra tutto + /// Json contenente lista 1 oggetto PODL serializzato, se presente + public string getPOdlAct(string id) + { + // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il + // carattere "|" che poi trasformiamo ora in "#" + if (!string.IsNullOrEmpty(id)) + { + id = id.Replace("|", "#"); + } + string answ = ""; + + // init obj DataLayer + DataLayer DataLayerObj = new DataLayer(); + try + { + // recupero IdxOdl corrente + string sIdxOdl = DataLayerObj.currODL(id); + int IdxOdl = 0; + int.TryParse(sIdxOdl, out IdxOdl); + // recupero Podl running x macchina ... + DS_ProdTempi.PromesseODLDataTable elencoOdl = DataLayerObj.taPODL.getByIdxOdl(IdxOdl); + answ = JsonConvert.SerializeObject(elencoOdl); + } + catch + { } + return answ; + } +#endif + /// /// Processa una chiamata GET x salvare UserLog /// GET: IOB/ulog/SIMUL_03?flux=PROG&valore=P0001&dtEve=20161223180600000&dtCurr=20161223180600000&cnt=999&matrOpr=0=0&label=&valNum diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs index 3338a6a5..434495af 100644 --- a/MP.IOC/Data/MpDataService.cs +++ b/MP.IOC/Data/MpDataService.cs @@ -4171,6 +4171,32 @@ namespace MP.IOC.Data return resultList; } + public async Task> ListValuesFilt(string tabName, string fieldName) + { + List resultList = new List(); + string tag = ""; + tag += string.IsNullOrEmpty(tabName) ? "" : $"{tabName}:"; + tag += string.IsNullOrEmpty(fieldName) ? "" : $"{fieldName}:"; + var currKey = $"{Utils.redisConfFlux}:{tag}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + resultList = JsonConvert.DeserializeObject>($"{rawData}") ?? new(); + } + else + { + resultList = await IocDbController.ListValuesFilt(tabName, fieldName); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(resultList); + await redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (resultList == null) + { + resultList = new(); + } + return resultList; + } + /// /// Svuota la cache redis x l'elenco delle righe di confFlux x una macchina (se presenti) /// diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index e0835f13..c8fcf7b9 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 6.16.2604.1611 + 6.16.2604.1612 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index ec3380ca..b3ccad27 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2604.1611

+

Versione: 6.16.2604.1612


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index e97957d1..c468233b 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2604.1611 +6.16.2604.1612 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index d75fd07c..025c377c 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2604.1611 + 6.16.2604.1612 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false