220 lines
7.0 KiB
C#
220 lines
7.0 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web.UI;
|
|
|
|
namespace GIM_site.WebUserControls
|
|
{
|
|
public partial class mod_testata : ApplicationUserControl
|
|
{
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected override void Page_Load(object sender, EventArgs e)
|
|
{
|
|
base.Page_Load(sender, e);
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// se l'utente NON c'è torno a login...
|
|
if (!user_std.UtSn.isAuth)
|
|
{
|
|
string nextPage = Request.Url.LocalPath.Split('/').Last();
|
|
// solo SE non sono già su login (x evitare loop...)
|
|
if (nextPage != "login")
|
|
{
|
|
Session["nextPage"] = nextPage;
|
|
Response.Redirect("login");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
PagCorrente();
|
|
updateTreeMenu();
|
|
}
|
|
// fix componenti
|
|
hlHome.DataBind();
|
|
}
|
|
}
|
|
|
|
public string cssIconPag
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
DataLayer_AnagGen.PermessiRow riga;
|
|
try
|
|
{
|
|
riga = (DataLayer_AnagGen.PermessiRow)user_std.UtSn.permessi.Select(string.Format("URL = '{0}'", user_std.pagCorrente))[0];
|
|
answ = traduci(riga.DESCRIZIONE);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
public string nomePag
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
DataLayer_AnagGen.PermessiRow riga = (DataLayer_AnagGen.PermessiRow)user_std.UtSn.permessi.Select(string.Format("URL = '{0}'", user_std.pagCorrente))[0];
|
|
answ = traduci(riga.NOME);
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
logger.lg.scriviLog(string.Format("Errore in recupero permesso x pagina corrente: {0}{1}{2}", user_std.pagCorrente, Environment.NewLine, exc));
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// wrapper traduzione
|
|
/// </summary>
|
|
/// <param name="lemma"></param>
|
|
/// <returns></returns>
|
|
public string traduci(object lemma)
|
|
{
|
|
return user_std.UtSn.Traduci(lemma.ToString());
|
|
}
|
|
/// <summary>
|
|
/// aggiornamento del menù
|
|
/// </summary>
|
|
private void updateTreeMenu()
|
|
{
|
|
try
|
|
{
|
|
if (user_std.UtSn.mappaSito == "")
|
|
{
|
|
Response.Redirect("default");
|
|
}
|
|
|
|
XmlMenu.Data = user_std.UtSn.mappaSito;
|
|
XmlMenu.XPath = "mainMenu/menu";
|
|
XmlMenu.DataBind();
|
|
}
|
|
catch
|
|
{
|
|
Response.Redirect(user_std.pagCorrente);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// forza l'update del menù sx
|
|
/// </summary>
|
|
public void forzaUpdateMenu()
|
|
{
|
|
user_std.UtSn.ricaricaMappaSito();
|
|
updateTreeMenu();
|
|
}
|
|
public string liClass(string nomeElem)
|
|
{
|
|
string answ = "";
|
|
try
|
|
{
|
|
if (user_std.pagCorrente.IndexOf(nomeElem) >= 0) answ = "active";
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// salva in variabile pagina il nome della pagina corrente
|
|
/// </summary>
|
|
protected override void PagCorrente()
|
|
{
|
|
base.PagCorrente();
|
|
string[] uri = Request.Url.LocalPath.Split('/');
|
|
// salvo pagina corrente
|
|
user_std.pagCorrente = uri.Last();
|
|
if (user_std.pagPrecedente == "")
|
|
{
|
|
user_std.pagPrecedente = user_std.pagCorrente;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// effettua un update completo dei valori in sessione
|
|
/// </summary>
|
|
private void doFullDataUpdate()
|
|
{
|
|
// salvo i dati attuali...
|
|
string cod_cdc = SteamWare.memLayer.ML.StringSessionObj("valRicercaCdC");
|
|
string lingua = user_std.UtSn.lingua;
|
|
string USER_NAME = SteamWare.memLayer.ML.StringSessionObj("USER_NAME");
|
|
string DOMINIO = SteamWare.memLayer.ML.StringSessionObj("DOMINIO");
|
|
bool isForceUser = user_std.UtSn.isForcedUser;
|
|
// salvo i valori delle tab in session...
|
|
Dictionary<string, string> sessionParam = SteamWare.memLayer.ML.valSess2SurvUpd;
|
|
|
|
// svuoto session e cache per rileggere i dati da Db
|
|
Session.RemoveAll();
|
|
|
|
SteamWare.memLayer.ML.flushRegisteredCache();
|
|
|
|
// rimemorizzo
|
|
SteamWare.memLayer.ML.setSessionVal("valRicercaCdC", cod_cdc);
|
|
user_std.UtSn.startUpUtente(DOMINIO, USER_NAME);
|
|
user_std.UtSn.lingua = lingua;
|
|
user_std.UtSn.isForcedUser = isForceUser;
|
|
DataWrap.DW.resetVocabolario();
|
|
|
|
// risalvo in session i valori...
|
|
foreach (KeyValuePair<string, string> kvp in sessionParam)
|
|
{
|
|
SteamWare.memLayer.ML.setSessionVal(kvp.Key, kvp.Value, true);
|
|
}
|
|
|
|
Response.Redirect(_paginaCorrente);
|
|
|
|
}
|
|
/// <summary>
|
|
/// click su pagina corrente, fa update!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbnUpdate_Click(object sender, EventArgs e)
|
|
{
|
|
doFullDataUpdate();
|
|
}
|
|
|
|
/// <summary>
|
|
/// verifica se la pagina abbia abilitato il search
|
|
/// </summary>
|
|
public bool pageHasSearch { get; set; }
|
|
/// <summary>
|
|
/// modifica campo ricerca...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void txtSearch_TextChanged(object sender, EventArgs e)
|
|
{
|
|
// salvo in sessione
|
|
memLayer.ML.setSessionVal("valoreCercato", txtSearch.Text.Trim(), true);
|
|
// raise dell'evento
|
|
if (eh_nuovaRicerca != null)
|
|
{
|
|
eh_nuovaRicerca(this, new EventArgs());
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// valore ricerca
|
|
/// </summary>
|
|
public string searchVal
|
|
{
|
|
get
|
|
{
|
|
return txtSearch.Text.Trim();
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("valoreCercato", value, true);
|
|
txtSearch.Text = value;
|
|
}
|
|
}
|
|
|
|
public event EventHandler eh_nuovaRicerca;
|
|
}
|
|
} |