114 lines
3.1 KiB
C#
114 lines
3.1 KiB
C#
using Microsoft.AspNetCore.Mvc;
|
|
using MP.Data.Conf;
|
|
using MP.Data.DatabaseModels;
|
|
using MP.WASM.Mon.Server.Data;
|
|
using Newtonsoft.Json;
|
|
using NLog;
|
|
|
|
namespace MP.WASM.Mon.Server.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/[controller]")]
|
|
public class MSEController : ControllerBase //, IDisposable
|
|
{
|
|
#region Public Constructors
|
|
|
|
/// <summary>
|
|
/// Avvio controller dei dati MSE
|
|
/// </summary>
|
|
/// <param name="DataService"></param>
|
|
public MSEController(MpDataService DataService)
|
|
{
|
|
_DataService = DataService;
|
|
Log.Trace("Avviata classe MSEController");
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Dizionario dei tag configurati per IOB
|
|
/// </summary>
|
|
public Dictionary<string, List<TagData>> currTagConf { get; set; } = new Dictionary<string, List<TagData>>();
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
[HttpGet("checkAlive")]
|
|
public Task<string> checkAlive()
|
|
{
|
|
Log.Trace("Check Alive");
|
|
//string answ = (DateTime.Now.Second % 3 == 0) ? "KO": "OK";
|
|
return Task.FromResult(JsonConvert.SerializeObject("OK"));
|
|
}
|
|
|
|
[HttpGet("getConfig")]
|
|
public Task<List<ConfigModel>> ConfigGetAll()
|
|
{
|
|
return _DataService.ConfigGetAll();
|
|
}
|
|
|
|
[HttpGet("getAllTagConf")]
|
|
public Task<Dictionary<string, List<TagData>>> getAllTags()
|
|
{
|
|
return _DataService.getAllTags();
|
|
}
|
|
|
|
/// <summary>
|
|
/// restituisce il valore da REDIS associato al tag richeisto
|
|
/// </summary>
|
|
/// <param name="redKey">Chiave in cui cercare il valore</param>
|
|
/// <returns></returns>
|
|
[HttpGet("getTagConf/{redKey}")]
|
|
public string getTagConf(string redKey)
|
|
{
|
|
return _DataService.getTagConf(redKey);
|
|
}
|
|
|
|
[HttpGet("getMachines")]
|
|
public Task<List<Macchine>> MacchineGetAll()
|
|
{
|
|
return _DataService.MacchineGetAll();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Metodo principale x ricevere tutte i dati MSE di tutti gli impianti
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
[HttpGet()]
|
|
public async Task<List<MappaStatoExpl>> MseGetAll()
|
|
{
|
|
return await _DataService.MseGetAll();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Dataservice x accesso DB
|
|
/// </summary>
|
|
protected MpDataService _DataService { get; set; }
|
|
|
|
#endregion Protected Properties
|
|
|
|
#if fase
|
|
/// <summary>
|
|
/// Dispone delle risorse quando non necessarie
|
|
/// </summary>
|
|
public void Dispose()
|
|
{
|
|
_DataService.Dispose();
|
|
Log.Trace("Dispose classe MSEController");
|
|
}
|
|
#endif
|
|
|
|
#region Private Fields
|
|
|
|
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |