示例#1
0
    /// <summary>
    /// this is the proper place to do initialization in a master page
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Init(object sender, EventArgs e)
    {
        //app specific stuff outside the base controller
        APPMaster = new AppMaster();
        APPMaster.SetBaseMaster(this);

        //Returns a string that can be used in a client
        //event to cause postback to the server.
        Page.ClientScript.GetPostBackEventReference(this, String.Empty);

        //set the character set, since all pages derive from basemaster
        //this will set the encoding for all pages...
        Response.ContentEncoding = Encoding.UTF8;

        //init status info and objects
        m_strStatusComment = string.Empty;
        m_lStatusCode      = -1;//-1 = success no show

        //04/16/2012 - Security Updates
        //set the timeout
        Timeout = (Session.Timeout < 15) ? Timeout = 15 : Timeout = Session.Timeout;

        //connect to the data source
        if (!ConnectToDataSource())
        {
            //redirect to an error page
            Response.Redirect("error_database.aspx");
            Response.End();
        }

        //sec helper
        CSec sec = new CSec();

        //DBSessionID gets set in the database when the user
        //logs in. this is used to cache values in the db and to determine if the
        //user is logged in
        //
        //reset FXUserID, only gets set in the call below
        FXUserID = 0;
        if (!String.IsNullOrEmpty(DBSessionID))
        {
            //get actual user id from the database session created when the
            //user logs in
            string strUID = "";
            if (GetSessionValue("FX_USER_ID", out strUID))
            {
                if (strUID != "")
                {
                    FXUserID = Convert.ToInt32(strUID);
                }

                //load the app specific user details
                //needed for the application
                APPMaster.LoadUserDetails();
            }
            else
            {
                //log off if we cannot retrieve a valid session,
                //user timed out
                LogOff();
            }
        }

        //user does not have access to this page
        //so logoff.
        if (!sec.AuditPageAccess(this))
        {
            LogOff();
        }

        string strPageName = this.GetPageName();

        if (strPageName.IndexOf("event_management.aspx") != -1)
        {
            Response.AddHeader("X-UA-Compatible", "IE=8,chrome=1");
        }
        else
        {
            Response.AddHeader("X-UA-Compatible", "IE=9,chrome=1");
        }
    }
