Files
NKC/NKC_WF/Controllers/getMUCssController.cs
T
2019-09-16 18:18:39 +02:00

72 lines
1.8 KiB
C#

using SteamWare;
using System.IO;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;
namespace NKC_WF.Controllers
{
public class getMUCssController : ApiController
{
// GET api/<controller>
public HttpResponseMessage Get()
{
string answ = "";
// recupero da REDIS!
string redKey = memLayer.ML.redHash("MachineUnload:01:Css");
// se vuoto scrivo versione attuale...
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 (answ == "")
// se vuoto lo calcolo... !!!FIXME!!! leggere da DB!!!!
{
string filename = HttpContext.Current.Server.MapPath("~/Content/SheetColor.css");
answ = File.ReadAllText(filename);
// imposto sfondo ...
answ = answ.Replace("#BLK-BCK", "#Sheet");
// ...e primi 3 items...
answ = answ.Replace("#BLK-CUT", "#IT000006, #IT000007, #IT000008");
answ = answ.Replace("#BLK-SEL", "#IT000003");
answ = answ.Replace("#BLK-BIN", "#IT000001");
answ = answ.Replace("#BLK-CART", "#IT000002");
// salvo redis!
memLayer.ML.setRSV(redKey, answ);
}
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(answ, Encoding.UTF8, "text/css")
};
}
// GET api/<controller>/5
public string Get(int id)
{
return "value";
}
// 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)
{
}
}
}