65d219dee9
- update parziale bootstrap5
176 lines
5.0 KiB
C#
176 lines
5.0 KiB
C#
using SteamWare;
|
|
using SteamWare.Logger;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace MP_MAG.WebUserControls
|
|
{
|
|
public partial class cmp_menuTop : BaseUserControl
|
|
{
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// Elenco pagine "safe" da web.config
|
|
/// </summary>
|
|
protected string safePages
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.confReadString("_safePages");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Valore ricerca attivo
|
|
/// </summary>
|
|
protected string searchVal
|
|
{
|
|
get
|
|
{
|
|
return txtSearch.Text.Trim();
|
|
}
|
|
set
|
|
{
|
|
txtSearch.Text = value.Trim();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// imposta visibilità search globale
|
|
/// </summary>
|
|
public bool showSearch
|
|
{
|
|
get
|
|
{
|
|
return divSearch.Visible;
|
|
}
|
|
set
|
|
{
|
|
divSearch.Visible = value;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// effettua un update completo dei valori in sessione
|
|
/// </summary>
|
|
private void doDataUpdate(bool doFullReset)
|
|
{
|
|
if (doFullReset)
|
|
{
|
|
// aggiorno vocabolario
|
|
DataWrap.DW.resetVocabolario();
|
|
// reset dati in cache x DbConfig...
|
|
memLayer.ML.resetAppConf();
|
|
// svuoto session e cache per rileggere i dati da Db
|
|
Session.RemoveAll();
|
|
memLayer.ML.setSessionVal("nextPage", user_std.pagCorrente);
|
|
Response.Redirect("login");
|
|
}
|
|
else
|
|
{
|
|
resetProdData();
|
|
Response.Redirect("menu");
|
|
}
|
|
}
|
|
|
|
private void doSearch()
|
|
{
|
|
// se searchVal !=""
|
|
if (!string.IsNullOrEmpty(searchVal))
|
|
{
|
|
memLayer.ML.setSessionVal("valoreSearch", searchVal);
|
|
}
|
|
else
|
|
{
|
|
memLayer.ML.emptySessionVal("valoreSearch");
|
|
}
|
|
// se qualcuno ascolta sollevo evento nuovo valore...
|
|
raiseEvent();
|
|
}
|
|
|
|
/// <summary>
|
|
/// aggiornamento del menù
|
|
/// </summary>
|
|
private void updateTreeMenu()
|
|
{
|
|
try
|
|
{
|
|
if (string.IsNullOrEmpty(user_std.UtSn.mappaSito))
|
|
{
|
|
if (safePages.IndexOf(Request.Url.Segments.LastOrDefault(), StringComparison.OrdinalIgnoreCase) < 0)
|
|
{
|
|
Response.Redirect("login", true);
|
|
}
|
|
string DefaultMenuPath = Server.MapPath("~/Resources/DefaultMenu.xml");
|
|
Logging.Instance.Info($"Manca menu utente --> leggo default da {DefaultMenuPath}");
|
|
XmlMenu.Data = File.ReadAllText(DefaultMenuPath);
|
|
}
|
|
else
|
|
{
|
|
XmlMenu.Data = devicesAuthProxy.stObj.mappaSito;
|
|
}
|
|
}
|
|
catch (Exception exc)
|
|
{
|
|
Logging.Instance.Info($"Eccezione in updateTreeMenu {Environment.NewLine}{exc}");
|
|
if (safePages.IndexOf(Request.Url.Segments.LastOrDefault(), StringComparison.OrdinalIgnoreCase) < 0)
|
|
{
|
|
Response.Redirect("login", false);
|
|
}
|
|
XmlMenu.Data = "<?xml version=\"1.0\" encoding=\"utf-8\" ?><mainMenu><menu title=\"Utility\" description=\"fa fa-briefcase shortcut-icon\" url=\"~/menu\"><voce title=\"Enroll Device\" description=\"fas fa-sign-in-alt shortcut-icon\" url= \"~/EnrollDevice\" /></ menu></ mainMenu>";
|
|
}
|
|
XmlMenu.XPath = "mainMenu/menu";
|
|
XmlMenu.DataBind();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// click su pagina corrente, fa update!
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lbnUpdate_Click(object sender, EventArgs e)
|
|
{
|
|
doDataUpdate(true);
|
|
}
|
|
|
|
protected void lbtSearch_Click(object sender, EventArgs e)
|
|
{
|
|
doSearch();
|
|
}
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
lblTitle.Text = titolo;
|
|
searchVal = "";
|
|
doSearch();
|
|
updateTreeMenu();
|
|
}
|
|
}
|
|
|
|
protected void txtSearch_TextChanged(object sender, EventArgs e)
|
|
{
|
|
doSearch();
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |