Esempio n. 1
0
 /// <summary>
 /// This method adds a user's selected program role information to the session
 /// </summary>
 /// <param name="session">The current session state</param>
 /// <param name="programAndRole">The program, role, hub and state information to store in session</param>
 /// <returns>The program role name if it exists, null otherwise</returns>
 public static void SetProgramRoleInSession(HttpSessionState session, ProgramAndRoleFromSession programAndRole)
 {
     try
     {
         session["CodeProgramRoleFK"]        = programAndRole.RoleFK;
         session["ProgramRoleName"]          = programAndRole.RoleName;
         session["ProgramRoleAllowedToEdit"] = programAndRole.AllowedToEdit;
         session["CurrentProgramFK"]         = programAndRole.CurrentProgramFK;
         session["ProgramFKs"]        = programAndRole.ProgramFKs;
         session["ProgramName"]       = programAndRole.ProgramName;
         session["BOQOnly"]           = programAndRole.ShowBOQ;
         session["BOQFCCOnly"]        = programAndRole.ShowBOQFCC;
         session["HubFK"]             = programAndRole.HubFK;
         session["HubName"]           = programAndRole.HubName;
         session["StateFK"]           = programAndRole.StateFK;
         session["StateName"]         = programAndRole.StateName;
         session["StateLogoFileName"] = programAndRole.StateLogoFileName;
         session["StateCatchphrase"]  = programAndRole.StateCatchphrase;
         session["StateDisclaimer"]   = programAndRole.StateDisclaimer;
         session["CohortFKs"]         = programAndRole.CohortFKs;
     }
     catch (Exception ex)
     {
         //It failed, log the exception
         LogException(ex);
     }
 }
Esempio n. 2
0
        /// <summary>
        /// This method returns a user's program role from the session
        /// </summary>
        /// <param name="session">The current session state</param>
        /// <returns>The program role name if it exists, null otherwise</returns>
        public static ProgramAndRoleFromSession GetProgramRoleFromSession(HttpSessionState session)
        {
            ProgramAndRoleFromSession returnObj = new ProgramAndRoleFromSession();

            try
            {
                //Try to get the program role name and program from session
                returnObj.RoleFK            = (session["CodeProgramRoleFK"] != null ? Convert.ToInt32(session["CodeProgramRoleFK"].ToString()) : (int?)null);
                returnObj.RoleName          = (session["ProgramRoleName"] != null ? session["ProgramRoleName"].ToString() : null);
                returnObj.AllowedToEdit     = (session["ProgramRoleAllowedToEdit"] != null ? Convert.ToBoolean(session["ProgramRoleAllowedToEdit"].ToString()) : (bool?)null);
                returnObj.CurrentProgramFK  = (session["CurrentProgramFK"] != null ? Convert.ToInt32(session["CurrentProgramFK"].ToString()) : (int?)null);
                returnObj.ProgramFKs        = (session["ProgramFKs"] != null ? (List <int>)session["ProgramFKs"] : null);
                returnObj.ProgramName       = (session["ProgramName"] != null ? session["ProgramName"].ToString() : null);
                returnObj.ShowBOQ           = (session["BOQOnly"] != null ? Convert.ToBoolean(session["BOQOnly"]) : (bool?)null);
                returnObj.ShowBOQFCC        = (session["BOQFCCOnly"] != null ? Convert.ToBoolean(session["BOQFCCOnly"]) : (bool?)null);
                returnObj.HubFK             = (session["HubFK"] != null ? Convert.ToInt32(session["HubFK"].ToString()) : (int?)null);
                returnObj.HubName           = (session["HubName"] != null ? session["HubName"].ToString() : null);
                returnObj.StateFK           = (session["StateFK"] != null ? Convert.ToInt32(session["StateFK"].ToString()) : (int?)null);
                returnObj.StateName         = (session["StateName"] != null ? session["StateName"].ToString() : null);
                returnObj.StateLogoFileName = (session["StateLogoFileName"] != null ? session["StateLogoFileName"].ToString() : null);
                returnObj.StateCatchphrase  = (session["StateCatchphrase"] != null ? session["StateCatchphrase"].ToString() : null);
                returnObj.StateDisclaimer   = (session["StateDisclaimer"] != null ? session["StateDisclaimer"].ToString() : null);
                returnObj.CohortFKs         = (session["CohortFKs"] != null ? (List <int>)session["CohortFKs"] : null);
            }
            catch (Exception ex)
            {
                //It failed, log the exception
                LogException(ex);
            }

            //If the role from session does not have values, redirect the user
            if (!returnObj.RoleFK.HasValue || returnObj.RoleName == null || !returnObj.AllowedToEdit.HasValue ||
                !returnObj.CurrentProgramFK.HasValue || returnObj.ProgramName == null || !returnObj.HubFK.HasValue ||
                !returnObj.StateFK.HasValue)
            {
                if (HttpContext.Current.User != null && HttpContext.Current.User.Identity.IsAuthenticated)
                {
                    //If the user is logged in, redirect them to the SelectRole page.
                    HttpContext.Current.Response.Redirect(String.Format("/Account/SelectRole.aspx?ReturnUrl={0}&message={1}", HttpContext.Current.Request.Url.PathAndQuery, "LostSession"));
                }
                else
                {
                    //If the user is not logged in, redirect them to the login page
                    HttpContext.Current.Response.Redirect(String.Format("/Account/Login.aspx?ReturnUrl={0}", HttpContext.Current.Request.Url.PathAndQuery));
                }
            }

            //Return the program role
            return(returnObj);
        }
Esempio n. 3
0
        /// <summary>
        /// This method returns the application title based on the passed program role
        /// </summary>
        /// <param name="programRole">The program role</param>
        /// <returns>The application title string</returns>
        public static string GetApplicationTitle(ProgramAndRoleFromSession programRole)
        {
            //Get the application title
            StringBuilder applicationTitle = new StringBuilder();

            //Check to see if the program role has values
            if (programRole.CurrentProgramFK.HasValue)
            {
                //Get the app title values from the program role
                applicationTitle.Append("<span class='app-state-name'>" + programRole.StateName + " State</span>");
                applicationTitle.Append("<span class='app-name'>Pyramid Model Implementation Data System</span>");
                applicationTitle.Append((string.IsNullOrWhiteSpace(programRole.StateCatchphrase) ? "" : "<span class='app-state-catchphrase'>" + programRole.StateCatchphrase + "</span>"));
            }
            else
            {
                //Set to the default app title
                applicationTitle.Append("<span class='app-name'>Pyramid Model Implementation Data System</span>");
            }

            //Return the title
            return(applicationTitle.ToString());
        }