Update x metodi refresh da chiamate PROD

This commit is contained in:
Samuele E. Locatelli
2020-08-13 11:19:53 +02:00
parent 85e3c7d6ef
commit bcf6805ac1
9 changed files with 199 additions and 55 deletions
+143 -36
View File
@@ -184,7 +184,7 @@ namespace AppData
public static string redOutPath = "NKC:SERV:BREQ";
public static string redMsgCount = "NKC:SERV:BREQ:MCount";
public static string redMsgList = "NKC:SERV:BREQ:MList";
public static string redMLCurrStack = "NKC:SERV:TAKT:CurrStack";
public static string redMLCurrBunk = "NKC:SERV:TAKT:CurrBunk";
public static string redNestAnsw = "NKC:NEST:BANSW";
@@ -1165,29 +1165,121 @@ namespace AppData
/// <summary>
/// Chiave bunk corrente su redis
/// </summary>
/// <param name="machine"></param>
/// <returns></returns>
protected static string redCurrBunkTabKey(string machine)
{
string answ = "";
if (string.IsNullOrEmpty(machine))
{
machine = "WRK001";
answ = $"{redProdReq}:CurrBunks";
}
return $"{redProdReq}:CurrBunks:{machine}";
else
{
answ = $"{redProdReq}:CurrBunks:{machine}";
}
return answ;
}
/// <summary>
/// Chiave bunk corrente su redis
/// Chiave sheets correnti su redis
/// </summary>
protected static string redCurrSheetTabKey()
/// <param name="machine"></param>
/// <returns></returns>
protected static string redCurrSheetTabKey(string machine)
{
return $"{redProdReq}:CurrSheets";
string answ = "";
if (string.IsNullOrEmpty(machine))
{
answ = $"{redProdReq}:CurrSheets";
}
else
{
answ = $"{redProdReq}:CurrSheets:{machine}";
}
return answ;
}
/// <summary>
/// Chiave Bunk corrente su redis
/// </summary>
/// <param name="machine"></param>
/// <returns></returns>
protected static string redCurrBunkId(string machine)
{
string answ = "";
if (string.IsNullOrEmpty(machine))
{
answ = $"{redProdReq}:CurrBunkID";
}
else
{
answ = $"{redProdReq}:CurrBunkID:{machine}";
}
return answ;
}
/// <summary>
/// Chiave Sheets corrente su redis
/// </summary>
/// <param name="machine"></param>
/// <returns></returns>
protected static string redCurrSheetId(string machine)
{
string answ = "";
if (string.IsNullOrEmpty(machine))
{
answ = $"{redProdReq}:CurrSheetID";
}
else
{
answ = $"{redProdReq}:CurrSheetID:{machine}";
}
return answ;
}
/// <summary>
/// Resetto in REDIS i dati di bunk (corrente e successivi)
/// </summary>
public static void resetRedisBunkData()
public static void resetRedisBunkData(string machine)
{
resetCurrBunk();
resetCurrSheet();
setCurrBunkId(machine, -2);
setCurrSheetId(machine, -2);
redisFirstBunk = null;
}
/// <summary>
/// Cache redis del BunkID in lavorazione sulla macchina
/// </summary>
public static int getCurrBunkId(string macchina)
{
int answ = -1;
string rawData = memLayer.ML.getRSV(redCurrBunkId(macchina));
int.TryParse(rawData, out answ);
return answ;
}
/// <summary>
/// Salvataggio in redis del BunkID in lavorazione sulla macchina
/// </summary>
public static void setCurrBunkId(string macchina, int BunkID)
{
memLayer.ML.setRSV(redCurrBunkId(macchina), BunkID.ToString());
}
/// <summary>
/// Cache redis del SheetID in lavorazione sulla macchina
/// </summary>
public static int getCurrSheetId(string macchina)
{
int answ = -1;
string rawData = memLayer.ML.getRSV(redCurrSheetId(macchina));
int.TryParse(rawData, out answ);
return answ;
}
/// <summary>
/// Salvataggio in redis del SheetID in lavorazione sulla macchina
/// </summary>
public static void setCurrSheetId(string macchina, int SheetID)
{
memLayer.ML.setRSV(redCurrBunkId(macchina), SheetID.ToString());
}
/// <summary>
/// Cache redis del PRIMO bunk da lavorare
/// </summary>
private static ProdBunk redisFirstBunk
@@ -1465,7 +1557,7 @@ namespace AppData
/// resetto curr bunk
/// </summary>
/// <param name="machine"></param>
protected static void resetCurrBunk(string machine = "WRK001")
public static void resetCurrBunk(string machine = "WRK001")
{
// svuoto"
memLayer.ML.redFlushKey(redCurrBunkTabKey(machine));
@@ -1523,8 +1615,9 @@ namespace AppData
/// Recupera lo sheet corrente da un BUNK come quello in status 5...
/// </summary>
/// <param name="BatchID"></param>
/// <param name="machine"></param>
/// <returns></returns>
public static DS_App.SheetListRow getCurrSheet(int BatchID)
public static DS_App.SheetListRow getCurrSheet(int BatchID, string machine)
{
DS_App.SheetListRow answ = null;
if (BatchID > 0)
@@ -1533,17 +1626,18 @@ namespace AppData
{
DS_App.SheetListDataTable tabSheets = null;
// cerco in cache....
if (cachedCurrSheetTab != null)
if (getCurrSheetTab(machine) != null)
{
tabSheets = cachedCurrSheetTab;
tabSheets = getCurrSheetTab(machine);
}
else
{
// recupero sheet corrente da Bunk...
tabSheets = DataLayer.man.taSHL.getByMLStatus(BatchID, 5, 5);
// salvo in redis
cachedCurrSheetTab = tabSheets;
setCurrSheetTab(machine, tabSheets);
}
// leggo prima riga --> foglio corrente
if (tabSheets != null && tabSheets.Count > 0)
{
answ = tabSheets[0];
@@ -1554,31 +1648,44 @@ namespace AppData
}
return answ;
}
protected static DS_App.SheetListDataTable cachedCurrSheetTab
/// <summary>
/// resetto curr sheets
/// </summary>
/// <param name="machine"></param>
public static void resetCurrSheet(string machine = "WRK001")
{
get
// svuoto"
memLayer.ML.redFlushKey(redCurrSheetTabKey(machine));
}
/// <summary>
/// Recupero da redis tab fogli correnti
/// </summary>
protected static DS_App.SheetListDataTable getCurrSheetTab(string machine)
{
DS_App.SheetListDataTable answ = null;
string rawData = memLayer.ML.getRSV(redCurrSheetTabKey(machine));
if (!string.IsNullOrEmpty(rawData))
{
DS_App.SheetListDataTable answ = null;
string rawData = memLayer.ML.getRSV(redCurrSheetTabKey());
if (!string.IsNullOrEmpty(rawData))
try
{
try
{
// deserializzo...
answ = JsonConvert.DeserializeObject<DS_App.SheetListDataTable>(rawData);
}
catch
{ }
// deserializzo...
answ = JsonConvert.DeserializeObject<DS_App.SheetListDataTable>(rawData);
}
return answ;
}
set
{
string rawData = JsonConvert.SerializeObject(value);
// TTL 5 sec
memLayer.ML.setRSV(redCurrSheetTabKey(), rawData, 5);
catch
{ }
}
return answ;
}
/// <summary>
/// Salvataggio in redis tab fogli correnti
/// </summary>
/// <param name="machine"></param>
/// <param name="tabella"></param>
protected static void setCurrSheetTab(string machine, DS_App.SheetListDataTable tabella)
{
string rawData = JsonConvert.SerializeObject(tabella);
// TTL 5 sec
memLayer.ML.setRSV(redCurrSheetTabKey(machine), rawData, 2);
}
/// <summary>
/// Restituisce il PROSSIMO bunk secondo criterio:
@@ -1791,17 +1898,17 @@ namespace AppData
return answ;
}
/// <summary>
/// Valore dello Stack correntemente in processing per ML (MachineLoad)
/// ID del BUNK correntemente in processing per ML (MachineLoad)
/// </summary>
public static string taktMLCurrStack
public static string taktMLCurrBunk
{
get
{
return memLayer.ML.getRSV(redMLCurrStack);
return memLayer.ML.getRSV(redMLCurrBunk);
}
set
{
memLayer.ML.setRSV(redMLCurrStack, value);
memLayer.ML.setRSV(redMLCurrBunk, value);
}
}
+5 -1
View File
@@ -8,6 +8,10 @@ namespace NKC_WF.Controllers
{
public class BunkController : ApiController
{
/// <summary>
/// COdice macchina (HARD CODED)
/// </summary>
protected string machine = "WRK001";
/// <summary>
/// Restituisce il FIRST BUNK da lavorare
/// GET: api/Bunk
@@ -101,7 +105,7 @@ namespace NKC_WF.Controllers
}
}
// INVALIDO eventuale valore BUNK in REDIS...
ComLib.resetRedisBunkData();
ComLib.resetRedisBunkData(machine);
}
/// <summary>
+8 -2
View File
@@ -8,6 +8,10 @@ namespace NKC_WF.Controllers
{
public class SheetController : ApiController
{
/// <summary>
/// COdice macchina (HARD CODED)
/// </summary>
protected string machine = "WRK001";
/// <summary>
/// Restituisce un array di sheet da lavorare (quindi NON ancora scaricati, anche di + BUNK)
/// GET: api/Sheet
@@ -95,7 +99,7 @@ namespace NKC_WF.Controllers
if (currSheet.Machining.DtEnd != null)
{
// hard coded su multiax
DataLayer.man.taIL.updateSheetStatus(currSheet.SheetId, 1, "WRK001");
DataLayer.man.taIL.updateSheetStatus(currSheet.SheetId, 1, machine);
}
}
// segnalo avanzamento su redis x pagina unload
@@ -113,7 +117,7 @@ namespace NKC_WF.Controllers
// ricalcolo stato BUNK
ComLib.updateBatchPosition(BatchId);
// INVALIDO eventuale valore BUNK in REDIS...
ComLib.resetRedisBunkData();
ComLib.resetRedisBunkData(machine);
}
}
@@ -175,6 +179,8 @@ namespace NKC_WF.Controllers
}
// ricalcolo stato BUNK
ComLib.updateBatchPosition(BatchId);
// INVALIDO eventuale valore BUNK in REDIS...
ComLib.resetRedisBunkData(machine);
}
}
catch
+6 -1
View File
@@ -17,6 +17,11 @@ namespace NKC_WF.WebUserControls
public partial class cmp_secScreen : BaseUserControl
{
/// <summary>
/// Codice macchina (HARD CODED x ora)
/// </summary>
protected string machine = "WRK001";
protected void timerRefresh_Tick(object sender, EventArgs e)
{
countDown--;
@@ -38,7 +43,7 @@ namespace NKC_WF.WebUserControls
DS_App.StackListRow currBunk = ComLib.getCurrBunk();
if (currBunk != null)
{
DS_App.SheetListRow currSheet = ComLib.getCurrSheet(currBunk.BatchID);
DS_App.SheetListRow currSheet = ComLib.getCurrSheet(currBunk.BatchID, machine);
if (currSheet != null)
{
// se variato...
@@ -162,7 +162,8 @@ namespace NKC_WF.WebUserControls
if (currentBunkPrinted)
{
cmp_barcode.showOutput("badge badge-success", $"BUNK OK, {decoData.rawData}");
ComLib.taktMLCurrStack = decoData.code;
ComLib.resetCurrBunk();
ComLib.taktMLCurrBunk = decoData.codeInt.ToString();
// processo DB e salvo che lo stack è stato caricato in MACHINE LOAD
int stackId = 0;
try
+3 -1
View File
@@ -7,6 +7,8 @@ namespace NKC_WF.site
{
public partial class DBG_QRCode_Unload : System.Web.UI.Page
{
string machine ="WRK001";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
@@ -92,7 +94,7 @@ namespace NKC_WF.site
if (currBunk != null)
{
BatchId = currBunk.BatchID;
DS_App.SheetListRow currSheet = ComLib.getCurrSheet(BatchId);
DS_App.SheetListRow currSheet = ComLib.getCurrSheet(BatchId, machine);
if (currSheet != null)
{
SheetId = currSheet.SheetID;
+6 -2
View File
@@ -9,7 +9,11 @@
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<div class="mx-0">
<div class="card text-center" style="width: 100%;">
<h4 class="card-header bg-secondary text-light"><%: traduci("MachineUnload") %> <sub>(<%: hfBatchID.Value %>)</sub></h4>
<asp:UpdatePanel runat="server" ID="upnlTitle" UpdateMode="Conditional">
<ContentTemplate>
<h4 class="card-header bg-secondary text-light"><%: traduci("MachineUnload") %> <sub>(<%: hfBatchID.Value %>)</sub></h4>
</ContentTemplate>
</asp:UpdatePanel>
<div class="card-body py-1 bg-dark">
<asp:UpdatePanel runat="server" ID="upnlStats" UpdateMode="Conditional">
<ContentTemplate>
@@ -36,7 +40,7 @@
<div class="col-2 pl-0">
<asp:UpdatePanel runat="server" ID="upnlCarts" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="timerSvg" runat="server" Interval="1200" OnTick="timerSvg_Tick"></asp:Timer>
<asp:Timer ID="timerSvg" runat="server" Interval="1100" OnTick="timerSvg_Tick"></asp:Timer>
<uc1:cmp_MU_carts runat="server" ID="cmp_MU_carts" />
</ContentTemplate>
</asp:UpdatePanel>
+17 -11
View File
@@ -30,10 +30,11 @@ namespace NKC_WF
set
{
hfBatchID.Value = value.ToString();
ComLib.setCurrBunkId(machine, value);
}
get
{
int answ = 0;
int answ = ComLib.getCurrBunkId(machine);
int.TryParse(hfBatchID.Value, out answ);
return answ;
}
@@ -46,10 +47,11 @@ namespace NKC_WF
set
{
hfSheetID.Value = value.ToString();
ComLib.setCurrSheetId(machine, value);
}
get
{
int answ = 0;
int answ = ComLib.getCurrSheetId(machine);
int.TryParse(hfSheetID.Value, out answ);
return answ;
}
@@ -61,15 +63,16 @@ namespace NKC_WF
{
// imposto dati correnti
bool doUpdate = setCurrData();
// aggiorno child
cmp_MU_stats.BatchId = BatchId;
cmp_MU_bins.BatchId = BatchId;
cmp_MU_carts.BatchId = BatchId;
cmp_MU_svgViewer.BatchId = BatchId;
cmp_MU_svgViewer.SheetId = SheetId;
if (doUpdate)
{
// aggiorno child
cmp_MU_stats.BatchId = BatchId;
cmp_MU_bins.BatchId = BatchId;
cmp_MU_carts.BatchId = BatchId;
cmp_MU_svgViewer.BatchId = BatchId;
cmp_MU_svgViewer.SheetId = SheetId;
cmp_MU_svgViewer.doUpdate();
upnlTitle.Update();
}
}
/// <summary>
@@ -88,7 +91,7 @@ namespace NKC_WF
needUpdate = true;
}
DS_App.SheetListRow currSheet = ComLib.getCurrSheet(BatchId);
DS_App.SheetListRow currSheet = ComLib.getCurrSheet(BatchId, machine);
if (currSheet != null)
{
if (SheetId != currSheet.SheetID)
@@ -101,10 +104,12 @@ namespace NKC_WF
else
{
BatchId = 0;
ComLib.setCurrBunkId(machine, 0);
ComLib.setCurrSheetId(machine, 0);
ComLib.man.resetSheetUnload(0);
}
// se sheet/bunk 0 --> update!
if (BatchId == 0 && SheetId == 0)
if (BatchId <= 0 && SheetId <= 0)
{
needUpdate = true;
}
@@ -168,9 +173,10 @@ namespace NKC_WF
/// </summary>
protected void incrNumWait()
{
if (numWaitSvg > 30)
if (numWaitSvg > 20)
{
memLayer.ML.resetRCnt(redProdReq);
Response.Redirect(Request.RawUrl);
}
memLayer.ML.setRCntI(redProdReq);
}
+9
View File
@@ -14,6 +14,15 @@ namespace NKC_WF
public partial class MachineUnload
{
/// <summary>
/// Controllo upnlTitle.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// </remarks>
protected global::System.Web.UI.UpdatePanel upnlTitle;
/// <summary>
/// Controllo upnlStats.
/// </summary>