using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SteamWare;

namespace GMW_Term
{
  public partial class Default : System.Web.UI.Page
  {
    /// <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;
    }
    /// <summary>
    /// Pagina corrente
    /// </summary>
    protected string currPage
    {
      get
      {
        return getPage(Request.Url).Replace(".aspx", "");
      }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
      // verifica se è già in sessione l'utente
      if (string.IsNullOrEmpty(memLayer.ML.StringSessionObj("username")))
      {
        // se non safe...
        if (memLayer.ML.CRS("_safePages").IndexOf(currPage) < 0)
        {
          Response.Redirect("Barcode.aspx");
        }
      }
      else
      {
        Response.Redirect("Home.aspx");
      }
    }
  }
}
