307 lines
8.2 KiB
C#
307 lines
8.2 KiB
C#
using AppData;
|
|
using SteamWare;
|
|
using System;
|
|
|
|
namespace NKC_WF
|
|
{
|
|
public partial class MachineUnload : BasePage, IDisposable
|
|
{
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// BatchId corrente...
|
|
/// </summary>
|
|
public int BatchId
|
|
{
|
|
set
|
|
{
|
|
hfBatchID.Value = value.ToString();
|
|
ComLib.setCurrBatchId(MachineSel, value);
|
|
}
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfBatchID.Value, out answ);
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// SheetId corrente...
|
|
/// </summary>
|
|
public int SheetId
|
|
{
|
|
set
|
|
{
|
|
hfSheetID.Value = value.ToString();
|
|
ComLib.setCurrSheetId(MachineSel, value);
|
|
}
|
|
get
|
|
{
|
|
int answ = 0;
|
|
int.TryParse(hfSheetID.Value, out answ);
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica se sia da mostrare pagina MissingInAction
|
|
/// </summary>
|
|
public bool showPartMIA
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
if (BatchId > 0)
|
|
{
|
|
try
|
|
{
|
|
bool hasMIA = DLMan.taIL.getMissingByBatch(BatchId).Count > 0;
|
|
answ = hasMIA && MachineSel != "#";
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public override void Dispose()
|
|
{
|
|
timerSvg.Tick -= timerSvg_Tick;
|
|
timerSvg.Dispose();
|
|
base.Dispose();
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Protected Properties
|
|
|
|
protected string MachineSel
|
|
{
|
|
get
|
|
{
|
|
return PlaceCod;
|
|
}
|
|
set
|
|
{
|
|
PlaceCod = value;
|
|
cmp_MU_bins.MachineSel = value;
|
|
cmp_MU_carts.MachineSel = value;
|
|
hlPartMIA.NavigateUrl = $"PartMIA?mach={value}";
|
|
}
|
|
}
|
|
|
|
protected int numWaitSvg
|
|
{
|
|
get
|
|
{
|
|
int answ = 999;
|
|
answ = memLayer.ML.getRCnt(redProdReq);
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// stringa x contatore refresh redis...
|
|
/// </summary>
|
|
protected string redProdForceReload
|
|
{
|
|
get
|
|
{
|
|
return ComLib.redMachUnloadForce;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// stringa x contatore refresh redis...
|
|
/// </summary>
|
|
protected string redProdReq
|
|
{
|
|
get
|
|
{
|
|
return $"{ComLib.redMachUnloadCount}:{Session.SessionID}";
|
|
}
|
|
}
|
|
|
|
protected int savedBatchId
|
|
{
|
|
get
|
|
{
|
|
return ComLib.getCurrBatchId(MachineSel);
|
|
}
|
|
}
|
|
|
|
protected int savedSheetId
|
|
{
|
|
get
|
|
{
|
|
return ComLib.getCurrSheetId(MachineSel);
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Incrementa counter redis
|
|
/// </summary>
|
|
protected void incrNumWait()
|
|
{
|
|
if (numWaitSvg > 30)
|
|
{
|
|
memLayer.ML.resetRCnt(redProdReq);
|
|
Response.Redirect(Request.RawUrl);
|
|
}
|
|
memLayer.ML.setRCntI(redProdReq);
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
((SiteMaster)this.Master).showSearch = false;
|
|
setTimer();
|
|
doUpdate();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Main SVG timer
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void timerSvg_Tick(object sender, EventArgs e)
|
|
{
|
|
// in base al num di sec dell'ora decido cosa aggiornare...
|
|
int counter = numWaitSvg;
|
|
// ogni x cicli resetto batch/Foglio
|
|
if (counter % 15 == 0)
|
|
{
|
|
SheetId = -3;
|
|
}
|
|
// ora faccio verifiche
|
|
doUpdate();
|
|
// ogni x cicli
|
|
if (counter % 5 == 0)
|
|
{
|
|
cmp_MU_stats.doUpdate();
|
|
upnlStats.Update();
|
|
}
|
|
// faccio update bin/cart ogni pari/dispari...
|
|
if (counter % 2 == 0)
|
|
{
|
|
cmp_MU_carts.doUpdate();
|
|
upnlCarts.Update();
|
|
}
|
|
else
|
|
{
|
|
cmp_MU_bins.doUpdate();
|
|
upnlBins.Update();
|
|
}
|
|
incrNumWait();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// Aggiorna componente principale e child components
|
|
/// </summary>
|
|
private void doUpdate()
|
|
{
|
|
// verifico CI SIA la macchina...
|
|
if (string.IsNullOrEmpty(cmp_MachSem.currMachine))
|
|
{
|
|
divMain.Visible = false;
|
|
MachineSel = "#";
|
|
}
|
|
else
|
|
{
|
|
MachineSel = cmp_MachSem.currMachine;
|
|
divMain.Visible = true;
|
|
// 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)
|
|
{
|
|
cmp_MU_svgViewer.doUpdate();
|
|
upnlDrawings.DataBind();
|
|
upnlDrawings.Update();
|
|
upnlTitle.Update();
|
|
}
|
|
}
|
|
// definisco se mostrare PartMIA
|
|
hlPartMIA.Visible = showPartMIA;
|
|
}
|
|
|
|
/// <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(MachineSel);
|
|
if (currBunk != null)
|
|
{
|
|
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, MachineSel);
|
|
if (currSheet != null)
|
|
{
|
|
bool chgShLocal = SheetId != currSheet.SheetID;
|
|
bool chgShCache = savedSheetId != currSheet.SheetID;
|
|
if (chgShLocal || chgShCache)
|
|
{
|
|
SheetId = currSheet.SheetID;
|
|
needUpdate = true;
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
BatchId = 0;
|
|
SheetId = 0;
|
|
ComLib.setCurrBunkId(MachineSel, 0);
|
|
ComLib.man.resetSheetUnload(0);
|
|
}
|
|
// se sheet/bunk 0 --> update!
|
|
if (BatchId <= 0 && SheetId <= 0)
|
|
{
|
|
needUpdate = true;
|
|
}
|
|
return needUpdate;
|
|
}
|
|
|
|
/// <summary>
|
|
/// imposta il tempo di scadenza del timer x il refresh del componente
|
|
/// </summary>
|
|
private void setTimer()
|
|
{
|
|
int timerSvgInt = memLayer.ML.CRI("timerUnload");
|
|
timerSvgInt = timerSvgInt > 0 ? timerSvgInt : 500;
|
|
timerSvg.Interval = timerSvgInt;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |