164 lines
4.7 KiB
C#
164 lines
4.7 KiB
C#
using MapoDb;
|
|
using MoonPro.WebUserControls;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MoonPro
|
|
{
|
|
public partial class MappaStatoSeq : System.Web.UI.Page
|
|
{
|
|
public resoconti _resoconti;
|
|
public int numGg
|
|
{
|
|
get
|
|
{
|
|
int answ = 1;
|
|
try
|
|
{
|
|
answ = Convert.ToInt32(ddlNumgg.SelectedValue);
|
|
}
|
|
catch
|
|
{
|
|
answ = 1;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
public intervalloDate intervalloAnalisi
|
|
{
|
|
get
|
|
{
|
|
intervalloDate answ = new intervalloDate();
|
|
// 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;
|
|
}
|
|
}
|
|
protected DS_applicazione.MacchineDataTable tabMacchine;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
//_resoconti = new resoconti();
|
|
//tabMacchine = MapoDb.DataLayer.obj.taMacchine.GetData();
|
|
if (!Page.IsPostBack)
|
|
{
|
|
ddlNumgg.DataBind();
|
|
ddlNumgg.SelectedValue = memLayer.ML.confReadString("seq_gg");
|
|
// 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.confReadInt("seq_height");
|
|
sequencer.numSplit = memLayer.ML.confReadInt("seq_numSpl");
|
|
try
|
|
{
|
|
sequencer.datiSequencer = _resoconti.sequenzaDati(sequencer.identificativo, intervalloAnalisi);
|
|
sequencer.doUpdate();
|
|
sequencer.Visible = true;
|
|
}
|
|
catch
|
|
{
|
|
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)
|
|
{
|
|
mod_sequencerStatiJS2.numGG = Convert.ToInt32(ddlNumgg.SelectedValue);
|
|
}
|
|
/// <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;
|
|
Session["IdxMacchina"] = lb.CommandArgument;
|
|
Response.Redirect("~/DettaglioMacchina.aspx");
|
|
}
|
|
|
|
protected void btnReload_Click(object sender, EventArgs e)
|
|
{
|
|
mod_sequencerStatiJS2.periodo = intervalloAnalisi;
|
|
}
|
|
}
|
|
} |