diff --git a/MP-IO/Controllers/WebAPI/CacheFilter.cs b/MP-IO/Controllers/WebAPI/CacheFilter.cs
new file mode 100644
index 00000000..d1176ce1
--- /dev/null
+++ b/MP-IO/Controllers/WebAPI/CacheFilter.cs
@@ -0,0 +1,23 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http.Headers;
+using System.Web;
+using System.Web.Http.Filters;
+
+namespace MP_IO.Controllers.WebAPI
+{
+ public class CacheFilter : ActionFilterAttribute
+ {
+ public int TimeDuration { get; set; }
+ public override void OnActionExecuted(HttpActionExecutedContext actionExecutedContext)
+ {
+ actionExecutedContext.Response.Headers.CacheControl = new CacheControlHeaderValue
+ {
+ MaxAge = TimeSpan.FromSeconds(TimeDuration),
+ MustRevalidate = true,
+ Public = true
+ };
+ }
+ }
+}
\ No newline at end of file
diff --git a/MP-IO/Controllers/WebAPI/IOBController.cs b/MP-IO/Controllers/WebAPI/IOBController.cs
index 53aa3c8b..e9ddb9f9 100644
--- a/MP-IO/Controllers/WebAPI/IOBController.cs
+++ b/MP-IO/Controllers/WebAPI/IOBController.cs
@@ -1,4 +1,6 @@
-using System;
+using MapoDb;
+using SteamWare;
+using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
@@ -9,18 +11,63 @@ namespace MP_IO.Controllers.WebAPI
{
public class IOBController : ApiController
{
- // GET api/IOB
- //[ResponseCache(Duration = 10)]
+ ///
+ /// GET api/IOB
+ /// è un check alive del server
+ ///
+ ///
+ [CacheFilter(TimeDuration = 10)]
[HttpGet]
public string Get()
{
+ if (memLayer.ML.CRB("IOB_RedEnab"))
+ {
+ // conto la richiesta nel contatore REDIS
+ long nCall = memLayer.ML.setRCntI(DataLayer.mHash("COUNT:pCall:IOB_INDEX"));
+ //... se == nCall2Log scrivo su log e resetto
+ long nCall2Log = memLayer.ML.cdvi("nCall2Log");
+ if (nCall >= nCall2Log)
+ {
+ // loggo
+ logger.lg.scriviLog(string.Format("IOB_INDEX: effettuate {0} call", nCall), tipoLog.INFO);
+ // resetto!
+ memLayer.ML.resetRCnt(DataLayer.mHash("COUNT:pCall:IOB_INDEX"));
+ }
+ }
return "OK";
}
- // GET api//5
- public string Get(int id)
+ ///
+ /// GET api/IOB/SIMUL_03
+ /// Verifica stato enabled di un determinato IOB
+ ///
+ ///
+ ///
+ [CacheFilter(TimeDuration = 5)]
+ [HttpGet]
+ public string Get(string id)
{
- return "value";
+ string answ = "ND";
+ // se id nullo --> KO!
+ if (id == null)
+ {
+ answ = "KO";
+ }
+ else
+ {
+ try
+ {
+ DataLayer DataLayerObj = new DataLayer();
+ // salvo risposta!
+ answ = DataLayerObj.insEnab(id) ? "OK" : "NO";
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog(string.Format("Errore in enabled{0}{1}", Environment.NewLine, exc));
+ answ = "NO";
+ }
+ }
+ return answ;
}
// POST api/
diff --git a/MP-IO/MP-IO.csproj b/MP-IO/MP-IO.csproj
index 90a79765..8a5fab7a 100644
--- a/MP-IO/MP-IO.csproj
+++ b/MP-IO/MP-IO.csproj
@@ -275,6 +275,7 @@
+
default.aspx