Ejemplo n.º 1
0
        /// <summary>
        /// Saves the value of a survey checkbox control. Should only be called when the control is visible.
        /// </summary>
        /// <param name="control"></param>
        public static void SaveValue(SurveyCheckBox control)
        {
            //Get value from postback
            bool postValue = (!String.IsNullOrEmpty(RequestVars.Post <string>(control.UniqueID, null)));

            control.Checked = postValue;
            SessionWrapper.Add(control.SessionKey, new SurveySessionControl <bool>(postValue));
            //if ( control.Checked ) {
            //    if ( !SessionWrapper.Get( control.SessionKey, new SurveySessionControl<bool>( false ) ).Value || postValue ) {
            //        //If it wasn't checked already or it's the same one as before, check it.
            //        SessionWrapper.Add( control.SessionKey, new SurveySessionControl<bool>( true ) );
            //        control.Checked = true;
            //    } else {
            //        //Uncheck other radio buttons that may have been flagged as checked if we know that we've already found a checked one.
            //        SessionWrapper.Add( control.SessionKey, new SurveySessionControl<bool>( false ) );
            //        control.Checked = false;
            //    }
            //} else {
            //    SessionWrapper.Add( control.SessionKey, new SurveySessionControl<bool>( false ) );
            //    control.Checked = false;
            //}
            //SurveyRadioButton rad = control as SurveyRadioButton;
            //if ( rad != null ) {

            //    return;
            //}
            //SaveValue<bool>( control );
        }
