cancellazione file inutilizzati x WebAPI (abbozzata)
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
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
|
||||
{
|
||||
/// <summary>
|
||||
/// Gestione cache x chaimate WebAPI
|
||||
///
|
||||
/// rif: https://www.c-sharpcorner.com/article/implementing-caching-in-web-api/
|
||||
/// </summary>
|
||||
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
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
using MapoDb;
|
||||
using SteamWare;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace MP_IO.Controllers.WebAPI
|
||||
{
|
||||
public class IOBController : ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// GET api/IOB
|
||||
/// è un check alive del server
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[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";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// GET api/IOB/SIMUL_03
|
||||
/// Verifica stato enabled di un determinato IOB
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
[CacheFilter(TimeDuration = 5)]
|
||||
[HttpGet]
|
||||
public string Get(string id)
|
||||
{
|
||||
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/<controller>
|
||||
public void Post([FromBody]string value)
|
||||
{
|
||||
}
|
||||
|
||||
// PUT api/<controller>/5
|
||||
public void Put(int id, [FromBody]string value)
|
||||
{
|
||||
}
|
||||
|
||||
// DELETE api/<controller>/5
|
||||
public void Delete(int id)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -416,7 +416,6 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Controllers\WebAPI\" />
|
||||
<Folder Include="Resources\Jetco\" />
|
||||
<Folder Include="Views\Home\" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user