示例#1
0
        protected void SignUpForSelectedRole(int RoleToSignUp, int UserID, int CampaignID, int StatusID)
        {
            int    CampaignPlayerID = 0;
            string Username         = "";

            if (Session["Username"] == null)
            {
                Username = "";
            }
            else
            {
                Username = Session["Username"].ToString();
            }
            Classes.cUserCampaign CampaignPlayer = new Classes.cUserCampaign();
            CampaignPlayer.Load(UserID, CampaignID);
            CampaignPlayerID = CampaignPlayer.CampaignPlayerID; // if this comes back empty (-1) make one
            if (CampaignPlayerID == -1)
            {
                CreatePlayerInCampaign(UserID, CampaignID);
                CampaignPlayer.Load(UserID, CampaignID);
                CampaignPlayerID = CampaignPlayer.CampaignPlayerID;
            }
            int RoleAlignment = 2;

            if (RoleToSignUp == 8)
            {
                RoleAlignment = 1;
            }
            Classes.cPlayerRole PlayerRole = new Classes.cPlayerRole();
            PlayerRole.CampaignPlayerRoleID = -1;
            PlayerRole.CampaignPlayerID     = CampaignPlayerID;
            PlayerRole.RoleID          = RoleToSignUp;
            PlayerRole.RoleAlignmentID = RoleAlignment;
            PlayerRole.Save(UserID);
            if (Username != "")
            {
                Classes.cUser LastLogged   = new Classes.cUser(Username, "Password");
                string        LastCampaign = LastLogged.LastLoggedInCampaign.ToString();
                if (LastCampaign == null || LastCampaign == "0")
                {
                    LastLogged.LastLoggedInCampaign = CampaignID;
                    LastLogged.Save();
                    Session["CampaignID"] = CampaignID;
                }
            }
        }
示例#2
0
        protected void ddlCampaigns_SelectedIndexChanged(object sender, EventArgs e)
        {
            MethodBase lmth          = MethodBase.GetCurrentMethod();
            string     lsRoutineName = lmth.DeclaringType + "." + lmth.Name;

            if (ddlCampaigns.SelectedValue == "-1")
            {
                Response.Redirect("~/Campaigns/JoinACampaign.aspx");
            }

            //			Classes.LogWriter oLogWriter = new Classes.LogWriter();

            // If the campaign ID has changed...
            if (CampaignID.ToString() != ddlCampaigns.SelectedValue)
            {
                //				oLogWriter.AddLogMessage("Starting to change campaign from " + CampaignID.ToString() + " to " + ddlCampaigns.SelectedValue, "Master.ddlCampaigns_SelectedIndexChanged", "", Session.SessionID);
                int iCampaignID;
                if (int.TryParse(ddlCampaigns.SelectedValue, out iCampaignID))
                {
                    Session["CampaignID"]   = iCampaignID;
                    Session["CampaignName"] = ddlCampaigns.SelectedItem.Text;

                    //					oLogWriter.AddLogMessage("New campaign will be " + iCampaignID.ToString(), "Master.ddlCampaigns_SelectedIndexChanged", "", Session.SessionID);

                    if (iCampaignID > 0)
                    {
                        // Since the campaign has changed, need to save the last campaign to the database.

                        Classes.cUser      UserInfo  = new Classes.cUser(UserName, "NOPASSWORD", Session.SessionID);
                        Classes.cUtilities utilities = new Classes.cUtilities();
                        SortedList         sParams   = new SortedList();
                        sParams.Add("@intUserId", UserID);
                        DataTable dtCharList = Classes.cUtilities.LoadDataTable("uspGetCharacterIDsByUserID", sParams, "LARPortal", UserName, lsRoutineName + ".GetCharList");
                        DataView  dvCampChar = new DataView(dtCharList, "CampaignID = " + iCampaignID.ToString(), "CharacterAKA", DataViewRowState.CurrentRows);
                        if (dvCampChar.Count > 0)
                        {
                            int iTemp;
                            if (int.TryParse(dvCampChar[0]["CharacterID"].ToString(), out iTemp))
                            {
                                UserInfo.LastLoggedInCharacter    = iTemp;
                                UserInfo.LastLoggedInMyCharOrCamp = "M";
                            }
                        }
                        else
                        {
                            UserInfo.LastLoggedInCharacter = -1;
                        }
                        UserInfo.LastLoggedInCampaign = iCampaignID;
                        UserInfo.Save();

                        Classes.cCampaignBase Campaign = new Classes.cCampaignBase(iCampaignID, UserName, UserID);



                        //oLogWriter.AddLogMessage("UserInfo was saved." + UserInfo.LastLoggedInCampaign.ToString(), "Master.ddlCampaigns_SelectedIndexChanged", "", Session.SessionID);
                        //Classes.cUser NewUserInfo = new Classes.cUser(UserName, "NOPASSWORD", Session.SessionID);
                        //oLogWriter.AddLogMessage("CampaignID after update was " + NewUserInfo.LastLoggedInCampaign.ToString(), "Master.ddlCampaigns_SelectedIndexChanged", "", Session.SessionID);

                        // Now that we have saved the campaign ID to the database, clear the session variables so it will force a reload.
                        Session.Remove("CampaignID");
                        Session.Remove("CampaignName");
                        Session.Remove("CampaignList");
                        Session.Remove("RoleString");

                        LoadData();

                        if (CampaignChanged != null)
                        {
                            CampaignChanged(this, EventArgs.Empty);
                        }
                    }
                    //					oLogWriter.AddLogMessage("Done with adding." + CampaignID.ToString(), "Master.ddlCampaigns_SelectedIndexChanged", "", Session.SessionID);
                }
            }
        }
