Update gestione separata 3 timers x pagina unload (pesante):

timerCss
timerStatus
timerUnload
This commit is contained in:
Samuele Locatelli
2024-06-13 19:07:15 +02:00
parent 721ddaae22
commit 601b3937f9
11 changed files with 267 additions and 175 deletions
+2 -1
View File
@@ -8,10 +8,11 @@
<asp:HiddenField ID="hfFilename" runat="server" Value="" />
<asp:HiddenField ID="hfCurrRev" runat="server" Value="0" />
<asp:HiddenField ID="hfCurrBunkRev" runat="server" Value="0" />
<asp:HiddenField ID="hfTimerCss" runat="server" Value="1000" />
<script type="text/javascript">
lastVal = 0;
my_function();
setInterval("my_function();", 1000);
setInterval("my_function();", <%=hfTimerCss.Value%>);
function my_function() {
BunkId = document.getElementById('<%=hfBatchId.ClientID%>').value;
SheetId = document.getElementById('<%=hfSheetId.ClientID%>').value;
@@ -48,6 +48,27 @@ namespace NKC_WF.WebUserControls
return answ;
}
}
/// <summary>
/// Timer rilettura css in ms...
/// </summary>
public int TimerCss
{
set
{
if (hfTimerCss.Value != value.ToString())
{
hfTimerCss.Value = value.ToString();
}
}
get
{
int answ = 0;
int.TryParse(hfTimerCss.Value, out answ);
return answ;
}
}
/// <summary>
/// Percorso file calcolato
/// </summary>
@@ -100,7 +121,14 @@ namespace NKC_WF.WebUserControls
{
// scrivo valore revisione batch!
hfCurrBunkRev.Value = ComLib.getSheetRevByBunk(BatchId).ToString();
fixTimer();
}
}
private void fixTimer()
{
int timerCss = memLayer.ML.CRI("timerCss");
TimerCss = timerCss > 0 ? timerCss : 500;
}
}
}
+65 -56
View File
@@ -1,71 +1,80 @@
//------------------------------------------------------------------------------
// <generato automaticamente>
// Codice generato da uno strumento.
// <auto-generated>
// This code was generated by a tool.
//
// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se
// il codice viene rigenerato.
// </generato automaticamente>
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace NKC_WF.WebUserControls
{
public partial class cmp_MU_svgViewer
{
public partial class cmp_MU_svgViewer
{
/// <summary>
/// Controllo hfBatchId.
/// </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.WebControls.HiddenField hfBatchId;
/// <summary>
/// hfBatchId control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField hfBatchId;
/// <summary>
/// Controllo hfSheetId.
/// </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.WebControls.HiddenField hfSheetId;
/// <summary>
/// hfSheetId control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField hfSheetId;
/// <summary>
/// Controllo hfFilename.
/// </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.WebControls.HiddenField hfFilename;
/// <summary>
/// hfFilename control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField hfFilename;
/// <summary>
/// Controllo hfCurrRev.
/// </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.WebControls.HiddenField hfCurrRev;
/// <summary>
/// hfCurrRev control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField hfCurrRev;
/// <summary>
/// Controllo hfCurrBunkRev.
/// </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.WebControls.HiddenField hfCurrBunkRev;
/// <summary>
/// hfCurrBunkRev control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField hfCurrBunkRev;
/// <summary>
/// Controllo svgTable.
/// </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.HtmlControls.HtmlGenericControl svgTable;
}
/// <summary>
/// hfTimerCss control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HiddenField hfTimerCss;
/// <summary>
/// svgTable control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlGenericControl svgTable;
}
}
+13 -8
View File
@@ -14,20 +14,25 @@
<asp:HiddenField runat="server" ID="hfCss03" Value="secondary" />
<div class="row" runat="server" id="divSelect">
<asp:DropDownList runat="server" ID="ddlMachine" CssClass="form-control" AutoPostBack="True" OnSelectedIndexChanged="ddlMachine_SelectedIndexChanged">
<asp:ListItem Text="-- PLEASE SELECT ---" Value="" />
<asp:ListItem Text="NE01" Value="NE01" />
<asp:ListItem Text="NE02" Value="NE02" />
<asp:ListItem Text="NE03" Value="NE03" />
</asp:DropDownList>
<div class="col-12">
<asp:DropDownList runat="server" ID="ddlMachine" CssClass="form-control" AutoPostBack="True" OnSelectedIndexChanged="ddlMachine_SelectedIndexChanged">
<asp:ListItem Text="-- PLEASE SELECT ---" Value="" />
<asp:ListItem Text="NE01" Value="NE01" />
<asp:ListItem Text="NE02" Value="NE02" />
<asp:ListItem Text="NE03" Value="NE03" />
</asp:DropDownList>
</div>
</div>
<asp:UpdatePanel runat="server" ID="upnlTitle" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="timerLoad" runat="server" Interval="2000" OnTick="timerLoad_Tick"></asp:Timer>
<asp:Timer ID="timerLoad" runat="server" OnTick="timerLoad_Tick"></asp:Timer>
<div class="row small py-0" runat="server" id="divRuntime">
<div class="col-2 pr-0">
<asp:LinkButton runat="server" ID="lbtReset" class="btn btn-info btn-block text-center" OnClick="lbtReset_Click"><i class="fa fa-refresh" aria-hidden="true"></i>&nbsp;<%: hfMachine.Value %>&nbsp;<i class="fa fa-link text-success" aria-hidden="true" runat="server" id="icnLiveOk"></i> <i class="fa fa-chain-broken text-danger" aria-hidden="true" runat="server" id="icnLiveKo"></i></asp:LinkButton>
<div class="small">
<asp:Label runat="server" ID="lblUpdated" Text="---"></asp:Label>
</div>
</div>
<div class="col-10">
<div class="d-flex text-center">
@@ -50,4 +55,4 @@
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:UpdatePanel>
+113 -91
View File
@@ -9,7 +9,7 @@ using System.Web.UI.WebControls;
namespace NKC_WF.WebUserControls
{
public partial class cmp_MachSem : BaseUserControl
public partial class cmp_MachSem : BaseUserControl, IDisposable
{
#region Public Properties
@@ -67,9 +67,110 @@ namespace NKC_WF.WebUserControls
}
}
#endregion Public Properties
#region Public Methods
public override void Dispose()
{
timerLoad.Tick -= timerLoad_Tick;
timerLoad.Dispose();
base.Dispose();
}
public void doUpdate()
{
lblUpdated.Text = $"upd: {DateTime.Now:HH:mm:ss}";
// verifico status delle 3 parti e mostro relativo semaforo...
hfCode01.Value = "00";
hfCss01.Value = "secondary";
hfStat01.Value = "UNKNOWN";
hfCode02.Value = "00";
hfCss02.Value = "secondary";
hfStat02.Value = "UNKNOWN";
hfCode03.Value = "00";
hfCss03.Value = "secondary";
hfStat03.Value = "UNKNOWN";
if (!string.IsNullOrEmpty(currMachine))
{
// leggo da redis lo status
var currState = ComLib.prodMachStateDataGet(currMachine);
// traduco!
DS_App.StatusDecodeRow state01 = getState(currState, "PRINTER");
if (state01 != null)
{
hfCode01.Value = state01.Code;
hfCss01.Value = state01.Css;
hfStat01.Value = state01.Descript;
}
DS_App.StatusDecodeRow state02 = getState(currState, "NC_MACHINE");
if (state02 != null)
{
hfCode02.Value = state02.Code;
hfCss02.Value = state02.Css;
hfStat02.Value = state02.Descript;
}
DS_App.StatusDecodeRow state03 = getState(currState, "UNLOADER");
if (state03 != null)
{
hfCode03.Value = state03.Code;
hfCss03.Value = state03.Css;
hfStat03.Value = state03.Descript;
}
icnLiveOk.Visible = false;
icnLiveKo.Visible = false;
if (ComLib.getMachLiveStatus(currMachine))
{
icnLiveOk.Visible = true;
}
else
{
icnLiveKo.Visible = true;
}
}
//upnlTitle.Update();
}
#endregion Public Methods
#region Protected Methods
protected void ddlMachine_SelectedIndexChanged(object sender, EventArgs e)
{
currMachine = ddlMachine.SelectedValue;
}
protected void lbtReset_Click(object sender, EventArgs e)
{
Response.Redirect(currPage);
}
protected void Page_Load(object sender, EventArgs e)
{
hfMachine.Value = currMachine;
checkVisibility();
lbtReset.DataBind();
if (!Page.IsPostBack)
{
setTimer();
doUpdate();
}
}
protected void timerLoad_Tick(object sender, EventArgs e)
{
doUpdate();
}
#endregion Protected Methods
#region Private Methods
private void checkVisibility()
@@ -107,95 +208,16 @@ namespace NKC_WF.WebUserControls
return thisState;
}
/// <summary>
/// imposta il tempo di scadenza del timer x il refresh del componente
/// </summary>
private void setTimer()
{
int timer = memLayer.ML.CRI("timerStatus");
timer = timer > 0 ? timer : 5000;
timerLoad.Interval = timer;
}
#endregion Private Methods
#region Protected Methods
protected void ddlMachine_SelectedIndexChanged(object sender, EventArgs e)
{
currMachine = ddlMachine.SelectedValue;
}
protected void lbtReset_Click(object sender, EventArgs e)
{
Response.Redirect(currPage);
}
protected void Page_Load(object sender, EventArgs e)
{
hfMachine.Value = currMachine;
checkVisibility();
lbtReset.DataBind();
if (!Page.IsPostBack)
{
//// timer base x 1.5
//timerLoad.Interval = memLayer.ML.confReadInt("intUpdatePagina_ms") * 15 / 10;
doUpdate();
}
}
protected void timerLoad_Tick(object sender, EventArgs e)
{
doUpdate();
}
#endregion Protected Methods
#region Public Methods
public void doUpdate()
{
// verifico status delle 3 parti e mostro relativo semaforo...
hfCode01.Value = "00";
hfCss01.Value = "secondary";
hfStat01.Value = "UNKNOWN";
hfCode02.Value = "00";
hfCss02.Value = "secondary";
hfStat02.Value = "UNKNOWN";
hfCode03.Value = "00";
hfCss03.Value = "secondary";
hfStat03.Value = "UNKNOWN";
// leggo da redis lo status
var currState = ComLib.prodMachStateDataGet(currMachine);
// traduco!
DS_App.StatusDecodeRow state01 = getState(currState, "PRINTER");
if (state01 != null)
{
hfCode01.Value = state01.Code;
hfCss01.Value = state01.Css;
hfStat01.Value = state01.Descript;
}
DS_App.StatusDecodeRow state02 = getState(currState, "NC_MACHINE");
if (state02 != null)
{
hfCode02.Value = state02.Code;
hfCss02.Value = state02.Css;
hfStat02.Value = state02.Descript;
}
DS_App.StatusDecodeRow state03 = getState(currState, "UNLOADER");
if (state03 != null)
{
hfCode03.Value = state03.Code;
hfCss03.Value = state03.Css;
hfStat03.Value = state03.Descript;
}
icnLiveOk.Visible = false;
icnLiveKo.Visible = false;
if (ComLib.getMachLiveStatus(currMachine))
{
icnLiveOk.Visible = true;
}
else
{
icnLiveKo.Visible = true;
}
}
#endregion Public Methods
}
}
+9
View File
@@ -193,5 +193,14 @@ namespace NKC_WF.WebUserControls
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.HtmlControls.HtmlGenericControl icnLiveKo;
/// <summary>
/// lblUpdated control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.Label lblUpdated;
}
}
+3 -3
View File
@@ -1,7 +1,7 @@
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="cmp_footer.ascx.cs" Inherits="NKC_WF.WebUserControls.cmp_footer" %>
<footer class="fixed-bottom bg-dark text-light small textCondens p-1">
<div class="container-flow px-1">
<asp:UpdatePanel runat="server" ID="upnlFooter" UpdateMode="Conditional">
<asp:UpdatePanel runat="server" ID="upnlFooter" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<div class="d-flex justify-content-between">
<div class="px-1">
@@ -16,7 +16,7 @@
<asp:Label runat="server" ID="lblApp" Text="." />
</div>
<div class="px-1">
<asp:UpdateProgress ID="UpdateProgressDisplay" runat="server" DisplayAfter="10">
<asp:UpdateProgress ID="UpdateProgressDisplay" runat="server" DisplayAfter="5">
<ProgressTemplate>
<i class="fa fa-circle-o-notch fa-spin fa-fw text-primary" aria-hidden="true"></i>
<i class="fa fa-circle-o-notch fa-spin fa-fw text-info" aria-hidden="true"></i>
@@ -27,7 +27,7 @@
</div>
</div>
</div>
<asp:Timer ID="Timer1" runat="server" Interval="60000">
<asp:Timer ID="Timer1" runat="server" Interval="1000" OnTick="Timer1_Tick">
</asp:Timer>
</ContentTemplate>
</asp:UpdatePanel>
+4 -2
View File
@@ -26,8 +26,10 @@ namespace NKC_WF.WebUserControls
/// </summary>
private void setTimer()
{
Timer1.Tick += Timer1_Tick;
Timer1.Interval = memLayer.ML.confReadInt("intUpdatePagina_ms");
//Timer1.Tick += Timer1_Tick;
int intUpdatePagina_ms = memLayer.ML.confReadInt("intUpdatePagina_ms");
//intUpdatePagina_ms = intUpdatePagina_ms > 10000 ? 10000 : intUpdatePagina_ms;
Timer1.Interval = intUpdatePagina_ms;
}
#endregion Private Methods
+1 -1
View File
@@ -43,6 +43,7 @@
<div class="col-8 py-0 my-0 px-0">
<asp:UpdatePanel runat="server" ID="upnlDrawings" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="timerSvg" runat="server" OnTick="timerSvg_Tick"></asp:Timer>
<uc1:cmp_MU_svgViewer runat="server" ID="cmp_MU_svgViewer" />
</ContentTemplate>
</asp:UpdatePanel>
@@ -50,7 +51,6 @@
<div class="col-2 pl-0">
<asp:UpdatePanel runat="server" ID="upnlCarts" UpdateMode="Conditional">
<ContentTemplate>
<asp:Timer ID="timerSvg" runat="server" Interval="500" OnTick="timerSvg_Tick"></asp:Timer>
<uc1:cmp_MU_carts runat="server" ID="cmp_MU_carts" />
</ContentTemplate>
</asp:UpdatePanel>
+20 -4
View File
@@ -4,7 +4,7 @@ using System;
namespace NKC_WF
{
public partial class MachineUnload : BasePage
public partial class MachineUnload : BasePage, IDisposable
{
#region Protected Properties
@@ -240,13 +240,29 @@ namespace NKC_WF
if (!Page.IsPostBack)
{
((SiteMaster)this.Master).showSearch = false;
setTimer();
doUpdate();
int timerSvgInt = memLayer.ML.CRI("timerSvgInt");
timerSvgInt = timerSvgInt > 0 ? timerSvgInt : 500;
timerSvg.Interval = timerSvgInt;
}
}
/// <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;
}
public override void Dispose()
{
timerSvg.Tick -= timerSvg_Tick;
timerSvg.Dispose();
base.Dispose();
}
/// <summary>
/// Main SVG timer
/// </summary>
+9 -9
View File
@@ -113,6 +113,15 @@ namespace NKC_WF
/// </remarks>
protected global::System.Web.UI.UpdatePanel upnlDrawings;
/// <summary>
/// timerSvg control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.Timer timerSvg;
/// <summary>
/// cmp_MU_svgViewer control.
/// </summary>
@@ -131,15 +140,6 @@ namespace NKC_WF
/// </remarks>
protected global::System.Web.UI.UpdatePanel upnlCarts;
/// <summary>
/// timerSvg control.
/// </summary>
/// <remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.Timer timerSvg;
/// <summary>
/// cmp_MU_carts control.
/// </summary>