Completo metodi attuali!!!
This commit is contained in:
@@ -55,6 +55,24 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce l'anagrafica STATI per intero
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagStatiModel>> AnagStatiGetAllAsync()
|
||||
{
|
||||
List<AnagStatiModel> dbResult = new List<AnagStatiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetAnagStati
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restitusice elenco ultimi articoli per macchina
|
||||
/// </summary>
|
||||
@@ -77,22 +95,6 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Restituisce l'anagrafica STATI per intero
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagStatiModel>> AnagStatiGetAllAsync()
|
||||
{
|
||||
List<AnagStatiModel> dbResult = new List<AnagStatiModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = await dbCtx
|
||||
.DbSetAnagStati
|
||||
.AsNoTracking()
|
||||
.ToListAsync();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Record ConfFlux dato macchina (oppure tutti se vuoto)
|
||||
@@ -527,6 +529,31 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco valori ammessi x tabella/colonna con filtro parametrico
|
||||
/// </summary>
|
||||
/// <param name="tabName">Filtro tabella (se "" tutto)</param>
|
||||
/// <param name="fieldName">Filtro colonna (se "" tutto)</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ListValuesModel>> ListValuesFilt(string tabName, string fieldName)
|
||||
{
|
||||
List<ListValuesModel> dbResult = new List<ListValuesModel>();
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intera tabella relazione master/slave in machine (gestione setup master --> slave)
|
||||
/// </summary>
|
||||
|
||||
+165
-108
@@ -564,7 +564,6 @@ namespace MP.IOC.Controllers
|
||||
return Ok(answ);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Recupera elenco articoli USATI per ultimi:
|
||||
/// - quelli dei PODL correnti
|
||||
@@ -593,6 +592,7 @@ namespace MP.IOC.Controllers
|
||||
}
|
||||
return Ok(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera DATI dell'ultimo dossier dato articolo:
|
||||
///
|
||||
@@ -622,6 +622,34 @@ namespace MP.IOC.Controllers
|
||||
return Ok(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera elenco ListValues data tabella: ///
|
||||
/// GET: IOB/getListValByTable
|
||||
/// </summary>
|
||||
/// <param name="id">nome tabella x cui filtrare risultati, se "" mostra tutto</param>
|
||||
/// <returns>Json contenente lista oggetti ListValue serializzati</returns>
|
||||
[HttpGet("getListValByTable/{id}")]
|
||||
public async Task<IActionResult> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di
|
||||
/// oggetti objItem
|
||||
/// GET: IOB/getObjItems2Write/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id">ID dell'IOB</param>
|
||||
/// <returns></returns>
|
||||
|
||||
[HttpGet("getObjItems2Write/{id}")]
|
||||
public async Task<IActionResult> GetObjItems2Write(string id)
|
||||
{
|
||||
@@ -697,105 +717,6 @@ namespace MP.IOC.Controllers
|
||||
return Ok(answ);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Recupera DATI PODL NEXT (=NON AVVIATI) x macchina: (copia di getCurrPODL)
|
||||
///
|
||||
/// GET: IOB/getPOdlNext/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id">id macchina, se "" mostra tutto</param>
|
||||
/// <returns>Json contenente lista oggetti PODL serializzati</returns>
|
||||
|
||||
[HttpGet("getPOdlNext/{id}")]
|
||||
public async Task<IActionResult> 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
|
||||
/// <summary>
|
||||
/// Recupera DATI PODL x macchina e codice PODL:
|
||||
///
|
||||
/// GET: IOB/getPODL/SIMUL_03?idxPODL=123
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="idxPODL">idx del PDL da avviare</param>
|
||||
/// <returns>Json contenente lista oggetti PODL serializzati</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera DATI PODL Running/Actual (AVVIATO e in corso) x macchina:
|
||||
///
|
||||
/// GET: IOB/getPOdlAct/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id">id macchina, se "" mostra tutto</param>
|
||||
/// <returns>Json contenente lista 1 oggetto PODL serializzato, se presente</returns>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// 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<IActionResult> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera TASK richiesto x macchina:
|
||||
/// GET: IOB/getTask2Exe/SIMUL_03
|
||||
@@ -1276,6 +1219,120 @@ namespace MP.IOC.Controllers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Processa una chiamata POST per l'invio di una List Json di oggetti objItem
|
||||
/// POST: IOB/setObjItems/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id">ID dell'IOB</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost("setObjItems/{id}")]
|
||||
public async Task<IActionResult> SetObjItems(string id, [FromBody] List<ObjItemDTO> 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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di
|
||||
/// oggetti objItem
|
||||
/// GET: IOB/getObjItems2Write/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id">ID dell'IOB</param>
|
||||
/// <returns></returns>
|
||||
/// <summary>
|
||||
/// Recupera DATI PODL NEXT (=NON AVVIATI) x macchina: (copia di getCurrPODL)
|
||||
///
|
||||
/// GET: IOB/getPOdlNext/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id">id macchina, se "" mostra tutto</param>
|
||||
/// <returns>Json contenente lista oggetti PODL serializzati</returns>
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupera DATI PODL x macchina e codice PODL:
|
||||
///
|
||||
/// GET: IOB/getPODL/SIMUL_03?idxPODL=123
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <param name="idxPODL">idx del PDL da avviare</param>
|
||||
/// <returns>Json contenente lista oggetti PODL serializzati</returns>
|
||||
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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera DATI PODL Running/Actual (AVVIATO e in corso) x macchina:
|
||||
///
|
||||
/// GET: IOB/getPOdlAct/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id">id macchina, se "" mostra tutto</param>
|
||||
/// <returns>Json contenente lista 1 oggetto PODL serializzato, se presente</returns>
|
||||
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
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
|
||||
@@ -4171,6 +4171,32 @@ namespace MP.IOC.Data
|
||||
return resultList;
|
||||
}
|
||||
|
||||
public async Task<List<ListValuesModel>> ListValuesFilt(string tabName, string fieldName)
|
||||
{
|
||||
List<ListValuesModel> resultList = new List<ListValuesModel>();
|
||||
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<List<ListValuesModel>>($"{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;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Svuota la cache redis x l'elenco delle righe di confFlux x una macchina (se presenti)
|
||||
/// </summary>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Version>6.16.2604.1611</Version>
|
||||
<Version>6.16.2604.1612</Version>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MP-IOC </i>
|
||||
<h4>Versione: 6.16.2604.1611</h4>
|
||||
<h4>Versione: 6.16.2604.1612</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2604.1611
|
||||
6.16.2604.1612
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2604.1611</version>
|
||||
<version>6.16.2604.1612</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
Reference in New Issue
Block a user