573 lines
16 KiB
C#
573 lines
16 KiB
C#
using MapoDb;
|
|
using NLog;
|
|
using SteamWare;
|
|
using System;
|
|
using System.IO;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public class BaseUserControl : System.Web.UI.UserControl //SteamWare.UserControl //
|
|
{
|
|
#region Public Fields
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione Controlli periodici
|
|
/// </summary>
|
|
public bool enableControlli = memLayer.ML.cdvb("enableControlli");
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione Disegno articolo
|
|
/// </summary>
|
|
public bool enableDisegno = memLayer.ML.cdvb("enableDisegno");
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione grafici JScript
|
|
/// </summary>
|
|
public bool enableGraphJS = memLayer.ML.cdvb("enableGraphJS");
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione LOTTI in DB MAG
|
|
/// </summary>
|
|
public bool enableMagLotti = memLayer.ML.cdvb("enableMagLotti");
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione Pezzi LAsciati in macchina
|
|
/// </summary>
|
|
public bool enablePzProdLasciati = memLayer.ML.cdvb("enablePzProdLasciati");
|
|
|
|
/// <summary>
|
|
/// Verifica chiave enableRiattrezzaggio in tab Config
|
|
/// </summary>
|
|
public bool enableRiattrezzaggio = memLayer.ML.cdvb("enableRiattrezzaggio");
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione Richieste - Promesse - ODL
|
|
/// </summary>
|
|
public bool enableRPO = memLayer.ML.cdvb("enableRPO");
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione scarti
|
|
/// </summary>
|
|
public bool enableScarti = memLayer.ML.cdvb("enableScarti");
|
|
|
|
/// <summary>
|
|
/// Abilitazione scheda Tecnica
|
|
/// </summary>
|
|
public bool enableSchedaTecnica = memLayer.ML.cdvb("enableSchedaTecnica");
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione SplitODL
|
|
/// </summary>
|
|
public bool enableSplitODL = memLayer.ML.cdvb("enableSplitODL");
|
|
|
|
/// <summary>
|
|
/// Abilitazione gestione Set PZ Pallet su tablet
|
|
/// </summary>
|
|
public bool enableTabSetPzPallet = memLayer.ML.cdvb("enableTabSetPzPallet");
|
|
|
|
#endregion Public Fields
|
|
|
|
#region Public Events
|
|
|
|
/// <summary>
|
|
/// evento update
|
|
/// </summary>
|
|
public event EventHandler eh_doUpdate;
|
|
|
|
/// <summary>
|
|
/// evento selezione valore
|
|
/// </summary>
|
|
public event EventHandler eh_selVal;
|
|
|
|
#endregion Public Events
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// idx macchina selezionata
|
|
/// </summary>
|
|
public string idxMacchina
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("IdxMacchina");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchina", value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Idx macchina selezionata FIX (esempio x nuovo ODL su doppia tavola)
|
|
/// </summary>
|
|
public string idxMacchinaFix
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("IdxMacchinaFix");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchinaFix", value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// idx macchina selezionata
|
|
/// </summary>
|
|
public string idxMacchinaSel
|
|
{
|
|
get
|
|
{
|
|
string answ = idxMacchina;
|
|
// verifoc: se multi uso selettore tendina...
|
|
if (isMulti)
|
|
{
|
|
answ = subMaccSel;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// idxOdl corrente in sessione
|
|
/// </summary>
|
|
public int idxOdl
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("idxODL");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("idxODL", value);
|
|
// resetto cache redis
|
|
if (value == 0)
|
|
{
|
|
DataLayerObj.emptyCurrODL(idxMacchina);
|
|
}
|
|
}
|
|
}
|
|
|
|
public DateTime inizioOdl
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = DateTime.Now.AddYears(-1);
|
|
if (idxOdl > 0)
|
|
{
|
|
var odlDetail = getCurrOdlRow();
|
|
if (odlDetail != null)
|
|
{
|
|
answ = odlDetail.DataInizio;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
public string keyRichiesta
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
if (idxOdl > 0)
|
|
{
|
|
//var odlDetail = DataLayerObj.currODLRowTab(idxMacchina);
|
|
//if (odlDetail != null && odlDetail.Rows.Count > 0)
|
|
//{
|
|
// answ = odlDetail[0].KeyRichiesta;
|
|
//}
|
|
var odlDetail = getCurrOdlRow();
|
|
if (odlDetail != null)
|
|
{
|
|
answ = odlDetail.KeyRichiesta;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Num giorni configurati x selezione ODL in scadenza
|
|
/// </summary>
|
|
public int numDaySelOdl
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.CRI("numDaySelOdl");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sotto sistema (macchina) selezionato in sessione
|
|
/// </summary>
|
|
public string subMaccSel
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("subMaccSel");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("subMaccSel", value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// titolo pagina
|
|
/// </summary>
|
|
public string titolo
|
|
{
|
|
get
|
|
{
|
|
return devicesAuthProxy.getPage(Request.Url);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// stringa UID univoca
|
|
/// </summary>
|
|
public string uid
|
|
{
|
|
get
|
|
{
|
|
return this.UniqueID.Replace("$", "_").Replace("-", "_");
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Public Methods
|
|
|
|
public string encodeAuthKey(object plainUserAuthKey)
|
|
{
|
|
string answ = "";
|
|
answ = SteamCrypto.EncryptString(plainUserAuthKey.ToString(), memLayer.ML.CRS("cookieName"));
|
|
return answ;
|
|
}
|
|
|
|
/// <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>
|
|
/// Conversione a bool del valore
|
|
/// </summary>
|
|
/// <param name="value"></param>
|
|
/// <returns></returns>
|
|
public bool getBool(object value)
|
|
{
|
|
bool answ = false;
|
|
string rawVal = $"{value}".ToUpper();
|
|
// se è 1/0 --> len 1
|
|
if (rawVal.Length == 1)
|
|
{
|
|
answ = rawVal == "1" || rawVal == "S" || rawVal == "Y";
|
|
}
|
|
else
|
|
{
|
|
bool.TryParse($"{value}", out answ);
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
public DS_ProdTempi.ODLRow getCurrOdlRow()
|
|
{
|
|
DS_ProdTempi.ODLRow answ = null;
|
|
if (idxOdl > 0)
|
|
{
|
|
DS_ProdTempi.ODLDataTable odlDetail = DataLayerObj.currODLRowTab(idxMacchina);
|
|
if (odlDetail != null && odlDetail.Rows.Count > 0)
|
|
{
|
|
answ = odlDetail[0];
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// url completo immagine icona
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <returns></returns>
|
|
public string ImgUrlIcon(object url)
|
|
{
|
|
return string.Format("./images/iconDic/{0}.png", url);
|
|
}
|
|
|
|
/// <summary>
|
|
/// url completo immagine
|
|
/// </summary>
|
|
/// <param name="url"></param>
|
|
/// <returns></returns>
|
|
public string ImgUrlMacc(object url)
|
|
{
|
|
string answ = "";
|
|
if (string.IsNullOrEmpty(url.ToString()))
|
|
{
|
|
url = "Steamware.png";
|
|
}
|
|
// verifico esistenza macchina SMALL...
|
|
answ = $"./images/macchine/small/{url}";
|
|
string fullPath = Server.MapPath(answ);
|
|
if (!File.Exists(fullPath))
|
|
{
|
|
// se non ci fosse cerco immagine fullsize
|
|
answ = $"./images/macchine/{url}";
|
|
fullPath = Server.MapPath(answ);
|
|
}
|
|
// altrimenti metto default Steamware
|
|
if (!File.Exists(fullPath))
|
|
{
|
|
answ = "./images/macchine/Steamware.png";
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Riporta evento selezione
|
|
/// </summary>
|
|
public virtual void reportSelect()
|
|
{
|
|
// alzo l'evento d update/inserimento e ricarico cache...
|
|
if (eh_selVal != null)
|
|
{
|
|
eh_selVal(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Riporta evento update
|
|
/// </summary>
|
|
public virtual void reportUpdate()
|
|
{
|
|
// alzo l'evento d update/inserimento e ricarico cache...
|
|
if (eh_doUpdate != null)
|
|
{
|
|
eh_doUpdate(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
public string TCMinSec(object _TC)
|
|
{
|
|
string TC_MinSec = "";
|
|
decimal TC = 0;
|
|
decimal.TryParse(_TC.ToString(), out TC);
|
|
int min = 0;
|
|
int sec = 0;
|
|
try
|
|
{
|
|
// cerco di convertire in min/sec
|
|
min = Convert.ToInt32(Math.Floor(Convert.ToDouble(TC)));
|
|
sec = Convert.ToInt32((Convert.ToDouble(TC) - min) * 60);
|
|
TC_MinSec = string.Format("{0}:{1:00}", min, sec);
|
|
}
|
|
catch
|
|
{ }
|
|
return TC_MinSec;
|
|
}
|
|
|
|
/// <summary>
|
|
/// effettua traduzione del lemma
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(string lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma);
|
|
}
|
|
|
|
/// <summary>
|
|
/// effettua traduzione del lemma
|
|
/// </summary>
|
|
/// <param name="_lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object _lemma)
|
|
{
|
|
_lemma = _lemma == null ? "" : _lemma;
|
|
return user_std.UtSn.Traduci(_lemma.ToString());
|
|
}
|
|
|
|
/// <summary>
|
|
/// effettua traduzione in inglese del lemma
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduciEn(string lemma)
|
|
{
|
|
return user_std.UtSn.TraduciEn(lemma);
|
|
}
|
|
|
|
public string urlDisegno(object _codArticolo)
|
|
{
|
|
// default è ND...
|
|
string outVal = "~/Files/Disegni/ND.pdf";
|
|
// recupero da anagrafica articoli...
|
|
try
|
|
{
|
|
DS_ProdTempi.AnagArticoliRow riga = selData.mng.rigaArt(_codArticolo.ToString());
|
|
if (riga != null)
|
|
{
|
|
outVal = string.Format("~/Files/Disegni/{0}.pdf", riga.Disegno);
|
|
}
|
|
else
|
|
{
|
|
logger.lg.scriviLog(string.Format("Attenzione! nessuna informazione trovata per l'articolo {0}", _codArticolo), tipoLog.WARNING);
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in ricostruzione URL disegno:{0}{1}", Environment.NewLine, exc), tipoLog.EXCEPTION);
|
|
}
|
|
return outVal;
|
|
}
|
|
|
|
#endregion Public Methods
|
|
|
|
#region Internal Fields
|
|
|
|
/// <summary>
|
|
/// classe MapoDB x uso locale
|
|
/// </summary>
|
|
internal MapoDb.MapoDb controllerMapo = new MapoDb.MapoDb();
|
|
|
|
/// <summary>
|
|
/// Oggetto datalayer specifico
|
|
/// </summary>
|
|
internal DataLayer DataLayerObj = new DataLayer();
|
|
|
|
#endregion Internal Fields
|
|
|
|
#region Internal Properties
|
|
|
|
/// <summary>
|
|
/// Verifica se la macchina MAIN sia MASTER
|
|
/// </summary>
|
|
internal bool isMaster
|
|
{
|
|
get
|
|
{
|
|
return DataLayerObj.isMaster(idxMacchina);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica se la macchina MAIN sia MULTI (da DatiMacchina / redis...)
|
|
/// </summary>
|
|
internal bool isMulti
|
|
{
|
|
get
|
|
{
|
|
return DataLayerObj.isMulti(idxMacchina);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Verifica se la macchina MAIN sia SLAVE
|
|
/// </summary>
|
|
internal bool isSlave
|
|
{
|
|
get
|
|
{
|
|
return DataLayerObj.isSlave(idxMacchina);
|
|
}
|
|
}
|
|
|
|
#endregion Internal Properties
|
|
|
|
#region Protected Fields
|
|
|
|
protected static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
|
|
|
/// <summary>
|
|
/// indica conferma con rettifica (evento 121)
|
|
/// </summary>
|
|
protected bool confRett = memLayer.ML.CRB("confRett");
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Restituisce il codice IdxMacchina dell'impianto PARENT (se multi) altrimenti la stessa macchina...
|
|
/// </summary>
|
|
protected string idxMaccParent
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
// se è multi controllo
|
|
if (isMulti)
|
|
{
|
|
// verifico se SIA una tavola (ha char "#")
|
|
int iSharp = idxMacchinaFix.IndexOf('#');
|
|
if (iSharp > 0)
|
|
{
|
|
// sistemo nome
|
|
answ = idxMacchinaFix.Substring(0, iSharp);
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// conversione da tempo minuti centesimali a minuti/secondi
|
|
/// </summary>
|
|
/// <param name="valore"></param>
|
|
/// <returns></returns>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// conversione da tempo minuti/secondi a minuti centesimali
|
|
/// </summary>
|
|
/// <param name="valore"></param>
|
|
/// <returns></returns>
|
|
protected decimal minSec2Cent(TimeSpan valore)
|
|
{
|
|
Decimal answ = 0;
|
|
try
|
|
{
|
|
answ = Math.Round((valore.Minutes + (decimal)valore.Seconds / 60), 3);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Arrotondamento oggetto datetime all'intervallo timespan indicato
|
|
/// </summary>
|
|
/// <param name="dt">Dataora</param>
|
|
/// <param name="d">Timespan arrotondamento (x eccesso)</param>
|
|
/// <returns></returns>
|
|
protected DateTime RoundUp(DateTime dt, TimeSpan d)
|
|
{
|
|
return new DateTime((dt.Ticks + d.Ticks - 1) / d.Ticks * d.Ticks, dt.Kind);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |