using AppData;
using SteamWare;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web.Http;
namespace NKC_WF.Controllers
{
public class getMUCssController : ApiController
{
// GET api/getMUCssController
public HttpResponseMessage Get()
{
string answ = getCssByPost(0);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(answ, Encoding.UTF8, "text/css")
};
}
// GET api/getMUCssController/5
public HttpResponseMessage Get(int id)
{
string answ = getCssByPost(id);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(answ, Encoding.UTF8, "text/css")
};
}
///
/// Calcola CSS da postsazione
///
///
///
///
private static string getCssByPost(int sheetID)
{
// var base
string answ = "";
if (sheetID > 0)
{
// recupero da REDIS!
string redKey = $"{ComLib.machineUnloadArea(sheetID)}:Css";
// se vuoto scrivo VUOTO...
if (!memLayer.ML.redKeyPresent(redKey))
{
memLayer.ML.setRSV(redKey, answ);
}
answ = memLayer.ML.getRSV(redKey);
// RICALCOLO SOLO SE non trovo in REDIS (perché invalidato)
if (string.IsNullOrEmpty(answ))
// se vuoto lo calcolo...
{
answ = ComLib.getCurrentCss(sheetID);
}
}
// restituisco css
return answ;
}
}
}