diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs
index eb7fda2..409bd96 100644
--- a/AppData/ComLib.cs
+++ b/AppData/ComLib.cs
@@ -5,6 +5,8 @@ using NKC_SDK;
using SteamWare;
using System;
using System.Collections.Generic;
+using System.IO;
+using System.Web;
namespace AppData
{
@@ -1425,25 +1427,36 @@ namespace AppData
#region metodi x UNLOAD
///
- /// Calcola area REDIS per postsaizone Unload
+ /// Calcola area REDIS per FOGLIO in fase di scarico
///
- ///
+ ///
///
- public static string machineUnloadArea(string codPost)
+ public static string machineUnloadArea(int SheetID)
{
- return memLayer.ML.redHash($"MachineUnload:{codPost}");
+ // se 0 --> tutto l'albero, sennĂ² solo area corrente...
+ string answ = "";
+ if (SheetID > 0)
+ {
+ answ = memLayer.ML.redHash($"MachineUnload:{SheetID}");
+ }
+ else
+ {
+ answ = memLayer.ML.redHash($"MachineUnload");
+ }
+ return answ;
}
///
/// Svuota elenco pezzi nella postazione di unload
///
+ ///
///
- public bool resetPostUnload(string codPost = "01")
+ public bool resetPostUnload(int SheetID = 0)
{
bool answ = false;
try
{
- memLayer.ML.redFlushKey(machineUnloadArea(codPost));
+ memLayer.ML.redFlushKey(machineUnloadArea(SheetID));
answ = true;
}
catch
@@ -1451,27 +1464,135 @@ namespace AppData
return answ;
}
///
- /// Fa setup postsazione scarico (lettura da DB dell'elenco pezzi con relativo stato)
+ ///
///
+ ///
///
- public bool setupPostUnload(string codPost = "01")
+ public static string getCurrentCss(int sheetID)
{
- bool answ = false;
- try
- {
- // svuoto...
- resetPostUnload(codPost);
- // ri-carico da DB
+ // recupero da REDIS!
+ string redKey = $"{ComLib.machineUnloadArea(sheetID)}:Css";
+ string redKeyBase = $"{ComLib.machineUnloadArea(sheetID)}";
+ // TTL standard
+ int dataCacheTTL = memLayer.ML.cdvi("cssCacheTTL");
+ dataCacheTTL = dataCacheTTL <= 0 ? 60 : dataCacheTTL;
+ // files
+ string filename = HttpContext.Current.Server.MapPath("~/Content/SheetColor.css");
+ string answ = File.ReadAllText(filename);
- // salvo su area REDIS
- answ = true;
+ // elenco items da foglio!!!
+ var tabItems = DataLayer.man.taIL.getBySheet(sheetID);
+ List itemsAll = new List();
+ List itemsDepo = new List();
+ List itemsCart = new List();
+ List itemsBin = new List();
+ List itemsSecOp = new List();
+
+ //se ho items...
+ if (tabItems.Count > 0)
+ {
+ // ciclo!
+ foreach (var item in tabItems)
+ {
+ // aggiungoncomunque a lista generale...
+ itemsAll.Add(item.ItemDtmx);
+ // controllo SE sia stato depositato... check null su campo data
+ if (!item.IsOnCartDateNull())
+ {
+ itemsDepo.Add(item.ItemDtmx);
+ }
+ else if (item.ProcessesReq.Contains("PaintFlag"))
+ {
+ itemsBin.Add(item.ItemDtmx);
+ }
+ else
+ {
+ itemsCart.Add(item.ItemDtmx);
+ }
+ // controllo ANCHE postprocessing
+ if (item.PostProcList != "")
+ {
+ itemsSecOp.Add(item.ItemDtmx);
+ }
+ }
}
- catch
- { }
+
+
+ // FIX BIN
+ answ = ComLib.saveItemData(answ, redKeyBase, "ItemsBin", itemsBin, dataCacheTTL);
+
+ // FIX CART
+ answ = ComLib.saveItemData(answ, redKeyBase, "ItemsCart", itemsCart, dataCacheTTL);
+
+ // FIX Scaricati
+ answ = ComLib.saveItemData(answ, redKeyBase, "ItemsDepo", itemsDepo, dataCacheTTL);
+
+ // FIX SEC-OP
+ answ = ComLib.saveItemData(answ, redKeyBase, "ItemsSecOp", itemsSecOp, dataCacheTTL);
+
+ // FIXED SEL da array oggetti selezionati...
+ string rawData = memLayer.ML.getRSV($"{redKeyBase}:ItemsSel");
+ if (!string.IsNullOrEmpty(rawData))
+ {
+ string replaceVal = "";
+ // deserializzo
+ List selArray = JsonConvert.DeserializeObject>(rawData);
+
+ // ciclo x cercare x ogni chiave (sessione utente)
+ foreach (var item in selArray)
+ {
+ replaceVal += $"#{item},";
+ }
+ if (replaceVal.Length > 1)
+ {
+ replaceVal = replaceVal.Remove(replaceVal.Length - 1);
+ }
+ // FIX CSS!
+ answ = answ.Replace("#ItemsSel", replaceVal);
+ replaceVal = "";
+ }
+
+ // INFINE serializzo e salvo tutti gli items trovati...
+ string serVal = JsonConvert.SerializeObject(itemsAll);
+ memLayer.ML.setRSV($"{redKeyBase}:ItemsAll", serVal, dataCacheTTL);
+
+ // salvo redis css!
+ memLayer.ML.setRSV(redKey, answ, dataCacheTTL);
+
return answ;
}
-
+ ///
+ /// Processa elenco items e salva in redis valori x css, elenchi, ...
+ ///
+ /// CSS corrente
+ /// HASH abse x area REDIS
+ /// nome variabile x elenco items
+ /// Elenco items specifici
+ /// TTL della cache x salvataggio valori
+ ///
+ public static string saveItemData(string currCss, string redKeyBase, string varName, List itemList, int dataCacheTTL)
+ {
+ string replaceVal = "";
+ if (itemList.Count > 0)
+ {
+ foreach (var item in itemList)
+ {
+ replaceVal += $"#{item},";
+ }
+ if (replaceVal.Length > 1)
+ {
+ replaceVal = replaceVal.Remove(replaceVal.Length - 1);
+ }
+ // FIX CSS!
+ currCss = currCss.Replace($"#{varName}", replaceVal);
+ replaceVal = "";
+ //serializzo e salvo
+ string serVal = JsonConvert.SerializeObject(itemList);
+ memLayer.ML.setRSV($"{redKeyBase}:{varName}", serVal, dataCacheTTL);
+ }
+ return currCss;
+ }
#endregion
diff --git a/NKC_WF/Controllers/getMUCssController.cs b/NKC_WF/Controllers/getMUCssController.cs
index c014ef3..75bb7f4 100644
--- a/NKC_WF/Controllers/getMUCssController.cs
+++ b/NKC_WF/Controllers/getMUCssController.cs
@@ -17,8 +17,7 @@ namespace NKC_WF.Controllers
// GET api/getMUCssController
public HttpResponseMessage Get()
{
- string SheetID = "0";
- string answ = getCssByPost(SheetID);
+ string answ = getCssByPost(0);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(answ, Encoding.UTF8, "text/css")
@@ -28,8 +27,7 @@ namespace NKC_WF.Controllers
// GET api/getMUCssController/5
public HttpResponseMessage Get(int id)
{
- string SheetID = id.ToString();
- string answ = getCssByPost(SheetID);
+ string answ = getCssByPost(id);
return new HttpResponseMessage(HttpStatusCode.OK)
{
Content = new StringContent(answ, Encoding.UTF8, "text/css")
@@ -41,19 +39,12 @@ namespace NKC_WF.Controllers
///
///
///
- private static string getCssByPost(string _sheetID)
+ private static string getCssByPost(int sheetID)
{
// var base
string answ = "";
- // TTL standard
- int dataCacheTTL = memLayer.ML.cdvi("cssCacheTTL");
- dataCacheTTL = dataCacheTTL <= 0 ? 60 : dataCacheTTL;
- // dati foglio corrente
- int sheetID = 0;
- int.TryParse(_sheetID, out sheetID);
// recupero da REDIS!
- string redKey = $"{ComLib.machineUnloadArea(_sheetID)}:Css";
- string redKeyBase = $"{ComLib.machineUnloadArea(_sheetID)}";
+ string redKey = $"{ComLib.machineUnloadArea(sheetID)}:Css";
// se vuoto scrivo VUOTO...
if (!memLayer.ML.redKeyPresent(redKey))
{
@@ -64,144 +55,11 @@ namespace NKC_WF.Controllers
if (answ == "")
// se vuoto lo calcolo...
{
- string filename = HttpContext.Current.Server.MapPath("~/Content/SheetColor.css");
- answ = File.ReadAllText(filename);
-
- // elenco items da foglio!!!
- var tabItems = DataLayer.man.taIL.getBySheet(sheetID);
- List itemsAll = new List();
- List itemsDepo = new List();
- List itemsCart = new List();
- List itemsBin = new List();
- List itemsSel = new List();
- List itemsPProc = new List();
-
- //se ho items...
- if (tabItems.Count > 0)
- {
- // ciclo!
- foreach (var item in tabItems)
- {
- // aggiungoncomunque a lista generale...
- itemsAll.Add(item.ItemDtmx);
- // controllo SE sia stato depositato... check null su campo data
- if (!item.IsOnCartDateNull())
- {
- itemsDepo.Add(item.ItemDtmx);
- }
- else if (item.ProcessesReq.Contains("PaintFlag"))
- {
- itemsBin.Add(item.ItemDtmx);
- }
- else
- {
- itemsCart.Add(item.ItemDtmx);
- }
- // controllo ANCHE postprocessing
- if (item.PostProcList != "")
- {
- itemsPProc.Add(item.ItemDtmx);
- }
- }
- }
-
-
- // FIX BIN
- answ = saveItemData(answ, redKeyBase, "ItemsBin", itemsBin, dataCacheTTL);
-
- // FIX CART
- answ = saveItemData(answ, redKeyBase, "ItemsCart", itemsCart, dataCacheTTL);
-
- // FIX Scaricati
- answ = saveItemData(answ, redKeyBase, "ItemsDepo", itemsDepo, dataCacheTTL);
-
- // FIX SEC-OP
- answ = saveItemData(answ, redKeyBase, "ItemsSecOp", itemsPProc, dataCacheTTL);
-
- // FIXED SEL da array oggetti selezionati...
- string rawData = memLayer.ML.getRSV($"{redKeyBase}:ItemsSel");
- if (!string.IsNullOrEmpty(rawData))
- {
- string replaceVal = "";
- // deserializzo
- List selArray = JsonConvert.DeserializeObject>(rawData);
-
- // ciclo x cercare x ogni chiave (sessione utente)
- foreach (var item in selArray)
- {
- replaceVal += $"#{item},";
- }
- if (replaceVal.Length > 1)
- {
- replaceVal = replaceVal.Remove(replaceVal.Length - 1);
- }
- // FIX CSS!
- answ = answ.Replace("#ItemsSel", replaceVal);
- replaceVal = "";
- }
-
- // INFINE serializzo e salvo tutti gli items trovati...
- string serVal = JsonConvert.SerializeObject(itemsAll);
- memLayer.ML.setRSV($"{redKeyBase}:ItemsAll", serVal, dataCacheTTL);
-
- // salvo redis css!
- memLayer.ML.setRSV(redKey, answ, dataCacheTTL);
+ answ = ComLib.getCurrentCss(sheetID);
}
-
+ // restituisco css
return answ;
}
- private static int List(T rawData)
- {
- throw new NotImplementedException();
- }
-
- ///
- /// Processa elenco items e salva in redis valori x css, elenchi, ...
- ///
- /// CSS corrente
- /// HASH abse x area REDIS
- /// nome variabile x elenco items
- /// Elenco items specifici
- /// TTL della cache x salvataggio valori
- ///
- private static string saveItemData(string currCss, string redKeyBase, string varName, List itemList, int dataCacheTTL)
- {
- string replaceVal = "";
- if (itemList.Count > 0)
- {
- foreach (var item in itemList)
- {
- replaceVal += $"#{item},";
- }
- if (replaceVal.Length > 1)
- {
- replaceVal = replaceVal.Remove(replaceVal.Length - 1);
- }
- // FIX CSS!
- currCss = currCss.Replace($"#{varName}", replaceVal);
- replaceVal = "";
- //serializzo e salvo
- string serVal = JsonConvert.SerializeObject(itemList);
- memLayer.ML.setRSV($"{redKeyBase}:{varName}", serVal, dataCacheTTL);
- }
- return currCss;
- }
-
-
- // 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)
- {
- }
}
}
\ No newline at end of file
diff --git a/NKC_WF/Controllers/getMUCssRevController.cs b/NKC_WF/Controllers/getMUCssRevController.cs
index 6febac7..ae508f7 100644
--- a/NKC_WF/Controllers/getMUCssRevController.cs
+++ b/NKC_WF/Controllers/getMUCssRevController.cs
@@ -9,17 +9,13 @@ namespace NKC_WF.Controllers
// GET api/getMUCssRev
public int Get()
{
- int answ = 0;
- string SheetID = "0";
- answ = getRevBySheet(SheetID);
+ int answ = getRevBySheet(0);
return answ;
}
// GET api/getMUCssRev/5
public int Get(int id)
{
- int answ = 0;
- string SheetID = id.ToString();
- answ = getRevBySheet(SheetID);
+ int answ = getRevBySheet(id);
return answ;
}
///
@@ -27,7 +23,7 @@ namespace NKC_WF.Controllers
///
///
///
- private static int getRevBySheet(string SheetID)
+ private static int getRevBySheet(int SheetID)
{
int answ;
// recupero da REDIS!
diff --git a/NKC_WF/WebUserControls/cmp_menuTop.ascx.cs b/NKC_WF/WebUserControls/cmp_menuTop.ascx.cs
index 0ec3276..31e2e10 100644
--- a/NKC_WF/WebUserControls/cmp_menuTop.ascx.cs
+++ b/NKC_WF/WebUserControls/cmp_menuTop.ascx.cs
@@ -110,7 +110,7 @@ namespace NKC_WF.WebUserControls
if (doFullReset)
{
// reset REDIS x css
- ComLib.man.resetPostUnload("");
+ ComLib.man.resetPostUnload();
// aggiorno vocabolario
DataWrap.DW.resetVocabolario();
// reset dati in cache x DbConfig...