Update x gestioen reset TabInCache a tempo

This commit is contained in:
Samuele Locatelli
2024-09-03 11:44:40 +02:00
parent d9d4af59fc
commit 08b67c9784
7 changed files with 298 additions and 159 deletions
+78 -45
View File
@@ -1,5 +1,6 @@
using SteamWare;
using System;
using System.Collections.Generic;
using System.IO;
using System.Web;
using System.Web.UI;
@@ -8,30 +9,8 @@ namespace MP_SITE
{
public class BaseExportPage : System.Web.UI.Page
{
protected resoconti _resoconti;
#region Public Properties
/// <summary>
/// idx della macchina da mostrare
/// </summary>
public string idxMacchina
{
get
{
string idxMacchina = "0";
try
{
idxMacchina = memLayer.ML.StringSessionObj("IdxMacchina");
}
catch
{
}
return idxMacchina;
}
set
{
memLayer.ML.setSessionVal("IdxMacchina", value);
}
}
/// <summary>
/// inizio periodo da mostrare
/// </summary>
@@ -76,6 +55,45 @@ namespace MP_SITE
}
}
/// <summary>
/// idx della macchina da mostrare
/// </summary>
public string idxMacchina
{
get
{
string idxMacchina = "0";
try
{
idxMacchina = memLayer.ML.StringSessionObj("IdxMacchina");
}
catch
{
}
return idxMacchina;
}
set
{
memLayer.ML.setSessionVal("IdxMacchina", value);
}
}
#endregion Public Properties
#region Public Methods
/// <summary>
/// Recupera commessa al momento indicato
/// </summary>
/// <param name="_dtRif"></param>
/// <returns></returns>
public string commessaCorr(object _dtRif)
{
DateTime dtRif = DateTime.Now;
DateTime.TryParse($"{_dtRif}", out dtRif);
return _resoconti.commessaAttiva(idxMacchina, dtFrom, dtTo, dtRif);
}
/// <summary>
/// restituisce stringa formattata in HH:mm
/// </summary>
@@ -104,27 +122,24 @@ namespace MP_SITE
public string operatoreDaMatr(object matricola)
{
int matr = 0;
if (matricola != null)
string answ = "N.A.";
try
{
try
{
matr = Convert.ToInt32(matricola);
}
catch
{ }
matr = Convert.ToInt32(matricola);
}
return _resoconti.oprDaMatr(matr);
}
/// <summary>
/// Recupera commessa al momento indicato
/// </summary>
/// <param name="_dtRif"></param>
/// <returns></returns>
public string commessaCorr(object _dtRif)
{
DateTime dtRif = DateTime.Now;
DateTime.TryParse($"{_dtRif}", out dtRif);
return _resoconti.commessaAttiva(idxMacchina, dtFrom, dtTo, dtRif);
catch
{ }
// cerco in LUT...
if (OprLUT.ContainsKey(matr))
{
answ = OprLUT[matr];
}
else
{
answ = _resoconti.oprDaMatr(matr);
OprLUT.Add(matr, answ);
}
return answ;
}
public string statoDaIdx(object idx)
@@ -139,9 +154,14 @@ namespace MP_SITE
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
// Confirms that an HtmlForm control is rendered for the specified ASP.NET server
// control at run time.
}
#endregion Public Methods
#region Internal Methods
internal virtual void aggiornamento()
{
}
@@ -170,14 +190,25 @@ namespace MP_SITE
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=DatiConfermati.xls");
Response.Charset = "";
// If you want the option to open the Excel file without saving than
// comment out the line below
// If you want the option to open the Excel file without saving than comment out the
// line below
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
stringWrite = new StringWriter();
htmlWrite = new HtmlTextWriter(stringWrite);
}
#endregion Internal Methods
#region Protected Fields
protected resoconti _resoconti;
protected Dictionary<int, string> OprLUT = new Dictionary<int, string>();
#endregion Protected Fields
#region Protected Methods
protected void Page_Load(object sender, EventArgs e)
{
_resoconti = new resoconti();
@@ -187,5 +218,7 @@ namespace MP_SITE
doExport();
}
}
#endregion Protected Methods
}
}
+47
View File
@@ -1,5 +1,7 @@
using MapoDb;
using SteamWare;
using System;
using System.Collections.Generic;
using System.Web.UI;
namespace MP_SITE
@@ -144,6 +146,17 @@ namespace MP_SITE
{
chkHideSpenta.DataBind();
graphDataRefresh = true;
// controllo se devo ricaricare i valori in cache redis...
string rKey = DataLayer.mHash($"VETO:ReloadTabInCache");
var vetoRefresh = memLayer.ML.getRSV(rKey);
if(string.IsNullOrEmpty(vetoRefresh))
{
// metto veto
int ttlReload = memLayer.ML.CRI("SITE_ForceReloadCache");
memLayer.ML.setRSV(rKey, $"Veto Reload TabInCache until: {DateTime.Now.AddSeconds(ttlReload): HH:mm:ss}", ttlReload);
// chiamo refresh tab in cache...
refreshTabInCache();
}
}
Mod_periodoAnalisi1.eh_doUpdate += new EventHandler(Mod_periodoAnalisi1_eh_doUpdate);
Mod_listaStatiEventi1.eh_doUpdate += new EventHandler(Mod_listaStatiEventi1_eh_doUpdate);
@@ -157,6 +170,40 @@ namespace MP_SITE
impostaGrafici();
}
private void refreshTabInCache()
{
#if false
// salvo i dati attuali...
string cod_cdc = SteamWare.memLayer.ML.StringSessionObj("valRicercaCdC");
string lingua = user_std.UtSn.lingua;
string USER_NAME = SteamWare.memLayer.ML.StringSessionObj("USER_NAME");
string DOMINIO = SteamWare.memLayer.ML.StringSessionObj("DOMINIO");
bool isForceUser = user_std.UtSn.isForcedUser;
// salvo i valori delle tab in session...
Dictionary<string, string> sessionParam = SteamWare.memLayer.ML.valSess2SurvUpd;
// svuoto session e cache per rileggere i dati da Db
Session.RemoveAll();
#endif
SteamWare.memLayer.ML.flushRegisteredCache();
#if false
// rimemorizzo
SteamWare.memLayer.ML.setSessionVal("valRicercaCdC", cod_cdc);
user_std.UtSn.startUpUtente(DOMINIO, USER_NAME);
user_std.UtSn.lingua = lingua;
user_std.UtSn.isForcedUser = isForceUser;
DataWrap.DW.resetVocabolario();
// risalvo in session i valori...
foreach (KeyValuePair<string, string> kvp in sessionParam)
{
SteamWare.memLayer.ML.setSessionVal(kvp.Key, kvp.Value, true);
}
#endif
}
protected void setSequencer()
{
// procedo SOLO SE ho dei dati...
+61 -31
View File
@@ -9,15 +9,6 @@ namespace MP_SITE.WebUserControls
{
public class baseUserControl : System.Web.UI.UserControl
{
#region Private Fields
/// <summary>
/// Oggetto datalayer specifico
/// </summary>
private DataLayer DataLayerObj = new DataLayer();
#endregion Private Fields
#region Public Properties
public string cognomeNome
@@ -62,30 +53,31 @@ namespace MP_SITE.WebUserControls
#endregion Public Properties
#region Protected Methods
protected virtual void doTranslate()
{
}
/// <summary>
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
/// </summary>
/// <param name="idxMacchina"></param>
/// <returns></returns>
protected bool isMulti(string idxMacchina)
{
return DataLayerObj.isMulti(idxMacchina);
}
protected virtual void Page_Load(object sender, EventArgs e)
{
}
#endregion Protected Methods
#region Public Methods
public string operatoreDaMatr(object matricola)
{
int matr = 0;
string answ = "N.A.";
try
{
matr = Convert.ToInt32(matricola);
}
catch
{ }
// cerco in LUT...
if (OprLUT.ContainsKey(matr))
{
answ = OprLUT[matr];
}
else
{
answ = _resoconti.oprDaMatr(matr);
OprLUT.Add(matr, answ);
}
return answ;
}
/// <summary>
/// effettua traduzione del lemma
/// </summary>
@@ -108,6 +100,33 @@ namespace MP_SITE.WebUserControls
#endregion Public Methods
#region Protected Fields
protected resoconti _resoconti = new resoconti();
protected Dictionary<int, string> OprLUT = new Dictionary<int, string>();
#endregion Protected Fields
#region Protected Methods
protected virtual void doTranslate()
{
}
/// <summary>
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
/// </summary>
/// <param name="idxMacchina"></param>
/// <returns></returns>
protected bool isMulti(string idxMacchina)
{
return DataLayerObj.isMulti(idxMacchina);
}
protected virtual void Page_Load(object sender, EventArgs e)
{
}
/// <summary>
/// Arrotondamento oggetto datetime all'intervallo timespan indicato
@@ -119,5 +138,16 @@ namespace MP_SITE.WebUserControls
{
return new DateTime((dt.Ticks + d.Ticks - 1) / d.Ticks * d.Ticks, dt.Kind);
}
#endregion Protected Methods
#region Private Fields
/// <summary>
/// Oggetto datalayer specifico
/// </summary>
private DataLayer DataLayerObj = new DataLayer();
#endregion Private Fields
}
}
+81 -56
View File
@@ -1,28 +1,12 @@
using MapoDb;
using SteamWare;
using System;
using System.Collections.Generic;
namespace MP_SITE.WebUserControls
{
public class baseProdControl : System.Web.UI.UserControl
{
#region Private Fields
/// <summary>
/// Oggetto datalayer specifico
/// </summary>
internal DataLayer DataLayerObj = new DataLayer();
#endregion Private Fields
#region Protected Fields
protected int _numRighe = 17;
protected resoconti _resoconti;
#endregion Protected Fields
#region Public Events
/// <summary>
@@ -48,35 +32,56 @@ namespace MP_SITE.WebUserControls
#endregion Public Properties
#region Protected Methods
/// <summary>
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
/// </summary>
/// <param name="idxMacchina"></param>
/// <returns></returns>
protected bool isMulti(string idxMacchina)
{
return DataLayerObj.isMulti(idxMacchina);
}
protected virtual void Page_Load(object sender, EventArgs e)
{
_resoconti = new resoconti();
if (!Page.IsPostBack)
{
doUpdate();
}
}
#endregion Protected Methods
#region Public Methods
public virtual void doUpdate()
{
}
/// <summary>
/// Conversione a bool del valore
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public bool getBool(object value)
{
bool answ = false;
string rawVal = $"{value}".ToUpper();
// se è 1/0 --> len 1
if (rawVal.Length == 1)
{
answ = rawVal == "1" || rawVal == "S" || rawVal == "Y";
}
else
{
bool.TryParse($"{value}", out answ);
}
return answ;
}
public string operatoreDaMatr(object matricola)
{
int matr = 0;
string answ = "N.A.";
try
{
matr = Convert.ToInt32(matricola);
}
catch
{ }
// cerco in LUT...
if (OprLUT.ContainsKey(matr))
{
answ = OprLUT[matr];
}
else
{
answ = _resoconti.oprDaMatr(matr);
OprLUT.Add(matr, answ);
}
return answ;
}
public void reportUpdate()
{
// alzo l'evento d update/inserimento e ricarico cache...
@@ -106,27 +111,47 @@ namespace MP_SITE.WebUserControls
return user_std.UtSn.TraduciEn(lemma);
}
#endregion Public Methods
#region Internal Fields
/// <summary>
/// Conversione a bool del valore
/// Oggetto datalayer specifico
/// </summary>
/// <param name="value"></param>
internal DataLayer DataLayerObj = new DataLayer();
#endregion Internal Fields
#region Protected Fields
protected int _numRighe = 17;
protected resoconti _resoconti;
protected Dictionary<int, string> OprLUT = new Dictionary<int, string>();
#endregion Protected Fields
#region Protected Methods
/// <summary>
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
/// </summary>
/// <param name="idxMacchina"></param>
/// <returns></returns>
public bool getBool(object value)
protected bool isMulti(string idxMacchina)
{
bool answ = false;
string rawVal = $"{value}".ToUpper();
// se è 1/0 --> len 1
if (rawVal.Length == 1)
{
answ = rawVal == "1" || rawVal == "S" || rawVal == "Y";
}
else
{
bool.TryParse($"{value}", out answ);
}
return answ;
return DataLayerObj.isMulti(idxMacchina);
}
#endregion Public Methods
protected virtual void Page_Load(object sender, EventArgs e)
{
_resoconti = new resoconti();
if (!Page.IsPostBack)
{
doUpdate();
}
}
#endregion Protected Methods
}
}
@@ -90,6 +90,7 @@ namespace MP_SITE.WebUserControls
return utility.durataEventoHMS((double)durataMinuti);
}
#if false
public string operatoreDaMatr(object matricola)
{
int matr = 0;
@@ -113,7 +114,8 @@ namespace MP_SITE.WebUserControls
return answ;
}
protected Dictionary<int, string> OprLUT = new Dictionary<int, string>();
protected Dictionary<int, string> OprLUT = new Dictionary<int, string>();
#endif
public void reportUpdt(object sender, EventArgs e)
{
+1 -1
View File
@@ -24,7 +24,7 @@
<asp:BoundField DataField="pallet" HeaderText="pallet" SortExpression="pallet" Visible="False" />
<asp:TemplateField HeaderText="Operatore" SortExpression="MatrOpr">
<ItemTemplate>
<asp:Label ID="lblOperatore" runat="server" Text='<%# resoconti.mngr.oprDaMatr(Convert.ToInt32(Eval("MatrOpr"))) %>' />
<asp:Label ID="lblOperatore" runat="server" Text='<%# operatoreDaMatr(Eval("MatrOpr")) %>' />
</ItemTemplate>
</asp:TemplateField>
</Columns>
+27 -25
View File
@@ -1,50 +1,52 @@
//------------------------------------------------------------------------------
// <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 MP_SITE.WebUserControls {
public partial class mod_logEventi {
namespace MP_SITE.WebUserControls
{
public partial class mod_logEventi
{
/// <summary>
/// Controllo gvView.
/// gvView control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.GridView gvView;
/// <summary>
/// Controllo ods.
/// ods control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.ObjectDataSource ods;
/// <summary>
/// Controllo HyperLink2.
/// HyperLink2 control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HyperLink HyperLink2;
/// <summary>
/// Controllo HyperLink4.
/// HyperLink4 control.
/// </summary>
/// <remarks>
/// Campo generato automaticamente.
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
/// </remarks>
protected global::System.Web.UI.WebControls.HyperLink HyperLink4;
}