示例#3
0
        protected void ddlUserCampaigns_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (ddlUserCampaigns.SelectedValue == "-1")
            {
                Response.Redirect("~/PublicCampaigns.aspx");
            }
            int    intUserID;
            string SelectedText;
            string SelectedValue;

            SelectedText  = ddlUserCampaigns.SelectedItem.Text.ToString();
            SelectedValue = ddlUserCampaigns.SelectedItem.Value.ToString();
            if (Session["UserID"] == null)
            {
                intUserID = -1;    // In theory we can't actually get here so we should just go back to login
                Response.Redirect("~/index.aspx");
            }
            else
            {
                intUserID = Session["UserID"].ToString().ToInt32();
            }
            Classes.cUser User = new Classes.cUser(Session["Username"].ToString(), "PasswordNotNeeded");
            User.UserID = intUserID;
            User.LastLoggedInCampaign = ddlUserCampaigns.SelectedItem.Value.ToInt32();
            Session["CampaignID"]     = ddlUserCampaigns.SelectedItem.Value.ToInt32();
            Session["CampaignName"]   = ddlUserCampaigns.SelectedItem.Text.ToString();
            User.SetCharacterForCampaignUser(intUserID, ddlUserCampaigns.SelectedItem.Value.ToInt32());
            Session["SelectedCharacter"]  = User.LastLoggedInCharacter;
            User.LastLoggedInMyCharOrCamp = "M";    // 5/27/2017-RPierce - If switching campaign list, assume switching to my characters on character tab
            User.Save();
            // 5/27/2018 - RPierce - Remove Campaign Character session variables
            if (Session["CharacterCampaignCharID"] != null)
            {
                Session.Remove("CharacterCampaignCharID");
            }
            if (Session["CharacterSelectCampaign"] != null)
            {
                Session.Remove("CharacterSelectCampaign");
            }
            if (Session["CharacterSelectGroup"] != null)
            {
                Session.Remove("CharacterSelectGroup");
            }
            if (Session["CharacterSelectID"] != null)
            {
                Session.Remove("CharacterSelectID");
            }
            if (Session["CampaignsToEdit"] != null)
            {
                Session.Remove("CampaignsToEdit");
            }
            if (Session["MyCharacters"] != null)
            {
                Session.Remove("MyCharacters");
            }
            // Go get all roles for that campaign and load them into a session variable
            Classes.cPlayerRoles Roles = new Classes.cPlayerRoles();
            Roles.Load(intUserID, 0, ddlUserCampaigns.SelectedItem.Value.ToInt32(), DateTime.Today);
            Session["PlayerRoleString"] = Roles.PlayerRoleString;
            Classes.cURLPermission permissions = new Classes.cURLPermission();
            bool   PagePermission         = true;
            string DefaultUnauthorizedURL = "";

            permissions.GetURLPermissions(Request.RawUrl, intUserID, Roles.PlayerRoleString);
            PagePermission         = permissions._PagePermission;
            DefaultUnauthorizedURL = permissions._DefaultUnauthorizedURL;
            string ReportCheck = Request.RawUrl.Substring(0, 8);

            if (PagePermission == true)
            {
                if (ReportCheck == "/Reports")
                {
                    Response.Redirect("/Reports/ReportsList.aspx");
                }
                else
                {
                    Response.Redirect(Request.RawUrl);
                }
            }

            else
            {
                Response.Redirect(DefaultUnauthorizedURL);
            }
        }
