using MapoDb; using SteamWare; using System; namespace MP_ADM { public class BaseUserControl : System.Web.UI.UserControl { #region Internal Fields /// /// Oggetto datalayer specifico NON singleton x scalare /// internal DataLayer DataLayerObj = new DataLayer(); #endregion Internal Fields #region Public Fields /// /// Abilitazione gestione Controlli periodici /// public bool enableControlli = memLayer.ML.cdvb("enableControlli"); /// /// Abilitazione gestione Disegno articolo /// public bool enableDisegno = memLayer.ML.cdvb("enableDisegno"); /// /// Abilitazione gestione grafici JScript /// public bool enableGraphJS = memLayer.ML.cdvb("enableGraphJS"); /// /// Abilitazione gestione Pezzi LAsciati in macchina /// public bool enablePzProdLasciati = memLayer.ML.cdvb("enablePzProdLasciati"); /// /// Abilitazione gestione Richieste - Promesse - ODL /// public bool enableRPO = memLayer.ML.cdvb("enableRPO"); /// /// Abilitazione gestione scarti /// public bool enableScarti = memLayer.ML.cdvb("enableScarti"); /// /// Abilitazione scheda Tecnica /// public bool enableSchedaTecnica = memLayer.ML.cdvb("enableSchedaTecnica"); /// /// Abilitazione gestione SplitODL /// public bool enableSplitODL = memLayer.ML.cdvb("enableSplitODL"); /// /// Abilitazione gestione Set PZ Pallet su tablet /// public bool enableTabSetPzPallet = memLayer.ML.cdvb("enableTabSetPzPallet"); #endregion Public Fields #region Public Events public event EventHandler eh_nuovoValore; public event EventHandler eh_resetSelezione; public event EventHandler eh_selValore; #endregion Public Events #region Public Properties /// /// Clipboard corrente utente /// public string clipboard { get { return memLayer.ML.StringSessionObj("UserClipboard"); } set { memLayer.ML.setSessionVal("UserClipboard", value); } } /// /// titolo pagina /// public string titolo { get { return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", ""); } } /// /// UID formattato con "_" /// public string uid { get { return this.UniqueID.Replace("$", "_").Replace("-", "_"); } } #endregion Public Properties #region Protected Methods /// /// Verifica se la macchina MAIN sia MASTER /// protected bool isMaster(string idxMacchina) { return DataLayerObj.isMaster(idxMacchina); } /// /// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...) /// protected bool isMulti(string idxMacchina) { return DataLayerObj.isMulti(idxMacchina); } /// /// Verifica se la macchina MAIN sia SLAVE /// protected bool isSlave(string idxMacchina) { return DataLayerObj.isSlave(idxMacchina); } /// /// conversione da tempo minuti centesimali a minuti/secondi /// /// /// protected TimeSpan minCent2Sec(decimal valore) { TimeSpan answ = new TimeSpan(0, 0, 1); try { answ = new TimeSpan(0, Convert.ToInt32(valore), Convert.ToInt32((valore - Convert.ToInt32(valore)) * 60)); } catch { } return answ; } #endregion Protected Methods #region Public Methods /// /// cambia il colore del campo secondo la due date indicata /// rosso: in ritardo (scaduta) /// verde: > 2 week /// giallo: altrimenti /// /// /// public string cssDueDate(object dueDate) { DateTime oggi = DateTime.Today; DateTime dataRif = oggi.AddDays(-1); DateTime.TryParse(dueDate.ToString(), out dataRif); string answ = "text-secondary"; if (dataRif < oggi) { answ = "text-danger"; } else if (dataRif < oggi.AddDays(14)) { answ = "text-warning"; } else { answ = "text-success"; } return answ; } /// /// Conversione a bool del valore /// /// /// public bool getBool(object value) { bool answ = false; bool.TryParse(value.ToString(), out answ); return answ; } public string min2hour(object minutes) { string answ = ""; double minDbl = 0; double.TryParse($"{minutes}", out minDbl); answ = $"{minDbl / 60:N2}"; return answ; } /// /// formatta in minuti/sec partendo da min.cent /// /// /// public string minSec(object minCent) { string answ = ""; try { answ = string.Format("{0:mm}:{0:ss}", minCent2Sec(Convert.ToDecimal(minCent.ToString().Replace(".", ",")))); } catch { } return answ; } /// /// Solleva evento nuovo valore /// public void raiseNewVal() { // evento come nuovo... if (eh_nuovoValore != null) { eh_nuovoValore(this, new EventArgs()); } } /// /// Solleva evento reset /// public void raiseReset() { if (eh_resetSelezione != null) { eh_resetSelezione(this, new EventArgs()); } } public void raiseSelNew() { // sollevo evento nuovo valore... if (eh_selValore != null) { eh_selValore(this, new EventArgs()); } } /// /// effettua traduzione del lemma /// /// /// public string traduci(object lemmaRaw) { return user_std.UtSn.Traduci($"{lemmaRaw}"); } /// /// effettua traduzione del lemma /// /// /// public string traduci(string lemma) { return user_std.UtSn.Traduci(lemma); } /// /// effettua traduzione in inglese del lemma /// /// /// public string traduciEn(string lemma) { return user_std.UtSn.TraduciEn(lemma); } #endregion Public Methods } }