152 lines
4.2 KiB
C#
152 lines
4.2 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public partial class mod_dettMacchina : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// fatto refresh --> chiedo remove modal (se c'è)
|
|
/// </summary>
|
|
public event EventHandler eh_reqRemoveModal;
|
|
/// <summary>
|
|
/// idx macchina selezionata
|
|
/// </summary>
|
|
public string idxMacchina
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("IdxMacchina");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchina", value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
dmTimer.Interval = memLayer.ML.CRI("dtTimerInt");
|
|
}
|
|
// controllo se ho dett macchina altrimenti ritorno a pagina generale...
|
|
if (idxMacchina == "")
|
|
{
|
|
Response.Redirect("~/MappaStato.aspx");
|
|
}
|
|
//hlFermate.Visible = showInsFermata;
|
|
}
|
|
/// <summary>
|
|
/// url completo immagine
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <returns></returns>
|
|
public string ImgUrl(object url)
|
|
{
|
|
if (url.ToString() == "")
|
|
{
|
|
url = "empty.png";
|
|
}
|
|
return string.Format("./images/macchine/{0}", url);
|
|
}
|
|
/// <summary>
|
|
/// fomratta durata in minuti/ore/gg a seconda del totale...
|
|
/// </summary>
|
|
/// <param name="minuti"></param>
|
|
/// <returns></returns>
|
|
public string formatDurata(object min)
|
|
{
|
|
return utility.formatDurata(min);
|
|
}
|
|
/// <summary>
|
|
/// fa update del controllo
|
|
/// </summary>
|
|
public void doUpdate()
|
|
{
|
|
ods.DataBind();
|
|
repLI.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// timeout scaduto
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Timer1_Tick(object sender, EventArgs e)
|
|
{
|
|
// sollevo evento!
|
|
if (eh_reqRemoveModal != null)
|
|
{
|
|
eh_reqRemoveModal(this, new EventArgs());
|
|
}
|
|
// update
|
|
doUpdate();
|
|
//ScriptManager.RegisterStartupScript(Page, GetType(), "temp", "<script type='text/javascript'>$('div').trigger('create');</script>", false);
|
|
ScriptManager.RegisterStartupScript(Page, GetType(), "temp", "<script type='text/javascript'>$('#dettMacch').trigger('create');</script>", false);
|
|
}
|
|
/// <summary>
|
|
/// Determina se il refresh (via timer) sia o meno abilitato
|
|
/// </summary>
|
|
public bool refreshEnabled
|
|
{
|
|
get
|
|
{
|
|
return dmTimer.Enabled;
|
|
}
|
|
set
|
|
{
|
|
dmTimer.Enabled = value;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Determina se dato lo stato dell'impianto si debba mostrare btn fermata perché
|
|
/// - fermo > xx min (da web.config, es 20')
|
|
/// - impianto fermo (controllando idxStato: priorità > 1)
|
|
/// </summary>
|
|
public bool showInsFermata(object _idxStato, object _durata)
|
|
{
|
|
int idxStato = 0;
|
|
int durata = 0;
|
|
int durMinWarning = memLayer.ML.CRI("durMinWarning");
|
|
int.TryParse(_idxStato.ToString(), out idxStato);
|
|
int.TryParse(_durata.ToString(), out durata);
|
|
bool answ = false;
|
|
if (durata >= durMinWarning)
|
|
{
|
|
try
|
|
{
|
|
// in questo caso controllo idxStato... e recupero priorità se > 1 --> richiesta qualifica
|
|
answ = (DataLayer.obj.taAnagStati.GetByIdx(idxStato)[0].Priorita > 1);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public string urlDisegno(object _codArticolo)
|
|
{
|
|
// default è ND...
|
|
string outVal = "~/Files/Disegni/ND.pdf";
|
|
// recupero da anagrafica articoli...
|
|
try
|
|
{
|
|
DS_ProdTempi.AnagArticoliRow riga = DataLayer.obj.taAnagArt.getByCod(_codArticolo.ToString())[0];
|
|
outVal = string.Format("~/Files/Disegni/{0}.pdf", riga.Disegno);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in ricostruzione URL disegno:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
return outVal;
|
|
}
|
|
}
|
|
} |