示例#4
0
 protected void btnSignUp_Click(object sender, EventArgs e)
 {
     if (Session["AttemptedPassword"] == null)
     {
         txtPasswordNew.Text = "";
     }
     else
     {
         txtPasswordNew.Text = Session["AttemptedPassword"].ToString();
         txtPasswordNew.Attributes.Add("value", txtPasswordNew.Text);
     }
     if (Session["AttemptedPasswordRetype"] == null)
     {
         txtPasswordNewRetype.Text = "";
     }
     else
     {
         txtPasswordNewRetype.Text = Session["AttemptedPasswordRetype"].ToString();
         txtPasswordNewRetype.Attributes.Add("value", txtPasswordNewRetype.Text);
     }
     if (Page.IsValid)
     {
         lblSignUpErrors.Text = "";
         // 1 - No duplicate usernames allowed
         Classes.cLogin Login = new Classes.cLogin();
         Login.CheckForExistingUsername(txtNewUsername.Text);
         if (Login.MemberID != 0)  // UserID is taken
         {
             lblSignUpErrors.Text = "This username is already in use.  Please select a different one.";
         }
         // 2 - Password must meet parameter standards
         int            ValidPassword;
         Classes.cLogin PasswordValidate = new Classes.cLogin();
         PasswordValidate.ValidateNewPassword(txtPasswordNew.Text);
         ValidPassword = PasswordValidate.PasswordValidation;
         if (ValidPassword == 0)
         {
             if (lblSignUpErrors.Text != "")
             {
                 lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>" + PasswordValidate.PasswordFailMessage + ".";
             }
             else
             {
                 lblSignUpErrors.Text = PasswordValidate.PasswordFailMessage + ".";
             }
         }
         // 3 - Both passwords must be the same
         if (txtPasswordNew.Text != txtPasswordNewRetype.Text)
         //set an error message
         {
             if (lblSignUpErrors.Text != "")
             {
                 lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>Passwords don't match.  Please re-enter.";
             }
             else
             {
                 lblSignUpErrors.Text = "Passwords don't match.  Please re-enter.";
             }
             txtPasswordNew.Text       = "";
             txtPasswordNewRetype.Text = "";
         }
         // 4 - New request - If the email address is already on file, warn them and suggest they go to the Forgot Username / Password section
         Classes.cLogin ExistingEmailAddress = new Classes.cLogin();
         ExistingEmailAddress.GetUsernameByEmail(txtEmail.Text);
         if (ExistingEmailAddress.Username != "")
         {
             if (lblSignUpErrors.Text != "")
             {
                 lblSignUpErrors.Text = lblSignUpErrors.Text + "<p></p>This email address is already associated with an account.  If you've forgotten your username or password, please use the link above.";
             }
             else
             {
                 lblSignUpErrors.Text = "This email address is already associated with an account.  If you've forgotten your username or password, please use the link above.";
             }
         }
         // If there were errors, display them and return to form
         if (lblSignUpErrors.Text != "")
         {
             lblSignUpErrors.Visible = true;
             txtNewUsername.Focus();
         }
         else
         {
             // Everything is ok.  Create the record.  If successful, go to the member demographics screen.
             Classes.cUser NewUser = new Classes.cUser(txtNewUsername.Text, txtPasswordNew.Text);
             NewUser.FirstName     = txtFirstName.Text;
             NewUser.LastName      = txtLastName.Text;
             NewUser.LoginPassword = txtPasswordNew.Text;
             NewUser.LoginEmail    = txtEmail.Text;
             NewUser.LoginName     = txtNewUsername.Text;
             NewUser.Save();
             Classes.cLogin Activation = new Classes.cLogin();
             Activation.Load(txtNewUsername.Text, txtPasswordNew.Text);
             string ActivationKey = "";
             ActivationKey = Activation.SecurityResetCode;
             GenerateWelcomeEmail(txtFirstName.Text, txtLastName.Text, txtNewUsername.Text, txtEmail.Text, ActivationKey);
             Response.Write("<script>");
             Response.Write("window.open('NewUserLoginDirections.aspx','_blank')");
             Response.Write("</script>");
             // TODO-Rick-0e Account for versioning of 'terms of use' and keeping track of date/time and which version user agreed to
         }
     }
     else
     {
         // TODO-Rick-3 On create user if something totally unexpected is wrong put up a message
     }
 }
示例#5
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            //Since no matter what happens in this routine we want to preserve the state of the grids, we bind them now
            BindAllGrids();

            if (!string.IsNullOrWhiteSpace(txtFirstName.Text))
            {
                Demography.FirstName = txtFirstName.Text.Trim();
            }

            Demography.MiddleName = txtMI.Text.Trim(); //I should be able to remove my middle initial if I want

            if (!string.IsNullOrWhiteSpace(txtLastName.Text))
            {
                Demography.LastName = txtLastName.Text.Trim();
            }

            if (ddlGender.SelectedIndex != -1)
            {
                PLDemography.GenderStandared = ddlGender.SelectedValue;
            }

            PLDemography.GenderOther = txtGenderOther.Text; //We shall trust this value since the select event clears the text when needed

            Demography.NickName = txtNickname.Text;

            if (string.IsNullOrWhiteSpace(txtUsername.Text)) //If left empty set back to original setting...They may not remember it....
            {
                txtUsername.Text = Demography.LoginName;
            }

            // 1 - No duplicate usernames allowed
            Classes.cLogin Login = new Classes.cLogin();
            Login.CheckForExistingUsername(txtUsername.Text);
            if (Login.MemberID != 0 && Login.MemberID != Demography.UserID)  // UserID is taken
            {
                lblMessage.Text = "This username is already in use.  Please select a different one.";
                txtUsername.Focus();
                return;
            }
            else
            {
                Demography.LoginName = txtUsername.Text.Trim();
            }

            DateTime dob;

            if (DateTime.TryParse(txtDOB.Text, out dob))
            {
                PLDemography.DateOfBirth = dob;
            }
            else
            {
                lblMessage.Text = "Please enter a valid date";
                txtDOB.Focus();
                return;
            }

            PLDemography.AuthorName  = txtPenname.Text;
            Demography.ForumUserName = txtForumname.Text;

            PLDemography.EmergencyContactName = txtEmergencyName.Text;

            // Using the inital records merge result with the new ones.
            if (AddressesChangesValidate() == false)
            {
                return;
            }

            if (PhoneNumbersChangesValidate() == false)
            {
                return;
            }

            if (EmailsChangesValidate() == false)
            {
                return;
            }

            if (!cPhone.isValidPhoneNumber(txtEmergencyPhone.Text, 10))
            {
                lblMessage.Text = cPhone.ErrorDescription;
                txtEmergencyPhone.Focus();
                return;
            }

            if (PLDemography.EmergencyContactPhone != txtEmergencyPhone.Text)
            {
                PLDemography.EmergencyContactPhone = txtEmergencyPhone.Text;
            }

            /* 3) handle picture update/add.
             */

            //At this point all validation must have been done so it is time to merge lists
            AddressesChangesUpdate();
            PhonesChangesUpdate();
            EmailsChangesUpdate();

            if (Session["dem_Img_Url"] != null)
            {
                PLDemography.UserPhoto  = Session["dem_Img_Url"].ToString();
                imgPlayerImage.ImageUrl = Session["dem_Img_Url"].ToString();
                Session["dem_Img_Url"]  = "";
                Session.Remove("dem_Img_Id");

                //Classes.cPicture NewPicture = new Classes.cPicture();
                //int iPictureId =0;
                //if (Session["dem_Img_Id"] != null && Int32.TryParse(Session["dem_Img_Id"].ToString(), out iPictureId))
                //{
                //    //This code will be enabled once the stored procedure is created
                //    string userID = Session["UserID"].ToString();
                //    //NewPicture.Load(iPictureId, userID);
                //    //NewPicture.PictureFileName = NewPicture.PictureFileName.Replace("_2", "_1");
                //    //NewPicture.Save(userID);
                //    //Time to trash the old main picture with the picture in memory
                //    //PLDemography.UserPhoto = NewPicture.PictureFileName;
                //}
            }

            /* As I validate I will place the new values on the component prior to saving the values*/
            Demography.Save();
            PLDemography.Save();
            Session["Username"] = Demography.LoginName;

            lblMessage.Text = "Changes saved successfully.";
        }