248 lines
6.9 KiB
C#
248 lines
6.9 KiB
C#
using MapoDb;
|
|
using MP_SITE.WebUserControls;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MP_SITE
|
|
{
|
|
public partial class MappaStatoSeq : System.Web.UI.Page
|
|
{
|
|
|
|
public bool enableGraphJS
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRB("enableGraphJS");
|
|
}
|
|
}
|
|
|
|
public resoconti _resoconti;
|
|
/// <summary>
|
|
/// num gg selezionati
|
|
/// </summary>
|
|
public int numGg
|
|
{
|
|
get
|
|
{
|
|
int answ = memLayer.ML.CRI("seq_gg");
|
|
// cerco in sessione... se ce l'ho in sessione uso ultimo intervallo...
|
|
if (memLayer.ML.isInSessionObject("_numGgSeq"))
|
|
{
|
|
answ = memLayer.ML.IntSessionObj("_numGgSeq");
|
|
}
|
|
else
|
|
{
|
|
try
|
|
{
|
|
answ = Convert.ToInt32(ddlNumgg.SelectedValue);
|
|
}
|
|
catch
|
|
{
|
|
answ = memLayer.ML.CRI("seq_gg");
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("_numGgSeq", value);
|
|
}
|
|
}
|
|
public intervalloDate intervalloAnalisi
|
|
{
|
|
get
|
|
{
|
|
intervalloDate answ = new intervalloDate();
|
|
// se ce l'ho in sessione uso ultimo intervallo...
|
|
if (memLayer.ML.isInSessionObject("_intervalloSeq"))
|
|
{
|
|
answ = (intervalloDate)memLayer.ML.objSessionObj("_intervalloSeq");
|
|
}
|
|
else
|
|
{
|
|
// parto dalla data alla mezzanotte di oggi (passato)
|
|
DateTime finePeriodo = DateTime.Today;
|
|
// se sono meno di 64 gg --> aggiungo ore arrotondando...
|
|
if (numGg <= 64)
|
|
{
|
|
int rOre = DateTime.Now.Hour;
|
|
/*********************************************
|
|
* Regole arrotondamento x errore MAX 1%
|
|
* - < 2gg --> 15'
|
|
* - < 4gg --> 30'
|
|
* - < 8gg --> 1h
|
|
* - < 16gg --> 2h
|
|
* - < 32gg --> 4h
|
|
* - < 64gg --> 8h
|
|
*
|
|
* semplifico con switch... sino a 8gg --> 1h!
|
|
*********************************************/
|
|
if (numGg > 8)
|
|
{
|
|
int rFactor = 1;
|
|
if (numGg <= 16)
|
|
{
|
|
rFactor = 2;
|
|
}
|
|
else
|
|
{
|
|
if (numGg <= 32)
|
|
{
|
|
rFactor = 4;
|
|
}
|
|
else
|
|
{
|
|
rFactor = 8;
|
|
}
|
|
}
|
|
// ora arrotondo x difetto alle ore indicate...
|
|
rOre = (int)Math.Floor((double)rOre / rFactor) * rFactor;
|
|
}
|
|
finePeriodo = finePeriodo.AddHours(rOre);
|
|
}
|
|
answ.fine = finePeriodo;
|
|
answ.inizio = answ.fine.AddDays(-numGg);
|
|
}
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("_intervalloSeq", value);
|
|
}
|
|
}
|
|
protected DS_applicazione.MacchineDataTable tabMacchine;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
divGraphJS.Visible = enableGraphJS;
|
|
divGraphLegacy.Visible = !enableGraphJS;
|
|
if (!enableGraphJS)
|
|
{
|
|
_resoconti = new resoconti();
|
|
tabMacchine = MapoDb.DataLayer.obj.taMacchine.GetData();
|
|
}
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// se nuovo grafico...
|
|
if (enableGraphJS)
|
|
{
|
|
// imposto date di intervallo
|
|
mod_sequencerStatiJS2.periodo = intervalloAnalisi;
|
|
mod_sequencerStatiJS2.numSplit = memLayer.ML.CRS("seq_numSpl");
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
protected void repSeq_ItemDataBound(object sender, RepeaterItemEventArgs e)
|
|
{
|
|
mod_sequencerStati sequencer = (mod_sequencerStati)e.Item.FindControl("seqStato");
|
|
sequencer.larghezza = memLayer.ML.IntSessionObj("WindowWidth") - 100;
|
|
sequencer.graphHeight = memLayer.ML.CRI("seq_height");
|
|
sequencer.numSplit = memLayer.ML.CRI("seq_numSpl");
|
|
try
|
|
{
|
|
var datiSeq = _resoconti.sequenzaDati(sequencer.identificativo, intervalloAnalisi);
|
|
// SE HO dati mostro
|
|
if (datiSeq.serieDati.Count > 0)
|
|
{
|
|
sequencer.datiSequencer = datiSeq;
|
|
sequencer.doUpdate();
|
|
sequencer.Visible = true;
|
|
}
|
|
else
|
|
{
|
|
sequencer.Visible = false;
|
|
logger.lg.scriviLog(string.Format("Dati non trovati per {0}", sequencer.identificativo), tipoLog.INFO);
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Eccezione recupero dati per {0}{1}{2}", sequencer.identificativo, Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
sequencer.Visible = false;
|
|
}
|
|
}
|
|
|
|
protected void lnkCambiaModo_Click(object sender, EventArgs e)
|
|
{
|
|
// passa alla pagina richiesta...
|
|
LinkButton lb = (LinkButton)sender;
|
|
Response.Redirect(lb.CommandArgument);
|
|
}
|
|
|
|
protected void ddlNumgg_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// salvo numGG...
|
|
int num = 1;
|
|
int.TryParse(ddlNumgg.SelectedValue, out num);
|
|
numGg = num;
|
|
// refresh
|
|
if (enableGraphJS)
|
|
{
|
|
mod_sequencerStatiJS2.numGG = Convert.ToInt32(ddlNumgg.SelectedValue);
|
|
}
|
|
else
|
|
{
|
|
repSeq.DataBind();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// recupera nome macchina da idx
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public string nomeMacchina(string idxMacchina)
|
|
{
|
|
string answ = "...";
|
|
answ = tabMacchine.FindByIdxMacchina(idxMacchina).Nome;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// recupera stato macchina da idx
|
|
/// </summary>
|
|
/// <param name="idxMacchina"></param>
|
|
/// <returns></returns>
|
|
public string cssStatoMacchina(string idxMacchina)
|
|
{
|
|
string answ = "...";
|
|
string codColore = resoconti.mngr.semaforoDaIdxStato(resoconti.mngr.statoMacchina(idxMacchina));
|
|
answ = codColore;
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// rimanda alla pagina di dettaglio della macchina scelta
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lnkMacchina_Click(object sender, EventArgs e)
|
|
{
|
|
LinkButton lb = (LinkButton)sender;
|
|
memLayer.ML.setSessionVal("IdxMacchina", lb.CommandArgument);
|
|
Response.Redirect("~/DettaglioMacchina.aspx");
|
|
}
|
|
|
|
protected void lbtForceReload_Click(object sender, EventArgs e)
|
|
{
|
|
// svuota sessioni x poi ricalcolare...
|
|
string rKey = DataLayer.mHash("legacySeq*");
|
|
memLayer.ML.redFlushKey(rKey);
|
|
rKey = DataLayer.mHash("jsonSeq*");
|
|
memLayer.ML.redFlushKey(rKey);
|
|
// disegna
|
|
if (enableGraphJS)
|
|
{
|
|
mod_sequencerStatiJS2.periodo = intervalloAnalisi;
|
|
}
|
|
else
|
|
{
|
|
repSeq.DataBind();
|
|
}
|
|
}
|
|
|
|
protected void ddlNumgg_DataBound(object sender, EventArgs e)
|
|
{
|
|
ddlNumgg.SelectedValue = numGg.ToString();
|
|
}
|
|
}
|
|
} |