291 lines
7.8 KiB
C#
291 lines
7.8 KiB
C#
using MapoDb;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
|
|
namespace MoonProTablet.WebUserControls
|
|
{
|
|
public class BaseUserControl : System.Web.UI.UserControl //SteamWare.UserControl //
|
|
{
|
|
#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 Public Properties
|
|
|
|
/// <summary>
|
|
/// idx macchina selezionata
|
|
/// </summary>
|
|
public string idxMacchina
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.StringSessionObj("IdxMacchina");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("IdxMacchina", value);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// idxOdl corrente in sessione
|
|
/// </summary>
|
|
public int idxOdl
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("idxODL");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("idxODL", value);
|
|
}
|
|
}
|
|
|
|
/// <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 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;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#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>
|
|
/// 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)
|
|
{
|
|
if (string.IsNullOrEmpty(url.ToString()))
|
|
{
|
|
url = "empty.png";
|
|
}
|
|
return string.Format("./images/macchine/{0}", url);
|
|
}
|
|
|
|
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
|
|
}
|
|
} |