using AppData; 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/getMUCssController public HttpResponseMessage Get() { string answ = ""; string codPost = "01"; answ = getCssByPost(answ, codPost); return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(answ, Encoding.UTF8, "text/css") }; } // GET api/getMUCssController/5 public HttpResponseMessage Get(int id) { string answ = ""; string codPost = id.ToString("00"); answ = getCssByPost(answ, codPost); return new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(answ, Encoding.UTF8, "text/css") }; } /// /// Calcola CSS da postsazione /// /// /// /// private static string getCssByPost(string answ, string codPost) { // recupero da REDIS! string redKey = $"{ComLib.machineUnloadArea(codPost)}:Css";// memLayer.ML.redHash($"MachineUnload:{codPost}: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 ... NON usato answ = answ.Replace("#BLK-BCK", "#Sheet"); // All'inizio --> tutti colorati secondo destinazione (cart, bin, secop) // eventualmente sec-op è SECONDO css aggiuntivo opzionale x indicare tratteggiato e/o tratteggiato + flashing... // ...e primi 3 items... answ = answ.Replace("#BLK-CUT", "#IT00008594, #IT000085AC, #IT000085AD, #IT000085AE"); answ = answ.Replace("#BLK-SEC-OP", "#IT000085AF"); answ = answ.Replace("#BLK-SEL", "#IT000085C2"); answ = answ.Replace("#BLK-BIN", "#IT000085BE"); answ = answ.Replace("#BLK-CART", "#IT000085AB"); //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! int cssCacheTTL = memLayer.ML.cdvi("cssCacheTTL"); cssCacheTTL = cssCacheTTL <= 0 ? 60: cssCacheTTL; memLayer.ML.setRSV(redKey, answ, cssCacheTTL); } return answ; } // POST api/ public void Post([FromBody]string value) { } // PUT api//5 public void Put(int id, [FromBody]string value) { } // DELETE api//5 public void Delete(int id) { } } }