Fix preliminare metodi getTC
This commit is contained in:
@@ -23,19 +23,17 @@ namespace MP.IOC.Controllers
|
||||
#region Public Methods
|
||||
|
||||
/// <summary> SALVA x macchina KVP parametro/valore:
|
||||
///
|
||||
/// GET: api/IOB/addOptPar/SIMUL_03?pName=PZREQ&pValue=1000
|
||||
///
|
||||
/// </summary> <param name="id"></param> <param name="pName"></param> <param name="pValue"></param>
|
||||
[HttpGet("addOptPar/{id}")]
|
||||
public string addOptPar(string id, string pName, string pValue)
|
||||
public string AddOptPar(string id, string pName, string pValue)
|
||||
{
|
||||
string answ = "";
|
||||
DService.ScriviKeepAlive(id, DateTime.Now);
|
||||
try
|
||||
{
|
||||
DService.AddOptPar4Machine(id, pName, pValue);
|
||||
answ = getOptPar(id);
|
||||
answ = GetOptPar(id);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
@@ -58,7 +56,7 @@ namespace MP.IOC.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("enabled/{id}")]
|
||||
public IActionResult enabled(string id)
|
||||
public IActionResult Enabled(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID");
|
||||
|
||||
@@ -68,8 +66,8 @@ namespace MP.IOC.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
return UnprocessableEntity("NO"); // O un altro errore appropriato
|
||||
//return StatusCode(503, "NO"); // O un altro errore appropriato
|
||||
//return StatusCode(503, "NO");
|
||||
return UnprocessableEntity("NO");
|
||||
}
|
||||
#if false
|
||||
if (string.IsNullOrEmpty(id)) return Ok("KO");
|
||||
@@ -88,6 +86,114 @@ namespace MP.IOC.Controllers
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera COUNTER x macchina:
|
||||
/// GET: IOB/getCounter/SIMUL_03
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Il conteggio pezzi o un errore strutturato</returns>
|
||||
[HttpGet("getCounter/{id}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(int))]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetCounter(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID");
|
||||
|
||||
try
|
||||
{
|
||||
var pzCount = await DService.pzCounter(id);
|
||||
return Ok(pzCount);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error(exc, "Errore durante il recupero del counter per la macchina {MachineId}", id);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "Errore interno | GetCounter");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera COUNTER x macchina dal CONTEGGIO dei TCRecorded:
|
||||
///
|
||||
/// GET: IOB/getCounterTCRec/5
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Il conteggio pezzi o un errore strutturato</returns>
|
||||
[HttpGet("getCounterTCRec/{id}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(int))]
|
||||
[ProducesResponseType(StatusCodes.Status400BadRequest)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<IActionResult> GetCounterTCRec(string id)
|
||||
{
|
||||
if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID");
|
||||
|
||||
// attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
|
||||
// carattere "|" che poi trasformiamo ora in "#"
|
||||
id = id.Replace("|", "#");
|
||||
try
|
||||
{
|
||||
var pzCount = await DService.pzCounterTC(id);
|
||||
return Ok(pzCount);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error(exc, "Errore durante il recupero del counter TC per la macchina {MachineId}", id);
|
||||
return StatusCode(StatusCodes.Status500InternalServerError, "Errore interno | GetCounterTCRec");
|
||||
}
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Recupera COUNTER x macchina:
|
||||
///
|
||||
/// GET: IOB/getCounter/5
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getCounter/{id}")]
|
||||
public async Task<string> getCounter(string id)
|
||||
{
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
var pzCount = await _tabDService.pzCounter(id);
|
||||
answ = $"{pzCount}";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in counter TC (get){Environment.NewLine}{exc}");
|
||||
answ = "NO";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Recupera COUNTER x macchina dal CONTEGGIO dei TCRecorded:
|
||||
///
|
||||
/// GET: IOB/getCounterTCRec/5
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[HttpGet("getCounterTCRec/{id}")]
|
||||
public async Task<string> getCounterTCRec(string id)
|
||||
{
|
||||
// attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
|
||||
// carattere "|" che poi trasformiamo ora in "#"
|
||||
id = id.Replace("|", "#");
|
||||
string answ = "";
|
||||
try
|
||||
{
|
||||
var pzCountTC = await _tabDService.pzCounterTC(id);
|
||||
answ = $"{pzCountTC}";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in counter TC (get){Environment.NewLine}{exc}");
|
||||
answ = "NO";
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Recupera TASK richiesto x macchina:
|
||||
///
|
||||
@@ -96,7 +202,7 @@ namespace MP.IOC.Controllers
|
||||
/// <param name="id"></param>
|
||||
/// <returns>Json contenente 1..n task da eseguire</returns>
|
||||
[HttpGet("getOptPar/{id}")]
|
||||
public string getOptPar(string id)
|
||||
public string GetOptPar(string id)
|
||||
{
|
||||
string answ = "";
|
||||
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
|
||||
@@ -113,7 +219,7 @@ namespace MP.IOC.Controllers
|
||||
}
|
||||
|
||||
[HttpGet("version")]
|
||||
public IActionResult version()
|
||||
public IActionResult Version()
|
||||
{
|
||||
var version = Assembly
|
||||
.GetExecutingAssembly()
|
||||
@@ -126,15 +232,6 @@ namespace MP.IOC.Controllers
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
protected MpDataService DService { get; set; }
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
@@ -143,6 +240,15 @@ namespace MP.IOC.Controllers
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Properties
|
||||
|
||||
/// <summary>
|
||||
/// Dataservice x accesso DB
|
||||
/// </summary>
|
||||
private MpDataService DService { get; set; }
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
///// <summary> AGGIUNGE TASK richiesto x macchina:
|
||||
/////
|
||||
///// GET: IOB/addTask2Exe/3010?taskName=startSetup&taskVal=T190406101512
|
||||
@@ -706,52 +812,6 @@ namespace MP.IOC.Controllers
|
||||
// return answ;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Recupera COUNTER x macchina:
|
||||
/////
|
||||
///// GET: IOB/getCounter/5
|
||||
///// </summary>
|
||||
///// <param name="id"></param>
|
||||
///// <returns></returns>
|
||||
//public string getCounter(string id)
|
||||
//{
|
||||
// string answ = "";
|
||||
// try
|
||||
// {
|
||||
// DataLayer DataLayerObj = new DataLayer();
|
||||
// answ = DataLayerObj.pzCounter(id).ToString();
|
||||
// }
|
||||
// catch (Exception exc)
|
||||
// {
|
||||
// logger.lg.scriviLog(string.Format("Errore in counter (get){0}{1}", Destination.NewLine, exc));
|
||||
// answ = "NO";
|
||||
// }
|
||||
// return answ;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Recupera COUNTER x macchina dal CONTEGGIO dei TCRecorded:
|
||||
/////
|
||||
///// GET: IOB/getCounterTCRec/5
|
||||
///// </summary>
|
||||
///// <param name="id"></param>
|
||||
///// <returns></returns>
|
||||
//public string getCounterTCRec(string id)
|
||||
//{
|
||||
// string answ = "";
|
||||
// try
|
||||
// {
|
||||
// DataLayer DataLayerObj = new DataLayer();
|
||||
// answ = DataLayerObj.pzCounterTC(id).ToString();
|
||||
// }
|
||||
// catch (Exception exc)
|
||||
// {
|
||||
// logger.lg.scriviLog(string.Format("Errore in counter TC (get){0}{1}", Destination.NewLine, exc));
|
||||
// answ = "NO";
|
||||
// }
|
||||
// return answ;
|
||||
//}
|
||||
|
||||
///// <summary>
|
||||
///// Recupera DATI correnti x macchina:
|
||||
/////
|
||||
|
||||
Reference in New Issue
Block a user