示例#2
0
    /// <summary>
    /// this is the proper place to do initialization in a master page
    /// </summary>
    /// <param name="sender"></param>
    /// <param name="e"></param>
    protected void Page_Init(object sender, EventArgs e)
    {
        //app specific stuff outside the base controller
        APPMaster = new AppMaster();
        APPMaster.SetBaseMaster(this);

        //Returns a string that can be used in a client
        //event to cause postback to the server.
        Page.ClientScript.GetPostBackEventReference(this, String.Empty);

        //set the character set, since all pages derive from basemaster
        //this will set the encoding for all pages...
        Response.ContentEncoding = Encoding.UTF8;

        //init status info and objects
        m_strStatusComment = "";
        m_lStatusCode      = -1;//-1 = success no show

        //04/16/2012 - Security Updates
        //set the timeout
        if (Session.Timeout < 15)
        {
            Timeout = 15;
        }
        else
        {
            Timeout = Session.Timeout;
        }


        //connect to the data source
        if (!ConnectToDataSource())
        {
            //redirect to an error page
            Response.Redirect("error_database.aspx");
            Response.End();
        }

        //sec helper
        CSec sec = new CSec();

        //auto-login with CAC/cert NO!
        //from the inspection user must click banner
        //so no auto login here

        /*if (!IsPostBack)
         * {
         *  string strPage = GetPageName();
         *  if (strPage != "fx_logoff.aspx")
         *  {
         *      //don't try to login if we clicked the logoff option
         *      if (Request.QueryString["logoff"] == null)
         *      {
         *          //attempt a cac cert login
         *          if (Session["SessionID"] == null)
         *          {
         *              //auto login with the cert on the CAC...
         *              sec.CertLogin(this);
         *          }
         *      }
         *  }
         * }*/

        //get sessionid if set - set user id if session is ok
        //Session["SessionID"] gets set in the database when the user
        //logs in. this is used to cache values in the db and also
        //force timeouts etc....

        /*       if (Session["SessionID"] != null)
         *     {
         *         m_strSessionID = Session["SessionID"].ToString();
         *
         *         //get actual user id
         *         string strUID = "";
         *         if (GetSessionValue("FX_USER_ID", out strUID))
         *         {
         *             if (strUID != "")
         *             {
         *                 m_lFXUserID = Convert.ToInt32(strUID);
         *             }
         *
         *             //load the app specific user details
         *             //needed for the application
         *             APPMaster.LoadUserDetails();
         *         }
         *     }
         *     else
         *     {
         *         //default to ASP.net session if we have not logged in
         *         m_strSessionID = Context.Session.SessionID;
         *     }
         */

        //DBSessionID gets set in the database when the user
        //logs in. this is used to cache values in the db and to determine if the
        //user is logged in
        //
        //reset FXUserID, only gets set in the call below
        FXUserID = 0;
        if (!String.IsNullOrEmpty(DBSessionID))
        {
            //get actual user id from the database session created when the
            //user logs in
            string strUID = "";
            if (GetSessionValue("FX_USER_ID", out strUID))
            {
                if (strUID != "")
                {
                    FXUserID = Convert.ToInt32(strUID);
                }

                //load the app specific user details
                //needed for the application
                APPMaster.LoadUserDetails();
            }
            else
            {
                //log off if we cannot retrieve a valid session,
                //user timed out
                LogOff();
            }
        }

        //user does not have access to this page
        //so logoff.
        if (!sec.AuditPageAccess(this))
        {
            LogOff();
        }

        long lNewModuleID = -1;

        //keep the module id, page id and random data segment
        if (Request.QueryString["mid"] != null)
        {
            string strModuleID;
            GetSessionValue("CURR_MODULE_ID", out strModuleID);

            if (strModuleID != Request.QueryString["mid"].ToString())
            {
                lNewModuleID = 1;
            }
            else
            {
                lNewModuleID = -1;
            }
            m_lModuleID = Convert.ToInt32(Request.QueryString["mid"].ToString());
            SetSessionValue("CURR_MODULE_ID", Convert.ToString(m_lModuleID));
        }

        if (Request.QueryString["pid"] != null)
        {
            if (lNewModuleID != -1)
            {
                m_lPageID = -1;
            }
            else
            {
                m_lPageID = Convert.ToInt32(Request.QueryString["pid"].ToString());
            }

            SetSessionValue("CURR_PAGE_ID", Convert.ToString(m_lPageID));
        }

        if (Request.QueryString["rds"] != null)
        {
            m_strRDS = Request.QueryString["rds"].ToString();
        }

        if (m_lModuleID < 1)
        {
            string strModuleID = "";
            if (m_lFXUserID > 0)
            {
                GetSessionValue("CURR_MODULE_ID", out strModuleID);
                if (strModuleID != "")
                {
                    m_lModuleID = Convert.ToInt32(strModuleID);
                }
            }
        }

        if (m_lModuleID < 1)
        {
            string strModuleID = "";
            if (m_lFXUserID > 0)
            {
                GetSessionValue("CURR_MODULE_ID", out strModuleID);
                if (strModuleID != "")
                {
                    m_lModuleID = Convert.ToInt32(strModuleID);
                }
            }
        }

        if (m_lPageID < 1)
        {
            string strPageID = "";
            if (m_lFXUserID > 0)
            {
                GetSessionValue("CURR_PAGE_ID", out strPageID);
                if (strPageID != "")
                {
                    m_lPageID = Convert.ToInt32(strPageID);
                }
            }
        }
    }