using AppData; using SteamWare; using System; namespace NKC_WF { public partial class MachineUnload : BasePage { #region Protected Properties protected int numWaitSvg { get { int answ = 999; answ = memLayer.ML.getRCnt(redProdReq); return answ; } } /// /// stringa x contatore refresh redis... /// protected string redProdForceReload { get { return ComLib.redMachUnloadForce; } } /// /// stringa x contatore refresh redis... /// protected string redProdReq { get { return $"{ComLib.redMachUnloadCount}:{Session.SessionID}"; } } protected int savedBatchId { get { return ComLib.getCurrBatchId(machine); } } protected int savedSheetId { get { return ComLib.getCurrSheetId(machine); } } #endregion Protected Properties #region Public Properties /// /// BatchId corrente... /// public int BatchId { set { hfBatchID.Value = value.ToString(); ComLib.setCurrBatchId(machine, value); } get { int answ = 0; int.TryParse(hfBatchID.Value, out answ); return answ; } } /// /// SheetId corrente... /// public int SheetId { set { hfSheetID.Value = value.ToString(); ComLib.setCurrSheetId(machine, value); } get { int answ = 0; int.TryParse(hfSheetID.Value, out answ); return answ; } } /// /// Verifica se sia da mostrare pagina MissingInAction /// public bool showPartMIA { get { bool answ = false; try { answ = DLMan.taIL.getMissingByBatch(BatchId).Count > 0; } catch { } return answ; } } #endregion Public Properties #region Private Methods /// /// Aggiorna componente principale e child components /// private void doUpdate() { // verifico CI SIA la macchina... if (string.IsNullOrEmpty(cmp_MachSem.currMachine)) { divMain.Visible = false; machine = "#"; } else { machine = 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; } } /// /// Imposta dati correnti (Bunk / Sheet) indicando SE fare update /// private bool setCurrData() { bool needUpdate = false; // recupero bunk corrente... DS_App.StackListRow currBunk = ComLib.getCurrBunk(machine); 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, machine); 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(machine, 0); ComLib.man.resetSheetUnload(0); } // se sheet/bunk 0 --> update! if (BatchId <= 0 && SheetId <= 0) { needUpdate = true; } return needUpdate; } #endregion Private Methods #region Protected Methods /// /// Incrementa counter redis /// 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; doUpdate(); int timerSvgInt = memLayer.ML.CRI("timerSvgInt"); timerSvgInt = timerSvgInt > 0 ? timerSvgInt : 500; timerSvg.Interval = timerSvgInt; } } /// /// Main SVG timer /// /// /// 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 } }