diff --git a/MP-SITE/BasePage.cs b/MP-SITE/BasePage.cs index 79991706..f124430c 100644 --- a/MP-SITE/BasePage.cs +++ b/MP-SITE/BasePage.cs @@ -5,18 +5,16 @@ namespace MP_SITE { public class BasePage : UserPage { + #region Internal Fields + /// /// Oggetto datalayer specifico /// internal DataLayer DataLayerObj = new DataLayer(); - public bool enableGraphJS - { - get - { - return memLayer.ML.CRB("enableGraphJS"); - } - } + #endregion Internal Fields + + #region Protected Properties /// /// Prox pagina da aprire @@ -34,6 +32,22 @@ namespace MP_SITE } } + #endregion Protected Properties + + #region Public Properties + + public bool enableGraphJS + { + get + { + return memLayer.ML.CRB("enableGraphJS"); + } + } + + #endregion Public Properties + + #region Public Methods + /// /// effettua traduzione del lemma /// @@ -53,5 +67,7 @@ namespace MP_SITE { return user_std.UtSn.TraduciEn(lemma); } + + #endregion Public Methods } } \ No newline at end of file diff --git a/MP-Site/WebUserControls/mod_sequencerStati.ascx.cs b/MP-Site/WebUserControls/mod_sequencerStati.ascx.cs index eb2769ce..13d8a9ca 100644 --- a/MP-Site/WebUserControls/mod_sequencerStati.ascx.cs +++ b/MP-Site/WebUserControls/mod_sequencerStati.ascx.cs @@ -9,6 +9,48 @@ namespace MP_SITE.WebUserControls { public partial class mod_sequencerStati : System.Web.UI.UserControl { + #region Protected Fields + + protected objSequencer _grafico; + + protected int _larghezza = 100; + + protected double _min2plot = 0.0; + + protected double _minRosso = 0.5; + + protected double _minSpento = 0.5; + + protected double _minVerde = 0.5; + + protected int _timeSplits = 10; + + protected string _titolo = "Sequencer"; + + /// + /// totale in minuti da plottare + /// + protected double totale = 1; + + #endregion Protected Fields + + #region Public Fields + + public resoconti _resoconti; + + #endregion Public Fields + + #region Public Events + + /// + /// evento di richeista zoom sui dati + /// + public event EventHandler eh_richiestaZoom; + + #endregion Public Events + + #region Public Properties + /// /// dati x grafico sequencer /// @@ -24,62 +66,198 @@ namespace MP_SITE.WebUserControls } } - public resoconti _resoconti; - protected objSequencer _grafico; - protected double _min2plot = 0.0; - protected string _titolo = "Sequencer"; - protected int _larghezza = 100; - protected int _timeSplits = 10; - /// - /// totale in minuti da plottare - /// - protected double totale = 1; - /// - /// numero dei segmenti del grafico - /// - public int numSplit { get; set; } - protected double _minVerde = 0.5; - protected double _minRosso = 0.5; - protected double _minSpento = 0.5; /// /// altezza max grafico /// public int graphHeight { get; set; } + /// /// identificativo /// public string identificativo { get; set; } - protected void Page_Load(object sender, EventArgs e) + /// + /// larghezza totale del grafico (forzo a zero come minimo...) + /// + public int larghezza { - doUpdate(); + get + { + return _larghezza; + } + set + { + if (value > 0) + { + _larghezza = value; + } + else + { + _larghezza = 0; + } + } } /// - /// disegna la tabella + /// valore minimo da plottare /// - protected void plottaGrafico() + public double min2plot { - // a seconda del numero di eventi da plottare decido la procedura... - DataLayer_generic.serieDatiDataTable dati = _grafico.serieDati; - try + get { - // è la somma dei minuti totali dall'inizio alla fine... - totale = _grafico.intervallo.fine.Subtract(_grafico.intervallo.inizio).TotalMinutes; + return _min2plot; } - catch - { } - int numCelle = dati.Rows.Count; - if (numCelle <= numSplit) // se ho eventi <= _num split.... + set { - plottaDettaglio(dati); - } - else // altrimenti raggruppo! - { - plottaGruppi(dati); + _min2plot = value; } } + /// + /// % minuma nel periodo per dire che sia rosso + /// + public double minRosso + { + get + { + return _minRosso; + } + set + { + _minRosso = value; + } + } + + /// + /// % minuma nel periodo per dire che sia spento + /// + public double minSpento + { + get + { + return _minSpento; + } + set + { + _minSpento = value; + } + } + + /// + /// % minuma nel periodo per dire che sia verde + /// + public double minVerde + { + get + { + return _minVerde; + } + set + { + _minVerde = value; + } + } + + /// + /// numero dei segmenti del grafico + /// + public int numSplit { get; set; } + + /// + /// titolo del grafico + /// + public string titolo + { + get + { + return _titolo; + } + set + { + _titolo = value; + } + } + + #endregion Public Properties + + #region Private Methods + + /// + /// accoda i dati alla serie corretta + /// + /// + /// + /// + /// + /// + /// + /// + /// + /// + private void accodaDati(ref int tipo, ref DateTime inizio, ref DateTime fine, DataLayer_generic.serieDatiRow rigaPrec, string codV, string codG, string codR, string codB, string codS) + { + switch (rigaPrec.colore) + { + case "sVe": + tipo = 1; + Chart1.Series["SeqV"].Points.AddXY(tipo, inizio, fine); + // aggiungo tooltip + Chart1.Series["SeqV"].Points[Chart1.Series["SeqV"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codV); + Chart1.Series["SeqV"].Points[Chart1.Series["SeqV"].Points.Count - 1].PostBackValue = inizio.ToString(); + break; + + case "sGi": + tipo = 1; + Chart1.Series["SeqG"].Points.AddXY(tipo, inizio, fine); + // aggiungo tooltip + Chart1.Series["SeqG"].Points[Chart1.Series["SeqG"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codG); + Chart1.Series["SeqG"].Points[Chart1.Series["SeqG"].Points.Count - 1].PostBackValue = inizio.ToString(); + break; + + case "sRo": + tipo = 1; + Chart1.Series["SeqR"].Points.AddXY(tipo, inizio, fine); + // aggiungo tooltip + Chart1.Series["SeqR"].Points[Chart1.Series["SeqR"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codR); + Chart1.Series["SeqR"].Points[Chart1.Series["SeqR"].Points.Count - 1].PostBackValue = inizio.ToString(); + break; + + case "sBl": + tipo = 1; + Chart1.Series["SeqB"].Points.AddXY(tipo, inizio, fine); + // aggiungo tooltip + Chart1.Series["SeqB"].Points[Chart1.Series["SeqB"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codR); + Chart1.Series["SeqB"].Points[Chart1.Series["SeqB"].Points.Count - 1].PostBackValue = inizio.ToString(); + break; + + case "sGr": + tipo = 1; + Chart1.Series["SeqS"].Points.AddXY(tipo, inizio, fine); + // aggiungo tooltip + Chart1.Series["SeqS"].Points[Chart1.Series["SeqS"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codS); + Chart1.Series["SeqS"].Points[Chart1.Series["SeqS"].Points.Count - 1].PostBackValue = inizio.ToString(); + break; + + default: + break; + } + } + + /// + /// intercetta richiesta di zoom e zoomma sul giorno in esame... + /// + /// + /// + private void lnkb_Click(object sender, EventArgs e) + { + LinkButton lnk = (LinkButton)sender; + // calcolo il giorno... + memLayer.ML.setSessionVal("dataZoom", lnk.CommandArgument.ToString()); + if (eh_richiestaZoom != null) + { + eh_richiestaZoom(this, new EventArgs()); + } + } /// /// popola il sequencer degli stati riportando tutti i singoli valori @@ -177,77 +355,7 @@ namespace MP_SITE.WebUserControls fine = rigaPrec.timeData.AddMinutes(rigaPrec.valore); accodaDati(ref tipo, ref inizio, ref fine, rigaPrec, codV, codG, codR, codB, codS); } - /// - /// accoda i dati alla serie corretta - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - private void accodaDati(ref int tipo, ref DateTime inizio, ref DateTime fine, DataLayer_generic.serieDatiRow rigaPrec, string codV, string codG, string codR, string codB, string codS) - { - switch (rigaPrec.colore) - { - case "sVe": - tipo = 1; - Chart1.Series["SeqV"].Points.AddXY(tipo, inizio, fine); - // aggiungo tooltip - Chart1.Series["SeqV"].Points[Chart1.Series["SeqV"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codV); - Chart1.Series["SeqV"].Points[Chart1.Series["SeqV"].Points.Count - 1].PostBackValue = inizio.ToString(); - break; - case "sGi": - tipo = 1; - Chart1.Series["SeqG"].Points.AddXY(tipo, inizio, fine); - // aggiungo tooltip - Chart1.Series["SeqG"].Points[Chart1.Series["SeqG"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codG); - Chart1.Series["SeqG"].Points[Chart1.Series["SeqG"].Points.Count - 1].PostBackValue = inizio.ToString(); - break; - case "sRo": - tipo = 1; - Chart1.Series["SeqR"].Points.AddXY(tipo, inizio, fine); - // aggiungo tooltip - Chart1.Series["SeqR"].Points[Chart1.Series["SeqR"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codR); - Chart1.Series["SeqR"].Points[Chart1.Series["SeqR"].Points.Count - 1].PostBackValue = inizio.ToString(); - break; - case "sBl": - tipo = 1; - Chart1.Series["SeqB"].Points.AddXY(tipo, inizio, fine); - // aggiungo tooltip - Chart1.Series["SeqB"].Points[Chart1.Series["SeqB"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codR); - Chart1.Series["SeqB"].Points[Chart1.Series["SeqB"].Points.Count - 1].PostBackValue = inizio.ToString(); - break; - case "sGr": - tipo = 1; - Chart1.Series["SeqS"].Points.AddXY(tipo, inizio, fine); - // aggiungo tooltip - Chart1.Series["SeqS"].Points[Chart1.Series["SeqS"].Points.Count - 1].ToolTip = string.Format("{2} | {0:dd/MM HH:mm:ss} -->{1:dd/MM HH:mm:ss}", inizio, fine, codS); - Chart1.Series["SeqS"].Points[Chart1.Series["SeqS"].Points.Count - 1].PostBackValue = inizio.ToString(); - break; - default: - break; - } - } - /// - /// intercetta richiesta di zoom e zoomma sul giorno in esame... - /// - /// - /// - void lnkb_Click(object sender, EventArgs e) - { - LinkButton lnk = (LinkButton)sender; - // calcolo il giorno... - memLayer.ML.setSessionVal("dataZoom", lnk.CommandArgument.ToString()); - if (eh_richiestaZoom != null) - { - eh_richiestaZoom(this, new EventArgs()); - } - } /// /// popola il sequencer degli stati raggruppando perché troppi valori /// @@ -256,7 +364,7 @@ namespace MP_SITE.WebUserControls private void plottaGruppi(DataLayer_generic.serieDatiDataTable dati) { DataLayer_generic.serieDatiDataTable datiGrouped = new DataLayer_generic.serieDatiDataTable(); - // verifico se ho i dati in cache REDIS... + // verifico se ho i dati in cache REDIS... double numGG = _grafico.intervallo.fine.Subtract(_grafico.intervallo.inizio).TotalDays; logger.lg.scriviLog(string.Format("Richiesta dati legacySeq GROUPED per {0} {1} gg", _grafico.idxMacchina, numGG)); string rKey = DataLayer.mHash(string.Format("legacySeq:spl_{0}:mac_{1}_{2}_{3}", numSplit, _grafico.idxMacchina, _grafico.intervallo.inizio.ToString("yyyyMMdd_HHmmss"), _grafico.intervallo.fine.ToString("yyyyMMdd_HHmmss")).Replace(" ", "_")); @@ -268,7 +376,7 @@ namespace MP_SITE.WebUserControls try { needRecalc = false; - // deserializzo + // deserializzo datiGrouped = JsonConvert.DeserializeObject(redJson); logger.lg.scriviLog("Recuperato " + rKey); } @@ -310,15 +418,19 @@ namespace MP_SITE.WebUserControls case "sVe": valV = valV + riga.valore; break; + case "sGi": valG = valG + riga.valore; break; + case "sRo": valR = valR + riga.valore; break; + case "sBl": valB = valB + riga.valore; break; + case "sGr": valS = valS + riga.valore; break; @@ -364,7 +476,7 @@ namespace MP_SITE.WebUserControls } //registro fine logger.lg.scriviLog(string.Format("FINE calcolo dati per {0} {1}", _grafico.idxMacchina, rKey)); - // salvo sequenza in REDIS... + // salvo sequenza in REDIS... string rData = JsonConvert.SerializeObject(datiGrouped); // salvo in sessione l'oggetto... secondo durata impostata in web.config.. moltiplicata x numero gg... memLayer.ML.setRSV(rKey, rData, 60 * memLayer.ML.CRI("seqCacheDurMin") * (int)numGG); @@ -373,6 +485,30 @@ namespace MP_SITE.WebUserControls plottaDettaglio(datiGrouped); } + #endregion Private Methods + + #region Protected Methods + + /// + /// evento click su sequencer: zoom 2X + /// + /// + /// + protected void Chart1_Click(object sender, ImageMapEventArgs e) + { + // alzo evento + if (eh_richiestaZoom != null) + { + if (e != null) + { + ImageMapEventArgs evIM = e; + // salvo in sessione + memLayer.ML.setSessionVal("zoomCenter", e.PostBackValue); + eh_richiestaZoom(this, new EventArgs()); + } + } + } + /// /// restituisce true se ci sono dati... /// @@ -393,97 +529,40 @@ namespace MP_SITE.WebUserControls return answ; } - /// - /// valore minimo da plottare - /// - public double min2plot + protected void Page_Load(object sender, EventArgs e) { - get + doUpdate(); + } + + /// + /// disegna la tabella + /// + protected void plottaGrafico() + { + // a seconda del numero di eventi da plottare decido la procedura... + DataLayer_generic.serieDatiDataTable dati = _grafico.serieDati; + try { - return _min2plot; + // è la somma dei minuti totali dall'inizio alla fine... + totale = _grafico.intervallo.fine.Subtract(_grafico.intervallo.inizio).TotalMinutes; } - set + catch + { } + int numCelle = dati.Rows.Count; + if (numCelle <= numSplit) // se ho eventi <= _num split.... { - _min2plot = value; - } - } - /// - /// titolo del grafico - /// - public string titolo - { - get - { - return _titolo; - } - set - { - _titolo = value; - } - } - /// - /// larghezza totale del grafico (forzo a zero come minimo...) - /// - public int larghezza - { - get - { - return _larghezza; - } - set - { - if (value > 0) - { - _larghezza = value; - } - else - { - _larghezza = 0; - } - } - } - /// - /// % minuma nel periodo per dire che sia verde - /// - public double minVerde - { - get - { - return _minVerde; - } - set - { - _minVerde = value; - } - } - /// - /// % minuma nel periodo per dire che sia rosso - /// - public double minRosso - { - get - { - return _minRosso; - } - set - { - _minRosso = value; - } - } - /// - /// % minuma nel periodo per dire che sia spento - /// - public double minSpento - { - get - { - return _minSpento; - } - set - { - _minSpento = value; + plottaDettaglio(dati); + } + else // altrimenti raggruppo! + { + plottaGruppi(dati); } } + + #endregion Protected Methods + + #region Public Methods + /// /// aggiorna il controllo /// @@ -499,31 +578,6 @@ namespace MP_SITE.WebUserControls } } - - /// - /// evento di richeista zoom sui dati - /// - public event EventHandler eh_richiestaZoom; - /// - /// evento click su sequencer: zoom 2X - /// - /// - /// - protected void Chart1_Click(object sender, ImageMapEventArgs e) - { - // alzo evento - if (eh_richiestaZoom != null) - { - if (e != null) - { - ImageMapEventArgs evIM = e; - // salvo in sessione - memLayer.ML.setSessionVal("zoomCenter", e.PostBackValue); - eh_richiestaZoom(this, new EventArgs()); - } - } - } - - + #endregion Public Methods } } \ No newline at end of file