protected void btnEmail_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(PUsername.Text.Trim())) { var patron = Patron.GetObjectByUsername(PUsername.Text.Trim()); // Show message no matter what, even if we can't do it, because of hacking concerns if (patron == null || patron.EmailAddress == "") { lbMessage.Text = "Your account does not have an email address associated with it or you provided an incorrect email address, so we were unable to email you your password. <br><br> Please visit your local library branch to reset your password."; } else { lbMessage.Text = "Your password has been emailed to the email address associated with your account and should be arriving shortly. <br><br>Please check your email."; string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/'); var EmailBody = "<h1>Dear " + patron.FirstName + ",</h1><br><br>This is your current account information. Please make sure you reset your password as soon as you are able to log back in.<br><br>" + "Username: "******"<br>Password: "******"<br><br>If you have any questions regarding your account please contact " + SRPSettings.GetSettingValue("ContactName") + " at " + SRPSettings.GetSettingValue("ContactEmail") + "." + "<br><br><br><a href='" + baseUrl + "'>" + baseUrl + "</a> <br> "; EmailService.SendEmail(patron.EmailAddress, "Summer Reading Program - Password recovery", EmailBody); } Session["PatronLoggedIn"] = false; Session["Patron"] = null; } }
protected void Button1_Click(object sender, EventArgs e) { object tokenObject = this.ViewState["token"]; if (tokenObject == null) { passwordUpdate.Visible = false; invalidToken.Visible = true; return; } var user = SRPUser.UpdatePasswordByToken(tokenObject.ToString(), Password.Text); if (user == null) { passwordUpdate.Visible = false; invalidToken.Visible = true; return; } // user requested a password for an email address that is not in the database // if account doesn't exist, send an email saying so var values = new { SystemName = SRPSettings.GetSettingValue("SysName", user.TenID), ContactName = SRPSettings.GetSettingValue("ContactName", user.TenID), ContactEmail = SRPSettings.GetSettingValue("ContactEmail", user.TenID), RemoteAddress = new Tools.WebTools().RemoteUserAddress(Request), UserEmail = user.EmailAddress, ControlRoomLink = string.Format("{0}{1}", BaseUrl, "/ControlRoom/"), PasswordResetSuccessSubject = SRPResources.PasswordEmailSuccessSubject }; this.Log().Info("Password reset process for {0} complete from {1}", values.UserEmail, values.RemoteAddress); // TODO email - move this template out to the database StringBuilder body = new StringBuilder(); body.Append("<p>The password reset for your {SystemName} account is now complete.</p>"); body.Append("<p>You may now <a href=\"{ControlRoomLink}\">log in</a> using your new "); body.Append("password.</p>"); body.Append("<p>If you have any comments or questions, please contact "); body.Append("{ContactName} at <a href=\"mailto:{ContactEmail}\">{ContactEmail}"); body.Append("</a>.</p>"); body.Append("<p style=\"font-size: smaller;\"><em>This password request was "); body.Append("completed from: {RemoteAddress}.</em></p>"); new EmailService().SendEmail(user.EmailAddress, "{SystemName} - {PasswordResetSuccessSubject}".FormatWith(values), body.ToString().FormatWith(values)); Response.Redirect("Login.aspx"); }
protected void Page_Load(object sender, EventArgs e) { MasterPage.RequiredPermission = 5100; MasterPage.IsSecure = true; MasterPage.PageTitle = "Patron Search"; _mStrSortExp = String.Empty; if (!IsPostBack) { _mStrSortExp = "Username"; _mSortDirection = SortDirection.Ascending; ViewState["_SortExp_"] = _mStrSortExp; ViewState["_Direction_"] = _mSortDirection; } else { if (null != ViewState["_SortExp_"]) { _mStrSortExp = ViewState["_SortExp_"] as String; } if (null != ViewState["_Direction_"]) { _mSortDirection = (SortDirection)ViewState["_Direction_"]; } } int pageSize = 10; if (int.TryParse(SRPSettings.GetSettingValue("PageSize"), out pageSize)) { gv1.PageSize = pageSize; } else { this.Log().Error("CR Patron Default couldn't parse page size: {0}", SRPSettings.GetSettingValue("PageSize")); } if (!IsPostBack) { PatronsRibbon.GetByAppContext(this); if (Filter.WasFiltered()) { //Filter.LoadDropdowns(); Filter.GetFilterSessionValues(); DoFilter(); } else { gv1.DataSourceID = null; gv1.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { MasterPage.RequiredPermission = 5100; MasterPage.IsSecure = true; MasterPage.PageTitle = string.Format("{0}", "Patron Search"); _mStrSortExp = String.Empty; if (!IsPostBack) { _mStrSortExp = String.Empty; } else { if (null != ViewState["_SortExp_"]) { _mStrSortExp = ViewState["_SortExp_"] as String; } if (null != ViewState["_Direction_"]) { _mSortDirection = (SortDirection)ViewState["_Direction_"]; } } gv1.PageSize = int.Parse(SRPSettings.GetSettingValue("PageSize")); if (!IsPostBack) { PatronsRibbon.GetByAppContext(this); } if (!IsPostBack) { if (Filter.WasFiltered()) { Filter.LoadDropdowns(); Filter.GetFilterSessionValues(); DoFilter(); } else { gv1.DataSourceID = ""; gv1.DataBind(); } } }
protected void Button1_Click(object sender, EventArgs e) { lblMessage.Text = "Your password has been emailed to the address associated with the account and should arrive shortly."; SRPUser user = SRPUser.FetchByUsername(uxUsername.Text); if (user != null) { //Send Email;..... string baseUrl = Request.Url.Scheme + "://" + Request.Url.Authority + Request.ApplicationPath.TrimEnd('/'); var EmailBody = "<h1>Dear " + user.FirstName + ",</h1><br><br>This is your current account information. Please make sure you reset your password as soon as you are able to log back in.<br><br>" + "Username: "******"<br>Password: "******"<br><br>If you have any questions regarding your account please contact " + SRPSettings.GetSettingValue("ContactName") + " at " + SRPSettings.GetSettingValue("ContactEmail") + "." + "<br><br><br><a href='" + baseUrl + "'>" + baseUrl + "</a> <br> <a href='" + baseUrl + "/ControlRoom'>" + baseUrl + "/ControlRoom</a>"; EmailService.SendEmail(user.EmailAddress, "Summer Reading Program - Control Room Password recovery", EmailBody); } }
protected void Page_Load(object sender, EventArgs e) { MasterPage.RequiredPermission = 5100; MasterPage.IsSecure = true; _mStrSortExp = String.Empty; if (!IsPostBack) { _mStrSortExp = String.Empty; } else { if (null != ViewState["_SortExp_"]) { _mStrSortExp = ViewState["_SortExp_"] as String; } if (null != ViewState["_Direction_"]) { _mSortDirection = (SortDirection)ViewState["_Direction_"]; } } gv1.PageSize = int.Parse(SRPSettings.GetSettingValue("PageSize")); if (Session["Curr_Patron"] == null) { Response.Redirect("Default.aspx"); } if (!IsPostBack) { PatronsRibbon.GetByAppContext(this); } if (!IsPostBack) { GetData(); } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { TranslateStrings(this); try { string contactEmail = SRPSettings.GetSettingValue("ContactEmail"); if (!string.IsNullOrEmpty(contactEmail)) { AlternateContact.Text = string.Format("If you continue to have issues, you can send an email to <a href=\"mailto:{0}\">{0}</a>.", contactEmail); } } catch (Exception ex) { try { this.Log().Error("An error occurred showing the not found page: {0}", ex.Message); } catch (Exception) { } } } }
protected void btnLogin_Click(object sender, EventArgs e) { if (Page.IsValid) { object tokenObject = this.ViewState["token"]; if (tokenObject == null) { new SessionTools(Session).AlertPatron(GetResourceString("password-recovery-expired"), PatronMessageLevels.Warning, "exclamation-sign"); Response.Redirect("~/Recover.aspx"); return; } var user = Patron.UpdatePasswordByToken(tokenObject.ToString(), NPassword.Text); if (user == null) { new SessionTools(Session).AlertPatron(GetResourceString("password-recovery-expired"), PatronMessageLevels.Warning, "exclamation-sign"); Response.Redirect("~/Recovery.aspx"); return; } // user requested a password for an email address that is not in the database // if account doesn't exist, send an email saying so var values = new { SystemName = SRPSettings.GetSettingValue("SysName"), ContactName = SRPSettings.GetSettingValue("ContactName"), ContactEmail = SRPSettings.GetSettingValue("ContactEmail"), RemoteAddress = Request.UserHostAddress, UserEmail = user.EmailAddress, Username = user.Username, LoginLink = string.Format("{0}{1}", WebTools.GetBaseUrl(Request), "/Login.aspx"), PasswordResetSuccessSubject = "Your password has been reset!" }; this.Log().Info("Password reset process for {0} ({1}) complete from {2}", values.Username, values.UserEmail, values.RemoteAddress); // TODO email - move this template out to the database StringBuilder body = new StringBuilder(); body.Append("<p>The password change has been successful for the {SystemName} account: {Username}.</p>"); body.Append("<p>You may now <a href=\"{LoginLink}\">log in</a> using your new password.</p>"); body.Append("<p>If you have any comments or questions, please contact "); body.Append("{ContactName} at <a href=\"mailto:{ContactEmail}\">{ContactEmail}</a>.</p>"); body.Append("<p style=\"font-size: smaller;\"><em>This password request was "); body.Append("completed from: {RemoteAddress}.</em></p>"); new EmailService().SendEmail(user.EmailAddress, "{SystemName} - {PasswordResetSuccessSubject}".FormatWith(values), body.ToString().FormatWith(values)); var st = new SessionTools(Session); st.EstablishPatron(user); st.AlertPatron(GetResourceString("Your password has been reset!"), glyphicon: "ok"); Response.Redirect("~"); } }
public void DoBusinessRulesNext(int curStep) { // code needs to have the steps in order for the ifs to flow properly on panels with now fields showing if (curStep == 1) { //get Age var sDOB = ((TextBox)rptr.Items[0].FindControl("DOB")).Text; var sAge = ((TextBox)rptr.Items[0].FindControl("Age")).Text; var sGrade = ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text; var age = -1; if (!string.IsNullOrEmpty(sDOB)) { var DOB = DateTime.Parse(sDOB); age = DateTime.Now.Year - DOB.Year; } else { int.TryParse(sAge, out age); } RegistrationAge.Text = age.ToString(); // Get Default Program for the Age // Set Program to that var grade = -1; if (sGrade.Length > 0) { int.TryParse(sGrade, out grade); } var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID"); if (pgmDD.Items.Count == 2) { // single program - just select the program pgmDD.SelectedIndex = 1; } else if (pgmDD.SelectedValue == "0" || string.IsNullOrEmpty(pgmDD.SelectedValue)) { var defaultProgram = Programs.GetDefaultProgramForAgeAndGrade(age, grade).ToString(); if (pgmDD.Items.FindByValue(defaultProgram) != null) { pgmDD.SelectedValue = defaultProgram; } } if (MasterPID.Text.Length > 0) // Already registered the master account and now looping for family accounts { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 2).ToString(); } else { if (age > 17 && SRPSettings.GetSettingValue("AllowFamilyAccounts").SafeToBoolYes()) { // Ask about adult var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } else { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 2).ToString(); } } } // Finished Current Step = 1 if (curStep == 2) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } // Finished Current Step = 2 if (curStep == 3) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0") { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 3 if (curStep == 4) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0") { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 4 if (curStep == 5) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // deal with parental consent, by program var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue); var prog = new Programs(); prog.Fetch(PID); ((Label)rptr.Items[0].FindControl("lblConsent")).Text = prog.ParentalConsentText; ((Panel)rptr.Items[0].FindControl("pnlConsent")).Visible = prog.ParentalConsentFlag; // // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0" && !prog.ParentalConsentFlag) { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 5 if (curStep == 6) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } // Finished Current Step = 6 if (curStep == 7) { if (!SaveAccount()) { return; } var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; //newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); var famAcct = (DropDownList)rptr.Items[0].FindControl("FamilyAccount"); if (famAcct.SelectedValue == "Yes") { curStep = 9; // Move to the next panel Step.Text = "9"; curPanel = FindControl("Panel" + curStep.ToString()); curPanel.Visible = true; btnPrev.Enabled = false; btnDone.Visible = true; return; } else { // we're done with registration, we can just jump right in TestingBL.CheckPatronNeedsPreTest(); TestingBL.CheckPatronNeedsPostTest(); Session[SessionKey.PatronMessage] = ((BaseSRPPage)Page).GetResourceString("registration-success"); Session[SessionKey.PatronMessageGlyphicon] = "thumbs-up"; Response.Redirect("~"); } newPanel.Visible = true; btnPrev.Enabled = false; } // Finished Current Step = 7 if (curStep == 8) { var curPanel = FindControl("Panel" + curStep.ToString()); var newPanel = FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); btnPrev.Enabled = false; // log them in and take them home Response.Redirect(GoToUrl); } // Finished Current Step = 8 if (curStep == 9) { // Reset Steps, flag as family members, restart the wizard var curPanel = FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel1"); curPanel.Visible = false; newPanel.Visible = true; btnPrev.Enabled = false; btnDone.Visible = false; Step.Text = "1"; Panel0.Visible = true; RegisteringFamily.Text = "1"; RegistrationAge.Text = "0"; ((TextBox)rptr.Items[0].FindControl("ParentGuardianFirstName")).Text = parentGuardianFirst.Text; ((TextBox)rptr.Items[0].FindControl("ParentGuardianMiddleName")).Text = parentGuardianMiddle.Text; ((TextBox)rptr.Items[0].FindControl("ParentGuardianLastName")).Text = parentGuardianLast.Text; ((TextBox)rptr.Items[0].FindControl("Username")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password")).Attributes.Add("Value", string.Empty); ((TextBox)rptr.Items[0].FindControl("Password2")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password2")).Attributes.Add("Value", string.Empty); ((TextBox)rptr.Items[0].FindControl("Age")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("DOB")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text = string.Empty; ((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue = string.Empty; ((TextBox)rptr.Items[0].FindControl("FirstName")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("MiddleName")).Text = string.Empty; ((DropDownList)rptr.Items[0].FindControl("Gender")).SelectedValue = string.Empty; ((TextBox)rptr.Items[0].FindControl("LiteracyLevel1")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("LiteracyLevel2")).Text = string.Empty; } // Finished Current Step = 9 }
public void DoBusinessRulesNext(int curStep) { // code needs to have the steps in order for the ifs to flow properly on panels with now fields showing if (curStep == 1) { //get Age var sDOB = ((TextBox)rptr.Items[0].FindControl("DOB")).Text; var sAge = ((TextBox)rptr.Items[0].FindControl("Age")).Text; var sGrade = ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text; var age = -1; if (!string.IsNullOrEmpty(sDOB)) { var DOB = DateTime.Parse(sDOB); age = DateTime.Now.Year - DOB.Year; } else { int.TryParse(sAge, out age); } RegistrationAge.Text = age.ToString(); // Get Default Program for the Age // Set Program to that var grade = -1; if (sGrade.Length > 0) { int.TryParse(sGrade, out grade); } var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID"); if (pgmDD.Items.Count == 2) { // single program - just select the program pgmDD.SelectedIndex = 1; } else if (pgmDD.SelectedValue == "0" || string.IsNullOrEmpty(pgmDD.SelectedValue)) { var defaultProgram = Programs.GetDefaultProgramForAgeAndGrade(age, grade).ToString(); if (pgmDD.Items.FindByValue(defaultProgram) != null) { pgmDD.SelectedValue = defaultProgram; } } if (MasterPID.Text.Length > 0) // Already registered the master account and now looping for family accounts { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 2).ToString(); } else { if (age > 17 && SRPSettings.GetSettingValue("AllowFamilyAccounts").SafeToBoolYes()) { // Ask about adult var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } else { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 2).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 2).ToString(); } } } // Finished Current Step = 1 if (curStep == 2) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } // Finished Current Step = 2 if (curStep == 3) { var pgmDD = (DropDownList)rptr.Items[0].FindControl("ProgID"); var selectedProgram = DAL.Programs.FetchObject(int.Parse(pgmDD.SelectedValue)); if (!selectedProgram.IsRegistrationOpen) { string programNotOpen; if (DateTime.Now < selectedProgram.StartDate) { programNotOpen = string.Format("This program opens for registration on {0}", selectedProgram.StartDate.ToLongDateString()); } else { programNotOpen = string.Format("Registration for this program ended on {0}", selectedProgram.EndDate.ToLongDateString()); } new SessionTools(Session).AlertPatron(programNotOpen, PatronMessageLevels.Danger, "exclamation-sign"); return; } var goal = rptr.Items[0].FindControl("Goal") as TextBox; if (goal != null && selectedProgram.GoalDefault > 0) { goal.Text = selectedProgram.GoalDefault.ToString(); } var sReqField = (HiddenField)rptr.Items[0].FindControl("ASchoolFieldIsRequired"); var aSchoolFieldIsRequired = bool.Parse(sReqField.Value) == true; if (selectedProgram.HideSchoolInRegistration == true && aSchoolFieldIsRequired == false) { ((Panel)rptr.Items[0].FindControl("SchoolArea")).Visible = false; } else { ((Panel)rptr.Items[0].FindControl("SchoolArea")).Visible = true; } var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0") { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 3 if (curStep == 4) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue); var selectedProgram = DAL.Programs.FetchObject(PID); // disable goal field when the user has a set goal ((TextBox)rptr.Items[0].FindControl("Goal")).Enabled = (selectedProgram.GoalMin != selectedProgram.GoalMax); // Goal needs to be modified by ProgramGamePointConversion /* If daily goal is enabled we need to find what method point system uses. Just select the first item that is relevant.. */ foreach (ActivityType activityTypeValue in Enum.GetValues(typeof(ActivityType))) { int activityTypeId = (int)activityTypeValue; var pgc = ProgramGamePointConversion.FetchObjectByActivityId(PID, activityTypeId); if (pgc != null && pgc.PointCount > 0) { var range = (RangeValidator)rptr.Items[0].FindControl("GoalRangeValidator"); range.MinimumValue = selectedProgram.GoalMin.ToString(); range.MaximumValue = selectedProgram.GoalMax.ToString(); range.Text = $"{range.MinimumValue}-{range.MaximumValue}"; var limitsInfoText = StringResources.getString("registration-goal-limits-note"); ((Label)rptr.Items[0].FindControl("RegistrationGoalInfoNoteLabel")).Text = String.Format(limitsInfoText, range.MinimumValue, range.MaximumValue); /* save the activity type id */ ViewState["ActivityTypeId"] = activityTypeId.ToString(); var intervalString = selectedProgram.GetGoalInterval.ToString(); ((Literal)rptr.Items[0].FindControl("GoalLabel")).Text = $"{intervalString} Goal ({activityTypeValue.ToString()}):"; // found a valid point conversion for goal so break break; } } // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0") { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 4 if (curStep == 5) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); // deal with parental consent, by program var PID = int.Parse(((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue); var prog = new Programs(); prog.Fetch(PID); ((Literal)rptr.Items[0].FindControl("lblConsent")).Text = Server.HtmlDecode(prog.ParentalConsentText); ((Panel)rptr.Items[0].FindControl("pnlConsent")).Visible = prog.ParentalConsentFlag; // do we show this next panel? var newPanelVisibility = ((TextBox)rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString() + "Visibility")).Text; if (newPanelVisibility == "0" && !prog.ParentalConsentFlag) { curStep = curStep + 1; // If not, move to the next panel } } // Finished Current Step = 5 if (curStep == 6) { var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); } // Finished Current Step = 6 if (curStep == 7) { if (!SaveAccount()) { return; } var curPanel = rptr.Items[0].FindControl("Panel" + curStep.ToString()); var newPanel = FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; //newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); var famAcct = (DropDownList)rptr.Items[0].FindControl("FamilyAccount"); if (famAcct.SelectedValue == "Yes") { curStep = 9; // Move to the next panel Step.Text = "9"; curPanel = FindControl("Panel" + curStep.ToString()); curPanel.Visible = true; btnPrev.Enabled = false; btnDone.Visible = true; return; } else { // we're done with registration, we can just jump right in TestingBL.CheckPatronNeedsPreTest(); TestingBL.CheckPatronNeedsPostTest(); Session[SessionKey.PatronMessage] = ((BaseSRPPage)Page).GetResourceString("registration-success"); Session[SessionKey.PatronMessageGlyphicon] = "thumbs-up"; Response.Redirect("~"); } newPanel.Visible = true; btnPrev.Enabled = false; } // Finished Current Step = 7 if (curStep == 8) { var curPanel = FindControl("Panel" + curStep.ToString()); var newPanel = FindControl("Panel" + (curStep + 1).ToString()); curPanel.Visible = false; newPanel.Visible = true; Step.Text = (curStep + 1).ToString(); btnPrev.Enabled = false; // log them in and take them home Response.Redirect(GoToUrl); } // Finished Current Step = 8 if (curStep == 9) { // Reset Steps, flag as family members, restart the wizard var curPanel = FindControl("Panel" + curStep.ToString()); var newPanel = rptr.Items[0].FindControl("Panel1"); curPanel.Visible = false; newPanel.Visible = true; btnPrev.Enabled = false; btnDone.Visible = false; Step.Text = "1"; Panel0.Visible = true; RegisteringFamily.Text = "1"; RegistrationAge.Text = "0"; ((TextBox)rptr.Items[0].FindControl("ParentGuardianFirstName")).Text = parentGuardianFirst.Text; ((TextBox)rptr.Items[0].FindControl("ParentGuardianMiddleName")).Text = parentGuardianMiddle.Text; ((TextBox)rptr.Items[0].FindControl("ParentGuardianLastName")).Text = parentGuardianLast.Text; ((TextBox)rptr.Items[0].FindControl("Username")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password")).Attributes.Add("Value", string.Empty); ((TextBox)rptr.Items[0].FindControl("Password2")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("Password2")).Attributes.Add("Value", string.Empty); ((TextBox)rptr.Items[0].FindControl("Age")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("DOB")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("SchoolGrade")).Text = string.Empty; ((DropDownList)rptr.Items[0].FindControl("ProgID")).SelectedValue = string.Empty; ((TextBox)rptr.Items[0].FindControl("FirstName")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("MiddleName")).Text = string.Empty; ((DropDownList)rptr.Items[0].FindControl("Gender")).SelectedValue = string.Empty; ((TextBox)rptr.Items[0].FindControl("LiteracyLevel1")).Text = string.Empty; ((TextBox)rptr.Items[0].FindControl("LiteracyLevel2")).Text = string.Empty; } // Finished Current Step = 9 }
protected void btnEmail_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(PUsername.Text.Trim())) { var patron = Patron.GetObjectByUsername(PUsername.Text.Trim()); // Show message no matter what, even if we can't do it, because of hacking concerns if (patron == null || string.IsNullOrEmpty(patron.EmailAddress)) { new SessionTools(Session).AlertPatron("Your account could not be located or is not associated with an email address. Please visit your local library branch to reset your password.", PatronMessageLevels.Warning, "exclamation-sign"); } else { string remoteAddress = Request.UserHostAddress; string passwordResetToken = patron.GeneratePasswordResetToken(); if (string.IsNullOrEmpty(passwordResetToken)) { new SessionTools(Session).AlertPatron("Unable to reset your password. Please visit your local library branch.", PatronMessageLevels.Warning, "exclamation-sign"); return; } string systemName = SRPSettings.GetSettingValue("SysName"); var values = new { SystemName = systemName, PasswordResetLink = string.Format("{0}{1}?token={2}", WebTools.GetBaseUrl(Request), "/PasswordRecovery.aspx", passwordResetToken), ContactName = SRPSettings.GetSettingValue("ContactName"), ContactEmail = SRPSettings.GetSettingValue("ContactEmail"), RemoteAddress = remoteAddress, UserEmail = patron.EmailAddress, Username = patron.Username, PasswordResetSubject = string.Format("{0} password reset request", systemName) }; StringBuilder body = new StringBuilder(); body.Append("<p>A password reset request was received by {SystemName} for "); body.Append("your account: {Username}.</p><p>Please "); body.Append("<a href=\"{PasswordResetLink}\">click here</a> in the next hour "); body.Append("to create a new password for your account.</p>"); body.Append("<p>If you did not initiate this request, take no action and your "); body.Append("password will not be changed.</p>"); body.Append("<p>If you have any comments or questions, please contact "); body.Append("{ContactName} at "); body.Append("<a href=\"mailto:{ContactEmail}\">{ContactEmail}</a>.</p>"); body.Append("<p style=\"font-size: smaller;\"><em>This password request was "); body.Append("submitted from: {RemoteAddress}.</em></p>"); new EmailService().SendEmail(patron.EmailAddress, "{SystemName} - {PasswordResetSubject}".FormatWith(values), body.ToString().FormatWith(values)); new SessionTools(Session).AlertPatron("Processing your password reset request, you should receive an email soon.", glyphicon: "ok"); } new SessionTools(Session).ClearPatron(); Response.Redirect("~"); } }
protected void btnSubmit_Click(object sender, EventArgs e) { var txtCount = txtCountSubmitted.Text.Trim(); var txtCode = txtProgramCode.Text.Trim(); // --------------------------------------------------------------------------------------------------- if (txtCount.Length > 0 && txtCode.Length > 0) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Please enter either how much you have read OR a code, but not both.<br><br>"; return; } if (txtCount.Length == 0 && txtCode.Length == 0) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Please enter either how much you have read OR a code.<br><br>"; return; } // --------------------------------------------------------------------------------------------------- int PID = int.Parse(lblPID.Text); int PGID = int.Parse(lblPGID.Text); var StartingPoints = PatronPoints.GetTotalPatronPoints(PID); var pa = new AwardPoints(PID); var sBadges = ""; #region Reading // --------------------------------------------------------------------------------------------------- // Logging reading ... //Badge EarnedBadge; if (txtCount.Length > 0) { var intCount = 0; if (!int.TryParse(txtCount, out intCount)) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "How much was read must be a number."; return; } if (intCount < 0) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "Hmmm, you must enter a positive number...<br><br>"; return; } int maxAmountForLogging = 0; int maxPointsPerDayForLogging = SRPSettings.GetSettingValue("MaxPtsDay").SafeToInt(); switch (int.Parse(rbActivityType.SelectedValue)) { case 0: maxAmountForLogging = SRPSettings.GetSettingValue("MaxBook").SafeToInt(); break; case 1: maxAmountForLogging = SRPSettings.GetSettingValue("MaxPage").SafeToInt(); break; //case 2: maxAmountForLogging = SRPSettings.GetSettingValue("MaxPar").SafeToInt(); // break; case 3: maxAmountForLogging = SRPSettings.GetSettingValue("MaxMin").SafeToInt(); break; default: maxAmountForLogging = SRPSettings.GetSettingValue("MaxMin").SafeToInt(); break; } if (intCount > maxAmountForLogging) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = string.Format("That is an awful lot of reading... unfortunately the maximum you can submit at one time is {0} {1}.<br><br>", maxAmountForLogging, ((ActivityType)int.Parse(rbActivityType.SelectedValue)).ToString()); return; } // convert pages/minutes/etc. to points var pc = new ProgramGamePointConversion(); pc.FetchByActivityId(PGID, int.Parse(rbActivityType.SelectedValue)); var points = Convert.ToInt32(intCount * pc.PointCount / pc.ActivityCount); var allPointsToday = PatronPoints.GetTotalPatronPoints(PID, DateTime.Now); if (intCount + allPointsToday > maxPointsPerDayForLogging) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = string.Format("We are sorry, you have reached the maximum amount of points you are allowed to log in a single day, regardless of how the points were earned. Please come back and and log them tomorrow.<br><br>"); return; } //// convert pages/minutes/etc. to points //var pc = new ProgramGamePointConversion(); //pc.FetchByActivityId(PGID, int.Parse(rbActivityType.SelectedValue)); //var points = Convert.ToInt32(intCount * pc.PointCount / pc.ActivityCount); sBadges = pa.AwardPointsToPatron(points, PointAwardReason.Reading, 0, (ActivityType)pc.ActivityTypeId, intCount, txtAuthor.Text.Trim(), txtTitle.Text.Trim(), Review.Text.Trim()); } #endregion #region Event Attendance // Logging event attendance if (txtCode.Length > 0) { // verify event code was not previously redeemed if (PatronPoints.HasRedeemedKeywordPoints(PID, txtCode)) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "This code has already been redeemend for this account."; return; } // get event for that code, get the # points var ds = Event.GetEventByEventCode(pa.pgm.StartDate.ToShortDateString(), DateTime.Now.ToShortDateString(), txtCode); if (ds.Tables[0].Rows.Count == 0) { lblMessage.ForeColor = System.Drawing.Color.Red; lblMessage.Text = "This code is not valid."; return; } var EID = (int)ds.Tables[0].Rows[0]["EID"]; var evt = Event.GetEvent(EID); var points = evt.NumberPoints; //var newPBID = 0; if (evt.BadgeID != 0) { sBadges = pa.AwardPointsToPatron(points, PointAwardReason.EventAttendance, eventCode: txtCode, eventID: EID); } } #endregion var EndingPoints = PatronPoints.GetTotalPatronPoints(PID); // No need to announcve the badge award lblMessage.ForeColor = System.Drawing.Color.Green; lblMessage.Text = (EndingPoints - StartingPoints).ToInt() + @" points have been added to the account!"; txtAuthor.Text = txtTitle.Text = txtCountSubmitted.Text = Review.Text = txtProgramCode.Text = ""; btnSubmit.Visible = false; btnReSubmit.Visible = true; EntryTable.Visible = false; }
protected void SubmitActivity() { var txtCount = readingActivityField.Text.Trim(); var intCount = 0; if (txtCount.Length == 0 || !int.TryParse(txtCount, out intCount) || intCount < 0) { Session[SessionKey.PatronMessage] = "You must enter how much you've read as a positive whole number."; Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Danger; Session[SessionKey.PatronMessageGlyphicon] = "remove"; return; } var selectedActivityType = activityTypeSelector.SelectedValue; // check that we aren't over the max int maxAmountForLogging = 0; switch (int.Parse(selectedActivityType)) { case 0: maxAmountForLogging = SRPSettings.GetSettingValue("MaxBook").SafeToInt(); break; case 1: maxAmountForLogging = SRPSettings.GetSettingValue("MaxPage").SafeToInt(); break; //case 2: maxAmountForLogging = SRPSettings.GetSettingValue("MaxPar").SafeToInt(); // break; case 3: maxAmountForLogging = SRPSettings.GetSettingValue("MaxMin").SafeToInt(); break; default: maxAmountForLogging = SRPSettings.GetSettingValue("MaxMin").SafeToInt(); break; } if (intCount > maxAmountForLogging) { Session[SessionKey.PatronMessage] = string.Format("That's an awful lot of reading! You can only submit {0} {1} at a time.", maxAmountForLogging, ((ActivityType)int.Parse(selectedActivityType)).ToString()); Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Warning; Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign"; return; } var patronId = ((Patron)Session[SessionKey.Patron]).PID; var programGameId = int.Parse(ViewState["ProgramGameId"].ToString()); var pa = new AwardPoints(patronId); var points = 0; // convert pages/minutes/etc. to points var pc = new ProgramGamePointConversion(); pc.FetchByActivityId(programGameId, int.Parse(activityTypeSelector.SelectedValue)); // round up to ensure they get at least 1 point decimal computedPoints = intCount * pc.PointCount / pc.ActivityCount; points = (int)Math.Ceiling(computedPoints); // ensure they aren't over teh day total var allPointsToday = PatronPoints.GetTotalPatronPoints(patronId, DateTime.Now); int maxPointsPerDayForLogging = SRPSettings.GetSettingValue("MaxPtsDay").SafeToInt(); if (intCount + allPointsToday > maxPointsPerDayForLogging) { Session[SessionKey.PatronMessage] = "Sorry but you have already reached the maximum amount of points that you can log in a day. Keep reading and come back tomorrow!"; Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Warning; Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign"; return; } var earnedBadges = pa.AwardPointsToPatron(points: points, reason: PointAwardReason.Reading, MGID: 0, readingActivity: (ActivityType)pc.ActivityTypeId, readingAmount: intCount, author: authorField.Text, title: titleField.Text); // clear out the form var bookButton = activityTypeSelector.Items.Count == 1 && int.Parse(activityTypeSelector.Items[0].Value) == (int)ActivityType.Books; if (!bookButton) { readingActivityField.Text = string.Empty; } authorField.Text = string.Empty; titleField.Text = string.Empty; // set message and earned badges string earnedMessage = new PointCalculation().EarnedMessage(earnedBadges, points); if (string.IsNullOrEmpty(earnedMessage)) { Session[SessionKey.PatronMessage] = "<strong>Good job!</strong> Your reading activity has been logged."; } else { Session[SessionKey.PatronMessage] = string.Format("<strong>Good job!</strong> Your reading activity has been logged. <strong>{0}</strong>", earnedMessage); } Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Success; Session[SessionKey.PatronMessageGlyphicon] = "thumbs-up"; new SessionTools(Session).EarnedBadges(earnedBadges); }
protected void Button1_Click(object sender, EventArgs e) { string userId = new SRPUser().GetUsernameByEmail(uxEmailaddress.Text); string remoteAddress = new Tools.WebTools().RemoteUserAddress(Request); if (string.IsNullOrEmpty(userId)) { // user requested a password for an email address that is not in the database // if account doesn't exist, send an email saying so var values = new { SystemName = SRPSettings.GetSettingValue("SysName", 1), ControlRoomLink = string.Format("{0}{1}", BaseUrl, "/ControlRoom/LoginRecovery.aspx"), ContactName = SRPSettings.GetSettingValue("ContactName", 1), ContactEmail = SRPSettings.GetSettingValue("ContactEmail", 1), RemoteAddress = remoteAddress, UserEmail = uxEmailaddress.Text, PasswordResetSubject = SRPResources.PasswordEmailSubject }; this.Log().Info("User at {0} requested password reset for nonexistent email {1}", values.RemoteAddress, values.UserEmail); // TODO email - move this template out to the database StringBuilder body = new StringBuilder(); body.Append("<p>A password reset request was received by {SystemName} for your "); body.Append("address. Unfortunately no account could be found associated with "); body.Append("this email address.</p>"); body.Append("<p>If you initiated this request, feel free to "); body.Append("<a href=\"{ControlRoomLink}\">try requesting the password</a> "); body.Append("for any other email address you might have used.</p>"); body.Append("<p>If you have any comments or questions, please contact "); body.Append("{ContactName} at <a href=\"mailto:{ContactEmail}\">{ContactEmail}"); body.Append("</a>.</p>"); body.Append("<p style=\"font-size: smaller;\"><em>This password request was "); body.Append("submitted from: {RemoteAddress}.</em></p>"); new EmailService().SendEmail(uxEmailaddress.Text, "{SystemName} - {PasswordResetSubject}".FormatWith(values), body.ToString().FormatWith(values)); } else { SRPUser lookupUser = SRPUser.FetchByUsername(userId); string passwordResetToken = lookupUser.GeneratePasswordResetToken(); if (string.IsNullOrEmpty(passwordResetToken)) { lblMessage.Text = "Unable to initiate password reset process."; return; } var values = new { SystemName = SRPSettings.GetSettingValue("SysName", lookupUser.TenID), PasswordResetLink = string.Format("{0}{1}?token={2}", BaseUrl, "/ControlRoom/PasswordRecovery.aspx", passwordResetToken), ContactName = SRPSettings.GetSettingValue("ContactName", lookupUser.TenID), ContactEmail = SRPSettings.GetSettingValue("ContactEmail", lookupUser.TenID), RemoteAddress = remoteAddress, UserEmail = uxEmailaddress.Text, PasswordResetSubject = SRPResources.PasswordEmailSubject, }; this.Log().Info("User at {0} requested password reset for email {1}", values.RemoteAddress, values.UserEmail); // TODO email - move this template out to the database StringBuilder body = new StringBuilder(); body.Append("<p>A password reset request was received by {SystemName} for your "); body.Append("address.</p>"); body.Append("<p>Please <a href=\"{PasswordResetLink}\">click here</a> "); body.Append("to create a new password for your account.</p>"); body.Append("<p>If you did not initiate this request, take no action and your "); body.Append("password will not be changed.</p>"); body.Append("<p>If you have any comments or questions, please contact "); body.Append("{ContactName} at <a href=\"mailto:{ContactEmail}\">{ContactEmail}"); body.Append("</a>.</p>"); body.Append("<p style=\"font-size: smaller;\"><em>This password request was "); body.Append("submitted from: {RemoteAddress}.</em></p>"); new EmailService().SendEmail(uxEmailaddress.Text, "{SystemName} - {PasswordResetSubject}".FormatWith(values), body.ToString().FormatWith(values)); } lblMessage.Text = "Processing your password reset request, you should receive an email soon."; }
protected void SubmitActivity() { var txtCount = readingActivityField.Text.Trim(); var intCount = 0; if (txtCount.Length == 0 || !int.TryParse(txtCount, out intCount) || intCount < 0) { Session[SessionKey.PatronMessage] = StringResources.getString("readinglog-entry-invalid"); Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Danger; Session[SessionKey.PatronMessageGlyphicon] = "remove"; return; } var selectedActivityType = activityTypeSelector.SelectedValue; // check that we aren't over the max int maxAmountForLogging = 0; switch (int.Parse(selectedActivityType)) { case 0: maxAmountForLogging = SRPSettings.GetSettingValue("MaxBook").SafeToInt(); break; case 1: maxAmountForLogging = SRPSettings.GetSettingValue("MaxPage").SafeToInt(); break; //case 2: maxAmountForLogging = SRPSettings.GetSettingValue("MaxPar").SafeToInt(); // break; case 3: maxAmountForLogging = SRPSettings.GetSettingValue("MaxMin").SafeToInt(); break; default: maxAmountForLogging = SRPSettings.GetSettingValue("MaxMin").SafeToInt(); break; } if (intCount > maxAmountForLogging) { Session[SessionKey.PatronMessage] = string.Format(StringResources.getString("readinglog-entry-limit"), maxAmountForLogging, ((ActivityType)int.Parse(selectedActivityType)).ToString()); Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Warning; Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign"; return; } var patronId = ((Patron)Session[SessionKey.Patron]).PID; var programGameId = int.Parse(ViewState[ProgramGameIdKey].ToString()); var pa = new AwardPoints(patronId); var points = 0; // convert pages/minutes/etc. to points var pc = new ProgramGamePointConversion(); pc.FetchByActivityId(programGameId, int.Parse(activityTypeSelector.SelectedValue)); // round up to ensure they get at least 1 point decimal computedPoints = intCount * pc.PointCount / pc.ActivityCount; points = (int)Math.Ceiling(computedPoints); // ensure they aren't over teh day total var allPointsToday = PatronPoints.GetTotalPatronPointsOnDate(patronId, DateTime.Now); int maxPointsPerDayForLogging = SRPSettings.GetSettingValue("MaxPtsDay").SafeToInt(); if (intCount + allPointsToday > maxPointsPerDayForLogging) { Session[SessionKey.PatronMessage] = StringResources.getString("readinglog-daily-limit"); Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Warning; Session[SessionKey.PatronMessageGlyphicon] = "exclamation-sign"; return; } var review = ""; if (ViewState[PatronCanReviewKey] as bool? == true) { review = reviewField.Text; } var earnedBadges = pa.AwardPointsToPatron(points: points, reason: PointAwardReason.Reading, MGID: 0, readingActivity: (ActivityType)pc.ActivityTypeId, readingAmount: intCount, author: authorField.Text, title: titleField.Text, review: review); // clear out the form var bookButton = activityTypeSelector.Items.Count == 1 && int.Parse(activityTypeSelector.Items[0].Value) == (int)ActivityType.Books; if (!bookButton) { readingActivityField.Text = string.Empty; } authorField.Text = string.Empty; titleField.Text = string.Empty; reviewField.Text = string.Empty; // set message and earned badges string earnedMessage = new PointCalculation().EarnedMessage(earnedBadges, points); if (string.IsNullOrEmpty(earnedMessage)) { Session[SessionKey.PatronMessage] = "<strong>Good job!</strong> Your reading activity has been logged."; } else { Session[SessionKey.PatronMessage] = string.Format("<strong>Good job!</strong> Your reading activity has been logged. <strong>{0}</strong>", earnedMessage); } Session[SessionKey.PatronMessageLevel] = PatronMessageLevels.Success; Session[SessionKey.PatronMessageGlyphicon] = "thumbs-up"; new SessionTools(Session).EarnedBadges(earnedBadges); }
protected void btnEmail_Click(object sender, EventArgs e) { if (!string.IsNullOrEmpty(PUsername.Text.Trim())) { var patron = Patron.GetObjectByUsername(PUsername.Text.Trim()); if (patron == null || string.IsNullOrEmpty(patron.EmailAddress)) { new SessionTools(Session).AlertPatron("Your account could not be located or is not associated with an email address. Please visit your local library branch to reset your password.", PatronMessageLevels.Warning, "exclamation-sign"); if (patron != null) { this.Log().Info("Unable to send password recovery email for patron id {0} becuase they don't have an email address configured", patron.PID); } return; } else { try { string remoteAddress = new WebTools().RemoteUserAddress(Request); string passwordResetToken = patron.GeneratePasswordResetToken(); if (string.IsNullOrEmpty(passwordResetToken)) { new SessionTools(Session).AlertPatron("Unable to reset your password. Please visit your local library branch.", PatronMessageLevels.Warning, "exclamation-sign"); this.Log().Fatal("Unable to generate password reset token - critical error in password recovery"); return; } string systemName = SRPSettings.GetSettingValue("SysName"); var values = new { SystemName = systemName, PasswordResetLink = string.Format("{0}{1}?token={2}", WebTools.GetBaseUrl(Request), "/PasswordRecovery.aspx", passwordResetToken), ContactName = SRPSettings.GetSettingValue("ContactName"), ContactEmail = SRPSettings.GetSettingValue("ContactEmail"), RemoteAddress = remoteAddress, UserEmail = patron.EmailAddress, Username = patron.Username, PasswordResetSubject = string.Format("{0} password reset request", systemName) }; StringBuilder body = new StringBuilder(); body.Append("<p>A password reset request was received by {SystemName} for "); body.Append("your account: {Username}.</p><p>Please "); body.Append("<a href=\"{PasswordResetLink}\">click here</a> "); body.Append("to create a new password for your account.</p>"); body.Append("<p>If you did not initiate this request, take no action and your "); body.Append("password will not be changed.</p>"); body.Append("<p>If you have any comments or questions, please contact "); body.Append("{ContactName} at "); body.Append("<a href=\"mailto:{ContactEmail}\">{ContactEmail}</a>.</p>"); body.Append("<p style=\"font-size: smaller;\"><em>This password request was "); body.Append("submitted from: {RemoteAddress}.</em></p>"); new EmailService().SendEmail(patron.EmailAddress, "{SystemName} - {PasswordResetSubject}".FormatWith(values), body.ToString().FormatWith(values)); this.Log().Info("Sent password request email for patron id {0} to {1}", patron.PID, patron.EmailAddress); new SessionTools(Session).AlertPatron("Processing your password reset request, you should receive an email soon.", glyphicon: "ok"); } catch (Exception ex) { this.Log().Fatal("Unable to send password recovery email for patron id {0} to {1}: {2} - {3}", patron.PID, patron.EmailAddress, ex.Message, ex.StackTrace); new SessionTools(Session).AlertPatron("A problem occurred resetting your password. Please visit your local library branch to reset your password.", PatronMessageLevels.Warning, "exclamation-sign"); } } new SessionTools(Session).ClearPatron(); Response.Redirect("~"); } }