178 lines
3.6 KiB
C#
178 lines
3.6 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Linq;
|
|
using System.Web.UI;
|
|
|
|
namespace WebLCP.WUC
|
|
{
|
|
public partial class cmp_header : System.Web.UI.UserControl
|
|
{
|
|
public event EventHandler eh_doRefresh;
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
showSearch = false;
|
|
searchVal = "";
|
|
ulLinks.DataBind();
|
|
hlReset.DataBind();
|
|
hlLogin.DataBind();
|
|
checkAuth();
|
|
}
|
|
}
|
|
|
|
protected string safePages
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = $"{memLayer.ML.confReadString("_safePages")}#{memLayer.ML.confReadString("_loginPages")}";
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
|
|
private void checkAuth()
|
|
{
|
|
string lastPage = Request.Url.LocalPath.Split('/').Last();
|
|
// se l'utente NON c'è torno a login...
|
|
if (!userIsAuth)
|
|
{
|
|
if (lastPage != "" && lastPage != "login")
|
|
{
|
|
Session["nextPage"] = lastPage;
|
|
}
|
|
// SE non sono in "safe page"
|
|
if (safePages.ToLower().IndexOf(lastPage.ToLower()) < 0)
|
|
{
|
|
Response.Redirect("~/login");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
PagCorrente();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Indica se user sia autorizzato
|
|
/// </summary>
|
|
public bool userIsAuth
|
|
{
|
|
get
|
|
{
|
|
return devicesAuthProxy.stObj.isAuth;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// salva in variabile pagina il nome della pagina corrente
|
|
/// </summary>
|
|
protected void PagCorrente()
|
|
{
|
|
string[] uri = Request.Url.LocalPath.Split('/');
|
|
// salvo pagina corrente
|
|
devicesAuthProxy.pagCorrente = uri.Last();
|
|
if (devicesAuthProxy.pagPrecedente == "")
|
|
{
|
|
devicesAuthProxy.pagPrecedente = devicesAuthProxy.pagCorrente;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// imposta visibilità search globale
|
|
/// </summary>
|
|
public bool showSearch
|
|
{
|
|
get
|
|
{
|
|
return divSearch.Visible;
|
|
}
|
|
set
|
|
{
|
|
divSearch.Visible = value;
|
|
}
|
|
}
|
|
|
|
protected void txtSearch_TextChanged(object sender, EventArgs e)
|
|
{
|
|
doSearch();
|
|
}
|
|
|
|
private void doSearch()
|
|
{
|
|
// se searchVal !=""
|
|
if (searchVal != "")
|
|
{
|
|
memLayer.ML.setSessionVal("valoreSearch", searchVal);
|
|
}
|
|
else
|
|
{
|
|
memLayer.ML.emptySessionVal("valoreSearch");
|
|
}
|
|
// se qualcuno ascolta sollevo evento nuovo valore...
|
|
if (eh_doRefresh != null)
|
|
{
|
|
eh_doRefresh(this, new EventArgs());
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Valore ricerca attivo
|
|
/// </summary>
|
|
protected string searchVal
|
|
{
|
|
get
|
|
{
|
|
return txtSearch.Text.Trim();
|
|
}
|
|
set
|
|
{
|
|
txtSearch.Text = value.Trim();
|
|
}
|
|
}
|
|
|
|
protected void lbtSearch_Click(object sender, EventArgs e)
|
|
{
|
|
doSearch();
|
|
}
|
|
|
|
public string checkPage(string tgtName)
|
|
{
|
|
string answ = "";
|
|
if (titolo == tgtName)
|
|
{
|
|
answ = "active";
|
|
}
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// titolo pagina
|
|
/// </summary>
|
|
public string titolo
|
|
{
|
|
get
|
|
{
|
|
return devicesAuthProxy.getPage(Request.Url).Replace(".aspx", "");
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// restituisce il nome della pagina corrente
|
|
/// </summary>
|
|
public static string getPage(Uri MyUrl)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
answ = MyUrl.LocalPath.Split('/').Last();
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(exc.ToString(), tipoLog.EXCEPTION);
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
} |