Files
NKC/NKC_WF/site/MachineUnload.aspx.cs
T
2020-08-12 15:23:02 +02:00

174 lines
4.8 KiB
C#

using AppData;
using SteamWare;
using System;
namespace NKC_WF
{
public partial class MachineUnload : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
((SiteMaster)this.Master).showSearch = false;
// svuoto redis...
memLayer.ML.redFlushKey(ComLib.redMachUnloadCount);
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;
}
}
/// <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 % 4 == 0)
{
cmp_MU_stats.doUpdate();
upnlStats.DataBind();
// verifico se c'è richiesta reload UNLOAD...
if (!string.IsNullOrEmpty(memLayer.ML.getRSV(redProdForceReload)))
{
Response.Redirect(Request.RawUrl);
}
}
if (counter % 2 == 0)
{
cmp_MU_carts.doUpdate();
upnlCarts.DataBind();
cmp_MU_bins.doUpdate();
upnlCarts.DataBind();
}
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);
Response.Redirect(Request.RawUrl);
}
memLayer.ML.setRCntI(redProdReq);
}
}
}