Ejemplo n.º 2
0
        public static void SaveRadioButtons(params SurveyRadioButton[] buttonsInGroup)
        {
            bool foundNew = false;

            foreach (SurveyRadioButton rad in buttonsInGroup)
            {
                if (rad.Checked && !SessionWrapper.Get(rad.SessionKey, new SurveySessionControl <bool>(false)).Value)
                {
                    foundNew = true;
                }
            }
            foreach (SurveyRadioButton rad in buttonsInGroup)
            {
                if (rad.Checked)
                {
                    if (!SessionWrapper.Get(rad.SessionKey, new SurveySessionControl <bool>(false)).Value || !foundNew)
                    {
                        //If it wasn't checked already or it's the same one as before, check it.
                        SessionWrapper.Add(rad.SessionKey, new SurveySessionControl <bool>(true));
                        rad.Checked = true;
                    }
                    else if (foundNew)
                    {
                        //Uncheck other radio buttons that may have been flagged as checked if we know that we've already found a checked one.
                        SessionWrapper.Add(rad.SessionKey, new SurveySessionControl <bool>(false));
                        rad.Checked = false;
                    }
                }
                else
                {
                    SessionWrapper.Add(rad.SessionKey, new SurveySessionControl <bool>(false));
                    rad.Checked = false;
                }
            }
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Saves the value of a control into the session.
 /// </summary>
 /// <param name="control">The control to save the value of session.</param>
 public static void SaveValue <T>(ISurveyControl <T> control)
 {
     if (control is SurveyCheckBox)
     {
         SaveValue(control as SurveyCheckBox);
     }
     else
     {
         SessionWrapper.Add(control.SessionKey, new SurveySessionControl <T>(control.GetValue()));
     }
 }
Ejemplo n.º 4
0
        public void Save()
        {
            List <string> selected = new List <string>();

            foreach (ListItem li in Items)
            {
                if (li.Selected)
                {
                    selected.Add(li.Value);
                }
            }
            SessionWrapper.Add(SessionKey, selected);
        }
Ejemplo n.º 5
0
        protected void Application_AcquireRequestState(object sender, EventArgs e)
        {
            //If the session doesn't exist, culture probably doesn't apply to this request. For example, this will happen when favicon.ico is requested.
            if (HttpContext.Current.Session == null)
            {
                return;
            }

            //Figure out the culture of the current request.
            string cultureName;

            //See if we have a session variable. If not, check for a cookie from last time.
            if (!SessionWrapper.Exists("DisplayLanguage"))
            {
                //No session, let's check the cookie
                HttpCookie cook = HttpContext.Current.Request.Cookies["DisplayLanguage"];
                if (cook != null && cook.Value.Equals("fr-CA"))
                {
                    //Found French cookie
                    cultureName = "fr-CA";
                }
                else
                {
                    //No cookie or cookie not French, default to English-Canada
                    cultureName = "en-CA";
                }
                //Save in session for future requests
                SessionWrapper.Add("DisplayLanguage", cultureName);
            }
            else
            {
                //Session value exists, load it
                cultureName = SessionWrapper.Get("DisplayLanguage", "en-CA");
            }

            //Don't do anything if it's the same culture
            if (Thread.CurrentThread.CurrentUICulture.Name == cultureName)
            {
                return;
            }

            //Set the thread culture
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(cultureName);
            Thread.CurrentThread.CurrentCulture   = Thread.CurrentThread.CurrentUICulture;
        }
Ejemplo n.º 6
0
        private void Application_Error(object sender, EventArgs e)
        {
            //Log ALL uncaught exceptions
            Exception exc = Server.GetLastError();

            if (exc is HttpUnhandledException)
            {
                exc = Context.Error.InnerException;
            }

            int dberrid = ErrorHandler.WriteLog("Uncaught", "Uncaught exception was unhandled.",
                                                ErrorHandler.ErrorEventID.General, exc);

            if (dberrid > -1)
            {
                SessionWrapper.Add("CaughtExceptionID", dberrid);
            }
        }
        /// <summary>
        ///     Perform password reset
        /// </summary>
        /// <param name="isGuidReset">is this a password retrieval?</param>
        public void ResetPassword(bool isGuidReset)
        {
            string         pass       = Request.Form["pwd"];     //Old password
            string         newpass1   = Request.Form["newpwd1"]; //New passwords
            string         newpass2   = Request.Form["newpwd2"];
            LoginErrorCode loginError = LoginErrorCode.UnknownError;
            UserInfo       user       = UserData;

            //If this isn't a GUID-based reset (we already checked those)
            if (!isGuidReset)
            {
                int outputValue;
                user       = UserInformation.LogUserIn <UserInfo>(user.Email, pass, true, Config.ClientID, out outputValue);
                loginError = (LoginErrorCode)outputValue;
                if (loginError != LoginErrorCode.Success)
                {
                    user = SessionWrapper.Get <UserInfo>("UserInfo", null);
                    switch (loginError)
                    {
                    case LoginErrorCode.NoUserOrEmailSpecified:
                        mmMessages.ErrorMessage = "Please enter your old password.";
                        return;

                    case LoginErrorCode.LoginFailed:
                        mmMessages.ErrorMessage = "Invalid password.";
                        return;

                    case LoginErrorCode.UserLockedOut:
                        mmMessages.ErrorMessage = "This account has been locked out. Please try again in 30 minutes.";
                        return;

                    case LoginErrorCode.UserOrEmailNotExists:
                        mmMessages.ErrorMessage = "This user doesn't appear to exist. If you think this is an error, please contact the administrator.";
                        return;
                    }
                }
            }
            if (user == null)
            {
                //Error message!
                mmMessages.ErrorMessage = "We're sorry. We couldn't find the user associated with this account. Please try again.";
                return;
            }
            UserData = user;
            //Validate new password
            if (newpass1 != newpass2)
            {
                mmMessages.ErrorMessage = "These new passwords don't match.";
                return;
            }
            //try to update password and return error message if invalid
            string error;

            if (!UserData.UpdatePassword(newpass1, out error))
            {
                mmMessages.ErrorMessage = error;
                return;
            }

            int rows = UserData.ClearLoginAttempts();

#if DEBUG
            Debug.WriteLine("{0} Login Attempts deleted");
#endif

            //Get user with new password to make sure that everything is OK
            int outputValue2;
            UserData = UserInformation.LogUserIn <UserInfo>(UserData.Email, newpass1, true, Config.ClientID, out outputValue2);

            if (UserData == null)
            {
                if (user != null)
                {
                    UserData = user;
                }
                else
                {
                    UserData = SessionWrapper.Get <UserInfo>("UserInfo", null);
                }

                mmMessages.ErrorMessage = "There was a database level error while attempting to save this user. Please contact the administrator if this error persists.";
                return;
            }

            SessionWrapper.Add("UserInfo", UserData);

            string redir = RequestVars.Get("rd", String.Empty);
            if (!String.IsNullOrEmpty(redir))
            {
                redir = "?rd=" + HttpContext.Current.Server.UrlEncode(redir);
            }
            Response.Redirect("/Director.ashx" + redir);
        }
Ejemplo n.º 8
0
 public void Save()
 {
     SessionWrapper.Add(SessionKey, SelectedIndex);
 }
        protected void Page_LoadComplete(object sender, EventArgs e)
        {
            Title = "Hastings Racecourse Customer Survey";
            //Check all previous pages
            //Must do in LoadComplete because controls load values in Load method
            SessionWrapper.Add("HastingsSurveyPageNumber", CurrentPage);
            if (CurrentPage > 1 && CurrentPage != 99 && !IsPostBack)
            {
                for (int i = 1; i < CurrentPage; i++)
                {
                    //System.Diagnostics.Debug.WriteLine( "Checking Page: " + i );
                    if (!ValidateAndSave(i, false, false))
                    {
                        //System.Diagnostics.Debug.WriteLine( "Invalid Page: " + i );
                        if (CurrentPage == 97)
                        {
                            continue;
                        }
                        Response.Redirect(GetURL(i, 1), true);
                        return;
                    }
                }
                //if (PageShouldBeSkipped(CurrentPage))
                //{
                //    int nextPage = CurrentPage + RedirectDirection;
                //    if (CurrentPage == 22 && RedirectDirection == 1)
                //    {
                //        nextPage = 97;
                //        //return;
                //    }
                //    Response.Redirect(GetSurveyURL(nextPage, RedirectDirection), true);
                //    return;
                //}

                //If we've made it to 97, save to database.
                if (CurrentPage == 97 && !IsPostBack)
                {
                    int surveyID;
                    if (SaveData(out surveyID))
                    {
                        //SendNotifications(surveyID);
                        HastingsComplete = true;
                        Session.Abandon();
                        SurveyComplete.SuccessMessage = "Thank you for your feedback. We will use your responses in our ongoing efforts to make your visits exciting and memorable.<br /><br />Please Note: If you have requested someone to contact you, please ensure you check your \"Junk Mail\" folder or add \"@gcgamingsurvey.com\" to your email account's white list.";
                    }
                    else
                    {
                        StringBuilder sb = new StringBuilder();
                        foreach (string key in Session.Keys)
                        {
                            object        val = Session[key];
                            List <string> ls  = val as List <string>;
                            if (ls != null)
                            {
                                sb.AppendFormat("\"{0}\": {1}", key, String.Join(", ", ls));
                            }
                            else
                            {
                                sb.AppendFormat("\"{0}\": {1}", key, val);
                            }
                        }
                        //ErrorHandler.WriteLog("GCC_Web_Portal.SurveyGEI", "Unable to save responses.\n\nSession Variables:\n\n" + sb.ToString(), ErrorHandler.ErrorEventID.General);
                        SurveyComplete.ErrorMessage = "We were unable to save your responses. Please go back and try again.";
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public void Save()
 {
     SessionWrapper.Add(SessionKey + "_BeginDate", BeginDate);
     SessionWrapper.Add(SessionKey + "_EndDate", EndDate);
 }
Ejemplo n.º 11
0
 public void Save()
 {
     SessionWrapper.Add(SessionKey, Text);
 }