Files
NKC/NKC_WF/site/MachineUnload.aspx.cs
T
2020-08-13 09:43:19 +02:00

178 lines
4.7 KiB
C#

using AppData;
using SteamWare;
using System;
namespace NKC_WF
{
public partial class MachineUnload : BasePage
{
/// <summary>
/// Codice macchina (HARD CODED x ora)
/// </summary>
protected string machine = "WRK001";
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
((SiteMaster)this.Master).showSearch = false;
BatchId = -1;
SheetId = -1;
doUpdate();
}
}
/// <summary>
/// BatchId corrente...
/// </summary>
public int BatchId
{
set
{
hfBatchID.Value = value.ToString();
}
get
{
int answ = 0;
int.TryParse(hfBatchID.Value, out answ);
return answ;
}
}
/// <summary>
/// SheetId corrente...
/// </summary>
public int SheetId
{
set
{
hfSheetID.Value = value.ToString();
}
get
{
int answ = 0;
int.TryParse(hfSheetID.Value, out answ);
return answ;
}
}
/// <summary>
/// Aggiorna componente principale e child components
/// </summary>
private void doUpdate()
{
// imposto dati correnti
bool doUpdate = setCurrData();
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();
}
}
/// <summary>
/// Imposta dati correnti (Bunk / Sheet) indicando SE fare update
/// </summary>
private bool setCurrData()
{
bool needUpdate = false;
// recupero bunk corrente...
DS_App.StackListRow currBunk = ComLib.getCurrBunk();
if (currBunk != null)
{
if (BatchId != currBunk.BatchID)
{
BatchId = currBunk.BatchID;
needUpdate = true;
}
DS_App.SheetListRow currSheet = ComLib.getCurrSheet(BatchId);
if (currSheet != null)
{
if (SheetId != currSheet.SheetID)
{
SheetId = currSheet.SheetID;
needUpdate = true;
}
}
}
else
{
BatchId = 0;
ComLib.man.resetSheetUnload(0);
}
// se sheet/bunk 0 --> update!
if (BatchId == 0 && SheetId == 0)
{
needUpdate = true;
}
return needUpdate;
}
protected void timerSvg_Tick(object sender, EventArgs e)
{
// in base al num di sec dell'ora decido cosa aggiornare...
int counter = numWaitSvg;
doUpdate();
// ogni x cicli
if (counter % 10 == 0)
{
cmp_MU_stats.doUpdate();
upnlStats.Update();
}
// faccio update bin/cart ogni pari/dispari...
else if (counter % 2 == 0)
{
cmp_MU_carts.doUpdate();
upnlCarts.Update();
}
else
{
cmp_MU_bins.doUpdate();
upnlBins.Update();
}
incrNumWait();
}
/// <summary>
/// stringa x contatore refresh redis...
/// </summary>
protected string redProdReq
{
get
{
return $"{ComLib.redMachUnloadCount}:{Session.SessionID}";
}
}
/// <summary>
/// stringa x contatore refresh redis...
/// </summary>
protected string redProdForceReload
{
get
{
return ComLib.redMachUnloadForce;
}
}
protected int numWaitSvg
{
get
{
return memLayer.ML.getRCnt(redProdReq);
}
}
/// <summary>
/// Incrementa counter redis
/// </summary>
protected void incrNumWait()
{
if (numWaitSvg > 30)
{
memLayer.ML.resetRCnt(redProdReq);
}
memLayer.ML.setRCntI(redProdReq);
}
}
}