From 5c09ff40803c4fdb601afa2b214034e1f3f8c283 Mon Sep 17 00:00:00 2001 From: "Samuele E. Locatelli" Date: Thu, 13 Aug 2020 13:17:31 +0200 Subject: [PATCH] Fix finali refresh corretto x UNLOAD --- AppData/ComLib.cs | 45 ++++++++++++++++++++++++++-- NKC_WF/site/MachineUnload.aspx.cs | 49 ++++++++++++++++++++++++------- 2 files changed, 81 insertions(+), 13 deletions(-) diff --git a/AppData/ComLib.cs b/AppData/ComLib.cs index ec32b7c..f3d2050 100644 --- a/AppData/ComLib.cs +++ b/AppData/ComLib.cs @@ -1199,6 +1199,24 @@ namespace AppData return answ; } /// + /// Chiave BATCH corrente su redis + /// + /// + /// + protected static string redCurrBatchId(string machine) + { + string answ = ""; + if (string.IsNullOrEmpty(machine)) + { + answ = $"{redProdReq}:CurrBatchID"; + } + else + { + answ = $"{redProdReq}:CurrBatchID:{machine}"; + } + return answ; + } + /// /// Chiave Bunk corrente su redis /// /// @@ -1241,12 +1259,32 @@ namespace AppData { resetCurrBunk(); resetCurrSheet(); - setCurrBunkId(machine, -2); - setCurrSheetId(machine, -2); + setCurrBatchId(machine, 0); + setCurrBunkId(machine, 0); + setCurrSheetId(machine, 0); redisFirstBunk = null; } /// /// Cache redis del BunkID in lavorazione sulla macchina + /// + /// + public static int getCurrBatchId(string macchina) + { + int answ = -1; + string rawData = memLayer.ML.getRSV(redCurrBatchId(macchina)); + int.TryParse(rawData, out answ); + return answ; + } + /// + /// Salvataggio in redis del BunkID in lavorazione sulla macchina + /// + public static void setCurrBatchId(string macchina, int BatchID) + { + memLayer.ML.setRSV(redCurrBatchId(macchina), BatchID.ToString()); + } + /// + /// Cache redis del BunkID in lavorazione sulla macchina + /// /// public static int getCurrBunkId(string macchina) { @@ -1264,6 +1302,7 @@ namespace AppData } /// /// Cache redis del SheetID in lavorazione sulla macchina + /// /// public static int getCurrSheetId(string macchina) { @@ -1277,7 +1316,7 @@ namespace AppData /// public static void setCurrSheetId(string macchina, int SheetID) { - memLayer.ML.setRSV(redCurrBunkId(macchina), SheetID.ToString()); + memLayer.ML.setRSV(redCurrSheetId(macchina), SheetID.ToString()); } /// /// Cache redis del PRIMO bunk da lavorare diff --git a/NKC_WF/site/MachineUnload.aspx.cs b/NKC_WF/site/MachineUnload.aspx.cs index 5f514cf..cd362f0 100644 --- a/NKC_WF/site/MachineUnload.aspx.cs +++ b/NKC_WF/site/MachineUnload.aspx.cs @@ -16,12 +16,25 @@ namespace NKC_WF if (!Page.IsPostBack) { ((SiteMaster)this.Master).showSearch = false; - BatchId = -1; - SheetId = -1; doUpdate(); } } + protected int savedBatchId + { + get + { + return ComLib.getCurrBatchId(machine); + } + } + protected int savedSheetId + { + get + { + return ComLib.getCurrSheetId(machine); + } + } + /// /// BatchId corrente... /// @@ -30,11 +43,11 @@ namespace NKC_WF set { hfBatchID.Value = value.ToString(); - ComLib.setCurrBunkId(machine, value); + ComLib.setCurrBatchId(machine, value); } get { - int answ = ComLib.getCurrBunkId(machine); + int answ = 0; int.TryParse(hfBatchID.Value, out answ); return answ; } @@ -51,7 +64,7 @@ namespace NKC_WF } get { - int answ = ComLib.getCurrSheetId(machine); + int answ = 0; int.TryParse(hfSheetID.Value, out answ); return answ; } @@ -72,6 +85,8 @@ namespace NKC_WF if (doUpdate) { cmp_MU_svgViewer.doUpdate(); + upnlDrawings.DataBind(); + upnlDrawings.Update(); upnlTitle.Update(); } } @@ -85,16 +100,21 @@ namespace NKC_WF DS_App.StackListRow currBunk = ComLib.getCurrBunk(); if (currBunk != null) { - if (BatchId != currBunk.BatchID) + bool chgBtLocal = BatchId != currBunk.BatchID; + bool chgBtCache = savedBatchId != currBunk.BatchID; + if (chgBtLocal || chgBtCache) { BatchId = currBunk.BatchID; + SheetId = 0; needUpdate = true; } DS_App.SheetListRow currSheet = ComLib.getCurrSheet(BatchId, machine); if (currSheet != null) { - if (SheetId != currSheet.SheetID) + bool chgShLocal = SheetId != currSheet.SheetID; + bool chgShCache = savedSheetId != currSheet.SheetID; + if (chgShLocal || chgShCache) { SheetId = currSheet.SheetID; needUpdate = true; @@ -104,8 +124,8 @@ namespace NKC_WF else { BatchId = 0; + SheetId = 0; ComLib.setCurrBunkId(machine, 0); - ComLib.setCurrSheetId(machine, 0); ComLib.man.resetSheetUnload(0); } // se sheet/bunk 0 --> update! @@ -120,6 +140,13 @@ namespace NKC_WF { // in base al num di sec dell'ora decido cosa aggiornare... int counter = numWaitSvg; + // ogni x cicli resetto batch/Foglio + if (counter % 15 == 0) + { + //BatchId = -3; + SheetId = -3; + } + // ora faccio verifiche doUpdate(); // ogni x cicli if (counter % 10 == 0) @@ -165,7 +192,9 @@ namespace NKC_WF { get { - return memLayer.ML.getRCnt(redProdReq); + int answ = 999; + answ = memLayer.ML.getRCnt(redProdReq); + return answ; } } /// @@ -173,7 +202,7 @@ namespace NKC_WF /// protected void incrNumWait() { - if (numWaitSvg > 20) + if (numWaitSvg > 30) { memLayer.ML.resetRCnt(redProdReq); Response.Redirect(Request.RawUrl);