using AppData; using Newtonsoft.Json; using SteamWare; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace NKC_WF { public partial class OrderManager : System.Web.UI.Page { /// /// Hash redis per il canale di comunicazione dei comandi /// protected string batchCmdChannel = "NKC:CMD:batchReq"; /// /// Hash redis per il canale di comunicazione dei batch da eseguire /// protected string batchOutChannel = "NKC:OUT:batchReq"; /// /// Hash redis per il canale di comunicazione dei batch eseguiti/in esecuzione /// protected string batchInChannel = "NKC:IN:batchReq"; protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { processPending(); checkVisibility(); } cmp_batchList.eh_doRefresh += Cmp_batchList_eh_doRefresh; } private void Cmp_batchList_eh_doRefresh(object sender, EventArgs e) { checkVisibility(); } private void processPending() { // se trova batch non riportati in REDIS li scrive x richiedere processing string batchKey = $"{batchOutChannel}:{currBatchID}"; bool reqPresent = !string.IsNullOrEmpty(memLayer.ML.getRSV(batchKey)); if (!reqPresent) { // !!!FIXME!!! leggere da DB!!! var articoli = new List(); var articolo = new Item() { ItemId = 1, ItemExtCode = "abc.2345", MatID = 2, ItemrQty = 2, CadFilePath = @"c:\temp\prova.dxf" }; articoli.Add(articolo); var ordini = new List(); Order ordine = new Order() { OrderCod = "abcde", OrderExtCode = "HFA_123456", DestPlant = "Striker", OrderQty = 1, Items = articoli }; ordini.Add(ordine); var currBatch = new batchRequest { BatchID = currBatchID, Orders = ordini } ; string payload = JsonConvert.SerializeObject(currBatch); memLayer.ML.setRSV(batchKey, payload); } } /// /// ID del batch corrente /// protected int currBatchID { get { int answ = 0; if (memLayer.ML.isInSessionObject("BatchID")) { answ = memLayer.ML.IntSessionObj("BatchID"); } return answ; } } private void checkVisibility() { bool hasBatch = false; if (currBatchID > 0) { hasBatch = true; } divStatus.Visible = hasBatch; } } }