using SteamWare;
using System;
using System.Linq;
using System.Web.UI;
namespace ES3.WebUserControls
{
public partial class mod_menuTopCompact : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
string lastPage = Request.Url.LocalPath.Split('/').Last();
if (!Page.IsPostBack)
{
// fix visibilità TASK
hlTask.Visible = devicesAuthProxy.stObj.userHasRight("CT_userStart");
// se l'utente NON c'è torno a login...
if (!devicesAuthProxy.stObj.isAuth)
{
if (lastPage != "" && lastPage != "login")
{
Session["nextPage"] = lastPage;
}
// SE non sono in "safe page"
if (memLayer.ML.CRS("_loginPages").IndexOf(lastPage) < 0)
{
Response.Redirect("login");
}
}
else
{
PagCorrente();
}
}
// controllo pagina...
bool pageAuth = devicesAuthProxy.stObj.isPageEnabled(lastPage);
// controllo pag auth...
if (!pageAuth)
{
Response.Redirect("~/login");
}
lblTitolo.Text = memLayer.ML.CRS("appName");
}
///
/// salva in variabile pagina il nome della pagina corrente
///
protected void PagCorrente()
{
string[] uri = Request.Url.LocalPath.Split('/');
// salvo pagina corrente
devicesAuthProxy.pagCorrente = uri.Last();
if (devicesAuthProxy.pagPrecedente == "")
{
devicesAuthProxy.pagPrecedente = devicesAuthProxy.pagCorrente;
}
}
///
/// Codice postazione di lavoro
///
public string CodPost
{
get
{
return memLayer.ML.StringSessionObj("CodPost");
}
}
///
/// Codice Operatore
///
public string CodOpr
{
get
{
return memLayer.ML.StringSessionObj("CodOpr");
}
}
///
/// Codice TASK corrente
///
public string CurrNumTask
{
get
{
return memLayer.ML.StringSessionObj("CurrNumTask");
}
}
///
/// Codice postazione di lavoro
///
public string DescPost
{
get
{
string answ = "";
#if false
if (memLayer.ML.isInSessionObject("DescPost"))
{
answ = memLayer.ML.StringSessionObj("DescPost");
}
if (answ == "")
{
var tabPost = dataLayer.man.taAP.getByKey(CodPost);
if (tabPost.Rows.Count > 0)
{
answ = tabPost[0].Descrizione;
}
memLayer.ML.setSessionVal("DescPost", answ);
}
#endif
return answ;
}
}
///
/// Codice Operatore
///
public string NomeOpr
{
get
{
string answ = "";
#if false
if (memLayer.ML.isInSessionObject("NomeOpr"))
{
answ = memLayer.ML.StringSessionObj("NomeOpr");
}
if (answ == "")
{
var tabOpr = dataLayer.man.taAO.getByKey(CodOpr);
if (tabOpr.Rows.Count > 0)
{
answ = string.Format("{0} {1}", tabOpr[0].Cognome, tabOpr[0].Nome);
}
memLayer.ML.setSessionVal("NomeOpr", answ);
}
#endif
return answ;
}
}
}
}