Ejemplo n.º 1
0
    //E' presente anche nella Default.aspx
    //public bool IsMobile()
    //{
    //    bool retValue = false;

    //    try //try , because sometimes user agent is empty
    //    {
    //        string ua = HttpContext.Current.Request.ServerVariables["HTTP_USER_AGENT"].ToString().ToLower();
    //        string[] uaArray = { "android", "maui", "ppc", "opera mobi", "symbian", "series", "nokia", "mot-", "motorola", "lg-", "lge", "nec-", "lg/", "samsung", "sie-", "sec-", "sgh-", "sonyericsson", "sharp", "windows ce", "portalmmm", "o2-", "docomo", "philips", "panasonic", "sagem", "smartphone", "up.browser", "up.link", "googlebot-mobile", "googlebot-image", "slurp", "spring", "alcatel", "sendo", "blackberry", "opera mini", "opera 2", "netfront", "mobilephone mm", "vodafone", "avantgo", "palmsource", "siemens", "toshiba", "i-mobile", "asus", "kwc", "htc", "softbank", "playstation", "nitro", "ipod", "google wireless transcoder", "t-mobile", "obigo", "brew" }; //"ice",

    //        bool foundInArray = false;
    //        foreach (string s in uaArray)
    //        {
    //            if (ua.IndexOf(s) > -1)
    //            {
    //                foundInArray = true;
    //                break;
    //            }
    //        }

    //        if (foundInArray == true || HttpContext.Current.Request.Browser.IsMobileDevice || HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT"].Contains("application/vnd.wap.xhtml+xml"))
    //            retValue = true;
    //    }
    //    catch (Exception e)
    //    {
    //        string foo = e.Message;
    //    }

    //    return retValue;
    //}

    void ByPassLogin(string idMailClick)
    {
        string idRichiesta   = string.Empty;
        string wrfCodice     = string.Empty;
        bool   loginVerified = false;

        Audit  objAudit  = new Audit();
        Utente objUtente = new Utente();

        objUtente.Mac_codice_univoco = idMailClick;
        loginVerified = objUtente.CheckByPassLogin();
        idRichiesta   = objUtente.Riv_id_richiesta.ToString();
        wrfCodice     = objUtente.Ioa_wrf_codice.ToString();

        //Pensare di centralizzare questo controllo.
        Session["UTE_ID_UTENTE"]  = objUtente.Ute_id_utente.Value;
        Session["UTE_SIGLA"]      = (objUtente.Ute_sigla.IsNull) ? (string.Empty) : (objUtente.Ute_sigla.Value);
        Session["IP_ADDRESS"]     = Convert.ToString(Request.ServerVariables["REMOTE_ADDR"]);
        Session["UTE_COGNOME"]    = objUtente.Ute_cognome.Value;
        Session["UTE_NOME"]       = objUtente.Ute_nome.Value;
        Session["CLI_ID_CLIENTE"] = objUtente.Cli_id_cliente.Value;

        if (objUtente.Tpi_acronimo.Value != "")
        {
            Session["ACRONIMO_INSTALLAZIONE"] = objUtente.Tpi_acronimo.Value;
        }
        else
        {
            Session["ACRONIMO_INSTALLAZIONE"] = "";
        }
        Response.Write(Session["UTE_ID_UTENTE"].ToString());

        try
        {
            objAudit.Ute_id_utente  = objUtente.Ute_id_utente;
            objAudit.Aud_ip_address = Convert.ToString(Session["IP_ADDRESS"]);
            objAudit.TraceAction("Login");
            Session["AUD_ID_AUDIT"] = objAudit.Aud_id_audit;

            Dictionary <string, int> dizionarioPermessi = objUtente.BuildPermissions();
            Session["dizionarioPermessi"] = dizionarioPermessi;

            // Create the authentication ticket
            FormsAuthenticationTicket authTicket = new
                                                   FormsAuthenticationTicket(1,                         // version
                                                                             InputUser.Text,            // user name
                                                                             DateTime.Now,              // creation
                                                                             DateTime.Now.AddHours(10), // Expiration
                                                                             false,                     // Persistent
                                                                             "");                       // User data

            // Now encrypt the ticket.
            string encryptedTicket = FormsAuthentication.Encrypt(authTicket);
            // Create a cookie and add the encrypted
            // cookie as data.
            HttpCookie authCookie = new HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);

            // Add the cookie to the outgoing cookies
            Response.Cookies.Add(authCookie);

            int naz_id_nazione = 1;//Convert.ToInt32(RadioButtonLingua.SelectedItem.Value);
            Session["NAZ_ID_NAZIONE"]    = naz_id_nazione;
            Session["CULTURE_INFO_NAME"] = "it";

            //SVA(07102011): Una volta che mi loggo inserisco nella tabella delle Sessioni le informazioni
            //relative all'utente che si è loggato.
            setSessionId();
        }
        catch (Exception ex)
        {
            // Gestione messaggistica all'utente e trace in DB dell'errore
            ExceptionPolicy.HandleException(ex, "Propagate Policy");
        }
        //*****************************************
        if (idRichiesta != null)
        {
            Response.Redirect("../HOME/mainpage.aspx?ID_RICHIESTA=" + idRichiesta + "&CODICE_WORKFLOW=" + wrfCodice, false);
        }
    }