210 lines
5.8 KiB
C#
210 lines
5.8 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
|
|
namespace MP_SITE.WebUserControls
|
|
{
|
|
public partial class mod_semaforo : System.Web.UI.UserControl
|
|
{
|
|
|
|
/// <summary>
|
|
/// Oggetto datalayer specifico
|
|
/// </summary>
|
|
DataLayer DataLayerObj = new DataLayer();
|
|
|
|
#region area protected / private
|
|
|
|
/// <summary>
|
|
/// seriale associato alla macchina da controllare
|
|
/// </summary>
|
|
protected string _IdxMacchina;
|
|
/// <summary>
|
|
/// posizione macchina nella tabella
|
|
/// </summary>
|
|
protected string _locazione;
|
|
protected resoconti _resoconti;
|
|
|
|
protected DS_applicazione.MacchineDataTable tabMacchine;
|
|
protected DS_applicazione.StatoMacchineDataTable tabStatoMacchine;
|
|
protected DS_applicazione.AnagraficaStatiDataTable tabAnagStati;
|
|
protected DS_applicazione.KeepAliveDataTable tabKeepAlive;
|
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
updateMe();
|
|
}
|
|
/// <summary>
|
|
/// effettua traduzione del lemma
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma);
|
|
}
|
|
/// <summary>
|
|
/// sistema il testo
|
|
/// </summary>
|
|
private void updateText()
|
|
{
|
|
if (_IdxMacchina != "nd")
|
|
{
|
|
// labels
|
|
lblDurata.Text = traduci("DurataStato");
|
|
// valori
|
|
lblMacchina.Text = tabMacchine.FindByIdxMacchina(IdxMacchina).Nome;
|
|
lblCodArticolo.Text = tabStatoMacchine.FindByIdxMacchina(IdxMacchina).CodArticolo;
|
|
int matrOper = tabStatoMacchine.FindByIdxMacchina(IdxMacchina).MatrOpr;
|
|
DS_applicazione.AnagraficaOperatoriRow rigaOper = DataLayerObj.taOp.getByMatrOpr(matrOper)[0];
|
|
lblOper.Text = string.Format("{0} {1}", rigaOper.Cognome, rigaOper.Nome);
|
|
int idxStato = 0;
|
|
int oreTot = 0;
|
|
float minuti = 0;
|
|
try
|
|
{
|
|
MapoDb.DS_ProdTempi.stp_repDonati_getLastStatoDurataMacchinaRow rigaStato = DataLayerObj.taDatiStatoMacch.GetData(IdxMacchina, 0.1)[0];
|
|
idxStato = rigaStato.idxStato;
|
|
oreTot = Convert.ToInt32(Math.Floor(rigaStato.Minuti / 60));
|
|
minuti = (float)rigaStato.Minuti - 60 * oreTot;
|
|
}
|
|
catch
|
|
{
|
|
idxStato = tabStatoMacchine.FindByIdxMacchina(IdxMacchina).IdxStato;
|
|
DateTime inizioStato = tabStatoMacchine.FindByIdxMacchina(IdxMacchina).InizioStato;
|
|
DateTime ora = DateTime.Now;
|
|
TimeSpan durata = ora.Subtract(inizioStato);
|
|
oreTot = durata.Days * 24 + durata.Hours;
|
|
minuti = durata.Minutes;
|
|
}
|
|
// aggiorno stato e durata
|
|
lblStato.Text = tabAnagStati.FindByIdxStato(idxStato).Descrizione;
|
|
valDurata.Text = string.Format("{0}h {1}min", oreTot, minuti);
|
|
|
|
// solo se in stato NON di run...
|
|
if (idxStato != 13)
|
|
{
|
|
lblCausale.Text = traduci("Causale");
|
|
valCausale.Text = tabStatoMacchine.FindByIdxMacchina(IdxMacchina).Value;
|
|
}
|
|
lblDurataCiclo.Text = traduci("UltimoEvento");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// aggiorna il layout grafico
|
|
/// </summary>
|
|
private void updateLayout()
|
|
{
|
|
if (_IdxMacchina != "nd")
|
|
{
|
|
string filtro = string.Format("IdxMacchina = '{0}'", _IdxMacchina);
|
|
int stato = ((DS_applicazione.StatoMacchineRow)tabStatoMacchine.Select(filtro)[0]).IdxStato;
|
|
// in base allo stato recupero il colore...
|
|
string codColore = ((DS_applicazione.AnagraficaStatiRow)tabAnagStati.FindByIdxStato(stato)).Semaforo;
|
|
pnlMacchina.CssClass = codColore;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// metto a posto l'immagine
|
|
/// </summary>
|
|
protected void updateImg()
|
|
{
|
|
string urlMacchina;
|
|
if (_IdxMacchina != "nd")
|
|
{
|
|
urlMacchina = string.Format("~/images/macchine/thumb_{0}", _resoconti.urlMacchina(IdxMacchina));
|
|
if (urlMacchina == "thumb_")
|
|
{
|
|
urlMacchina = "~/images/empty.png";
|
|
imgThumb.ImageUrl = urlMacchina;
|
|
}
|
|
else
|
|
{
|
|
imgThumb.ImageUrl = urlMacchina;
|
|
imgThumb.ToolTip = _resoconti.nomeMacchina(IdxMacchina);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
urlMacchina = "~/images/empty.png";
|
|
imgThumb.ImageUrl = urlMacchina;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// recupera i dati
|
|
/// </summary>
|
|
private void retrieveData()
|
|
{
|
|
_resoconti = new resoconti();
|
|
// popolazione tabelle
|
|
tabMacchine = DataLayerObj.taMacchine.GetData();
|
|
tabStatoMacchine = DataLayerObj.taStatoMacchine.GetData();
|
|
tabAnagStati = DataLayerObj.taAnagStati.GetData();
|
|
tabKeepAlive = DataLayerObj.taKeepAlive.GetData();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region area public
|
|
|
|
/// <summary>
|
|
/// Idx della macchina controllata
|
|
/// </summary>
|
|
public string IdxMacchina
|
|
{
|
|
get
|
|
{
|
|
return _IdxMacchina;
|
|
}
|
|
set
|
|
{
|
|
if (_resoconti == null)
|
|
{
|
|
_resoconti = new resoconti();
|
|
}
|
|
_IdxMacchina = value;
|
|
_locazione = _resoconti.locazioneDaIdx(_IdxMacchina);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// stringa locazione macchina in tabella
|
|
/// </summary>
|
|
public string locazione
|
|
{
|
|
get
|
|
{
|
|
return _locazione;
|
|
}
|
|
set
|
|
{
|
|
if (_resoconti == null)
|
|
{
|
|
_resoconti = new resoconti();
|
|
}
|
|
_locazione = value;
|
|
try
|
|
{
|
|
_IdxMacchina = _resoconti.idxDaLocazione(_locazione);
|
|
}
|
|
catch
|
|
{
|
|
_IdxMacchina = "nd";
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// aggiorna controllo
|
|
/// </summary>
|
|
public void updateMe()
|
|
{
|
|
// effettua update visualizzazione
|
|
retrieveData();
|
|
updateLayout();
|
|
updateText();
|
|
updateImg();
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
} |