Spostata ricerca ODL in minimal API

This commit is contained in:
Samuele Locatelli
2026-06-20 10:31:06 +02:00
parent 3ee34c0300
commit 7c8bca902f
6 changed files with 37 additions and 35 deletions
+2 -1
View File
@@ -483,6 +483,7 @@ namespace MP.IOC.Controllers
return Ok(actValues);
}
#if false
/// <summary>
/// Recupera ODL corrente x macchina:
/// GET: IOB/getCurrODL/SIMUL_03
@@ -507,6 +508,7 @@ namespace MP.IOC.Controllers
return StatusCode(StatusCodes.Status500InternalServerError, "NO");
}
}
#endif
/// <summary>
/// Restituisce la quantità pezzi dell'odl correntemente in lavorazione sulla macchina...
@@ -901,7 +903,6 @@ namespace MP.IOC.Controllers
Stopwatch sw = new Stopwatch();
sw.Start();
answ = await IOCService.ProcessInputAsync(id, valore, dtEve, dtCurr, cnt);
//answ = await DService.ProcessInputAsync(id, valore, dtEve, dtCurr, cnt);
sw.Stop();
Log.Debug($"Input | elapsed: {sw.Elapsed.TotalMilliseconds:N1} | id: {id} | val: {valore} | cnt: {cnt}");
return Ok(answ);
+31 -30
View File
@@ -34,8 +34,38 @@ namespace MP.IOC.Endpoints
}
});
// 3. Metodo: GetCurrODL (api/IOB/getCurrODL/{id})
app.MapGet("api/IOB/getCurrODL/{id}", async (string id, IIocService iocService, HttpContext context) =>
{
if (string.IsNullOrEmpty(id))
{
context.Response.StatusCode = StatusCodes.Status400BadRequest;
return "Missing ID";
}
if (id.Contains('|'))
{
id = id.Replace('|', '#');
}
try
{
var odl = await iocService.GetCurrOdlAsync(id);
// Ottimizzazione: Se 'odl' è già una stringa, ritornala direttamente.
// Se è un oggetto o un numero, il C# gestirà l'estrazione. Evitiamo $"{odl}" che alloca memoria inutilmente.
return odl?.ToString() ?? string.Empty;
}
catch (Exception exc)
{
Log.Error(exc, "Errore GetCurrODL | macchina {MachineId}", id);
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
return "NO";
}
});
#if false
// 3. Metodo: SetCounter (api/IOB/setCounter/{id}?counter=10)
// 4. Metodo: SetCounter (api/IOB/setCounter/{id}?counter=10)
// Nota: 'counter' viene letto automaticamente dalla Query String grazie al Model Binding automatico
app.MapGet("api/IOB/setCounter/{id}", async (string id, string counter, IIocService iocService, HttpContext context) =>
{
@@ -71,35 +101,6 @@ namespace MP.IOC.Endpoints
}
});
// 4. Metodo: GetCurrODL (api/IOB/getCurrODL/{id})
app.MapGet("api/IOB/getCurrODL/{id}", async (string id, IIocService iocService, HttpContext context) =>
{
if (string.IsNullOrEmpty(id))
{
context.Response.StatusCode = StatusCodes.Status400BadRequest;
return "Missing ID";
}
if (id.Contains('|'))
{
id = id.Replace('|', '#');
}
try
{
var odl = await iocService.GetCurrOdlAsync(id);
// Ottimizzazione: Se 'odl' è già una stringa, ritornala direttamente.
// Se è un oggetto o un numero, il C# gestirà l'estrazione. Evitiamo $"{odl}" che alloca memoria inutilmente.
return odl?.ToString() ?? string.Empty;
}
catch (Exception exc)
{
Log.Error(exc, "Errore GetCurrODL | macchina {MachineId}", id);
context.Response.StatusCode = StatusCodes.Status500InternalServerError;
return "NO";
}
});
#endif
}
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>8.16.2606.1511</Version>
<Version>8.16.2606.2010</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MP-IOC </i>
<h4>Versione: 8.16.2606.1511</h4>
<h4>Versione: 8.16.2606.2010</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
8.16.2606.1511
8.16.2606.2010
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>8.16.2606.1511</version>
<version>8.16.2606.2010</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>