protected void notify_user_account_status(string msgTemplate) { User u = new User(); u.id.Value = this.id.Value; u = (User)u.doSingleObjectQuery(typeof(User), "select"); Organization o = Organization.Current; OrgEmail oe = new OrgEmail(); oe.organization_id.Value = o.id.Value; oe = oe.doSingleObjectQuery <OrgEmail>("select"); string notificationMsg = msgTemplate; notificationMsg = notificationMsg.Replace("$(ORGNAME)", o.title.Value); notificationMsg = notificationMsg.Replace("$(USERNAME)", u.email.Value); notificationMsg = notificationMsg.Replace("$(WEBMASTER)", oe.webmaster_email_to.Value); notificationMsg = notificationMsg.Replace("$(SUBDOMAIN)", o.subdomain.Value); Email email = new Email(); email.subject = "New Account Request"; email.Body = notificationMsg; email.addTo(u.email.Value); email.from = Organization.Current.getFromEmail(); email.send(); }
protected void notify_webmaster_new_account() { User u = new User(); u.id.Value = this.id.Value; u = (User)u.doSingleObjectQuery(typeof(User), "select"); Organization o = Organization.Current; OrgEmail oe = new OrgEmail(); oe.organization_id.Value = o.id.Value; oe = oe.doSingleObjectQuery <LiftDomain.OrgEmail>("select"); string notification_msg = notify_webmaster_email; notification_msg = notification_msg.Replace("$(ORGNAME)", o.title); notification_msg = notification_msg.Replace("$(USERNAME)", u.email.Value); Email email = new Email(); email.subject = "New Account Request"; email.Body = notification_msg; email.addTo(oe.webmaster_email_to.Value); email.from = Organization.Current.getFromEmail(); email.send(); }
protected static void reloadCurrent() { User u = Current; lock (usersSync) { User u2 = new User(); u2.id.Value = u.id.Value; u2 = u2.doSingleObjectQuery <User>("select"); if (u2 != null) { string email = u2.email.Value; users[email] = u2; } } }
protected void Page_Load(object sender, EventArgs e) { EmailValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; PasswordValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_PASSWORDS_DO_NOT_MATCH; if (!Organization.setCurrent()) { Response.Redirect(LiftContext.Redirect); } PageAuthorized.check(Request, Response); int initialLanguageId = 1; //-- 1 = English string initialTimeZone = string.Empty; string saltValue = string.Empty; int sumTotalRequests = 0; TimeSpan sumPrayerSessionsDurationTimeSpan = new TimeSpan(); //------------------------------------------------------------------------- //-- do the language setting for the SUBMIT button here //-- (unable to place <%=LiftDomain.Language.Current.SHARED_SUBMIT %> in asp:Button Text field) //------------------------------------------------------------------------- this.submitBtn.Text = LiftDomain.Language.Current.SHARED_SUBMIT; this.submitBtnPassword.Text = LiftDomain.Language.Current.SHARED_CHANGE; this.submitBtnTimeZone.Text = LiftDomain.Language.Current.SHARED_CHANGE; LiftDomain.User thisUser = new LiftDomain.User(); if (IsPostBack) { //------------------------------------------------------------------------- //-- transfer screen values to the object //------------------------------------------------------------------------- thisUser.id.Value = int.Parse(id.Value); thisUser.login.Value = login.Text; thisUser.first_name.Value = first_name.Text; thisUser.last_name.Value = last_name.Text; thisUser.email.Value = email.Text; thisUser.address.Value = address.Text; thisUser.city.Value = city.Text; thisUser.state_province.Value = state_province.Text; thisUser.postal_code.Value = postal_code.Text; thisUser.phone.Value = phone.Text; thisUser.language_id.Value = Convert.ToInt32(language_list.SelectedItem.Value); //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT //(user_password.Text != user_password_confirmation.Text) if (!String.IsNullOrEmpty(user_password.Text.Trim())) { thisUser.password_hash_type.Value = "md5"; saltValue = LiftDomain.User.generateRandomSalt(); thisUser.password_salt.Value = saltValue; thisUser.crypted_password.Value = LiftDomain.User.hash(user_password.Text, saltValue); } thisUser.updated_at.Value = LiftTime.CurrentTime; thisUser.time_zone.Value = timezone_list.SelectedItem.Value; thisUser.previous_increment_id.Value = 0; //------------------------------------------------------------------------- //-- persist the User object data to the database //------------------------------------------------------------------------- thisUser.doCommand("save_current"); Response.Redirect("MyAccount.aspx"); } else { //------------------------------------------------------------------------- //-- query database for data for the current user //------------------------------------------------------------------------- id.Value = LiftDomain.User.Current.id.Value.ToString(); thisUser.id.Value = LiftDomain.User.Current.id.Value; thisUser = thisUser.doSingleObjectQuery <LiftDomain.User>("select"); } //------------------------------------------------------------------------- //-- populate the screen controls //------------------------------------------------------------------------- first_name_label.Text = thisUser.first_name; last_name_label.Text = thisUser.last_name; login.Text = thisUser.login; created_at.Text = thisUser.created_at.Value.ToString("dddd MMMM dd, yyyy"); first_name.Text = thisUser.first_name; last_name.Text = thisUser.last_name; email.Text = thisUser.email; address.Text = thisUser.address; city.Text = thisUser.city; state_province.Text = thisUser.state_province; postal_code.Text = thisUser.postal_code; phone.Text = thisUser.phone; initialLanguageId = thisUser.language_id; initLanguageList(initialLanguageId); initialTimeZone = thisUser.time_zone; initTimeZoneList(initialTimeZone); //------------------------------------------------------------------------- //-- MY PRAYER REQUESTS //------------------------------------------------------------------------- LiftDomain.Request prayerRequest = new LiftDomain.Request(); prayerRequest.user_id.Value = thisUser.id; prayerRequestSet = prayerRequest.doQuery("get_my_account_requests"); if (prayerRequestSet.Tables[0].Rows.Count > 0) { prayerRequestRenderer = new PartialRenderer(HttpContext.Current, prayerRequestSet, "_MyAccountRequest.htm", new PartialRenderer.RenderHelper(prayerRequest.my_account_request_helper)); prayerRequestRendererResult = prayerRequestRenderer; } else { prayerRequestRendererResult = "<p>" + LiftDomain.Language.Current.MY_ACCOUNT_YOU_HAVE_NO_REQUESTS.Value + ".</p>"; } //------------------------------------------------------------------------- //-- MY PRAYER REQUEST SUBSCRIPTIONS //------------------------------------------------------------------------- LiftDomain.Subscription prayerRequestSubscription = new LiftDomain.Subscription(); prayerRequestSubscription.user_id.Value = thisUser.id; prayerRequestSubscriptionSet = prayerRequestSubscription.doQuery("get_subscription_by_user"); if (prayerRequestSubscriptionSet.Tables[0].Rows.Count > 0) { prayerRequestSubscriptionRenderer = new PartialRenderer(HttpContext.Current, prayerRequestSubscriptionSet, "_MyAccountPrayerRequestSubscription.htm", new PartialRenderer.RenderHelper(prayerRequestSubscription.my_account_prayer_request_subscription_helper)); prayerRequestSubscriptionRendererResult = prayerRequestSubscriptionRenderer; } else { prayerRequestSubscriptionRendererResult = "<p>" + LiftDomain.Language.Current.MY_ACCOUNT_YOU_HAVE_NO_SUBSCRIPTIONS.Value + ".</p>"; } //------------------------------------------------------------------------- //-- MY PRAYER SESSIONS //------------------------------------------------------------------------- LiftDomain.Prayersession prayerSessionObject = new LiftDomain.Prayersession(); prayerSessionObject.user_id.Value = thisUser.id; prayerSessionSet = prayerSessionObject.doQuery("get_prayer_sessions_by_user_start_time_desc"); if (prayerSessionSet.Tables[0].Rows.Count > 0) { prayerSessionRenderer = new PartialRenderer(HttpContext.Current, prayerSessionSet, "_MyAccountPrayerSession.htm", new PartialRenderer.RenderHelper(prayerSessionObject.my_account_prayer_session_helper)); prayerSessionRendererResult = prayerSessionRenderer; foreach (DataRow thisDataRow in prayerSessionSet.Tables[0].Rows) { sumTotalRequests += Convert.ToInt32(thisDataRow["total_requests"]); sumPrayerSessionsDurationTimeSpan = sumPrayerSessionsDurationTimeSpan.Add(Convert.ToDateTime(thisDataRow["end_time"]) - Convert.ToDateTime(thisDataRow["start_time"])); } prayer_requests_sum_label = Convert.ToString(sumTotalRequests); prayer_sessions_duration_sum_label = Convert.ToString(sumPrayerSessionsDurationTimeSpan.Hours) + "." + (((float)((float)sumPrayerSessionsDurationTimeSpan.Minutes / (float)60)) * 10).ToString("0"); } else { prayerSessionRendererResult = "<tr id='request0'><td valign='top' colspan='4' align='center'>" + LiftDomain.Language.Current.MY_ACCOUNT_YOU_HAVE_NO_SESSIONS.Value + ".</td></tr>"; } }
protected void Page_Load(object sender, EventArgs e) { EmailValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; PasswordValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_PASSWORDS_DO_NOT_MATCH; if (!Organization.setCurrent()) { Response.Redirect(LiftContext.Redirect); } int initialUserStatus = 1; //-- 1 = unconfirmed string initialTimeZone = "Central Standard Time"; int initialLanguageId = 1; //-- 1 = English string saltValue = string.Empty; try { //------------------------------------------------------------------------- //-- do the language setting for the SUBMIT button here //-- (unable to place <%=LiftDomain.Language.Current.SIGNUP_USER_SIGN_ME_UP %> in asp:Button Text field) //------------------------------------------------------------------------- this.submitBtn.Text = LiftDomain.Language.Current.SIGNUP_USER_SIGN_ME_UP.Value; //------------------------------------------------------------------------- //-- do other language settings //------------------------------------------------------------------------- signup_user_fieldset_legend = LiftDomain.Language.Current.SIGNUP_USER_NEW_USER_REGISTRATION.Value; signup_user_fieldset_legend2 = LiftDomain.Language.Current.SIGNUP_USER_ALL_FIELDS_REQUIRED.Value; LiftDomain.User thisUser = new LiftDomain.User(); if (IsPostBack) { //TODO: ???what if CAPTCHA validation fails??? //TODO: ???should we be doing validation checking in Page_Load or submitBtn_Click??? //if (Page.IsValid && (txtCaptcha.Text.ToString() == Session["captchaValue"].ToString())) if (txtCaptcha.Text.ToString().Trim().ToUpper() == Session["captchaValue"].ToString().Trim().ToUpper()) { //Response.Write("CAPTCHA verification succeeded"); //------------------------------------------------------------------------- //-- get the user ID from the hidden id field on the page; //-- if there is a user ID value, then we are editing an EXISTING user //------------------------------------------------------------------------- if (!String.IsNullOrEmpty(id.Value) && (id.Value != "0")) { thisUser.id.Value = int.Parse(id.Value); if (!String.IsNullOrEmpty(password.Text.Trim())) { //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT //(user_password.Text != password_confirmation.Text) thisUser.password_hash_type.Value = "md5"; saltValue = LiftDomain.User.generateRandomSalt(); thisUser.password_salt.Value = saltValue; thisUser.crypted_password.Value = LiftDomain.User.hash(password.Text, saltValue); thisUser.last_password_changed_date.Value = LiftTime.CurrentTime; } } else { //------------------------------------------------------------------------- //-- if the user ID is blank or zero (0), then set some NEW user values (NOT id) //------------------------------------------------------------------------- thisUser.state.Value = initialUserStatus; thisUser.created_at.Value = LiftTime.CurrentTime; thisUser.last_logged_in_at.Value = new DateTime(2000, 1, 1, 0, 0, 0); //-- DateTime.MinValue; thisUser.login_failure_count.Value = 0; //thisUser.total_comments.Value = 0; //thisUser.total_comments_needing_approval.Value = 0; //thisUser.total_private_comments.Value = 0; //TODO: ???what if password is blank??? // TO BE DONE IN JAVASCRIPT if (String.IsNullOrEmpty(password.Text.Trim())) { } else { //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT //(user_password.Text != password_confirmation.Text) thisUser.password_hash_type.Value = "md5"; saltValue = LiftDomain.User.generateRandomSalt(); thisUser.password_salt.Value = saltValue; thisUser.crypted_password.Value = LiftDomain.User.hash(password.Text, saltValue); } } //------------------------------------------------------------------------- //-- transfer screen values to the object //------------------------------------------------------------------------- thisUser.login.Value = user_email.Text; thisUser.email.Value = user_email.Text; thisUser.first_name.Value = user_first_name.Text; thisUser.last_name.Value = user_last_name.Text; //thisUser.address.Value = user_address.Text; thisUser.address.Value = ""; //thisUser.city.Value = user_city.Text; thisUser.city.Value = ""; //thisUser.state_province.Value = user_state.Text; thisUser.state_province.Value = ""; //thisUser.postal_code.Value = user_postal_code.Text; thisUser.postal_code.Value = ""; thisUser.phone.Value = user_phone.Text; //thisUser.state.Value = initialUserStatus; //thisUser.time_zone.Value = timezone_list.SelectedItem.Value; thisUser.time_zone.Value = Organization.Current.time_zone.Value; //thisUser.language_id.Value = Convert.ToInt32(language_list.SelectedItem.Value); thisUser.language_id.Value = Organization.Current.language_id.Value; thisUser.previous_increment_id.Value = 0; thisUser.updated_at.Value = LiftTime.CurrentTime; thisUser.password_hash_type.Value = "md5"; //thisUser.isapproved.Value = true; //TODO: ???need to fix when moderator user available bool ok = true; if (LiftDomain.User.checkEmailExists(user_email.Text)) { ok = false; } if (user_login.Text.Length == 0) { user_login.Text = user_email.Text; } if (LiftDomain.User.checkUsernameExists(user_login.Text)) { ok = false; } if (!ok) { errorMsg.Text = Language.Current.SIGNUP_ACCT_EXISTS1; errorMsg.Text += " "; errorMsg.Text += Language.Current.SIGNUP_ACCT_EXISTS2; errorMsg.Text += "<br/><br/>"; errorMsg.Text += " <a href=\"ForgotPassword.aspx?email="; errorMsg.Text += thisUser.email.Value; errorMsg.Text += "\">"; errorMsg.Text += LiftDomain.Language.Current.SIGNUP_RETRIEVE_YOUR_PASSWORD; errorMsg.Text += "</a>"; } if (ok) { //------------------------------------------------------------------------- //-- persist the User object data to the database //------------------------------------------------------------------------- thisUser.id.Value = Convert.ToInt32(thisUser.doCommand("create_account")); LiftMembershipProvider membership = new LiftMembershipProvider(); if (membership.ValidateUser(user_email.Text, password.Text)) { FormsAuthentication.Initialize(); LiftRoleProvider roleProvider = new LiftRoleProvider(); roleProvider.Initialize(null, null); //String strRole = membership.AssignRoles(txtUsername.Text); string[] roles = roleProvider.GetRolesForUser(user_login.Text); string strRole = ""; foreach (string role in roles) { if (strRole.Length > 0) { strRole += ","; } strRole += role; } //FormsIdentity fi = new FormsIdentity((FormsIdentity)HttpContext.Current.User.Identity; FormsAuthenticationTicket fat = new FormsAuthenticationTicket(1, user_email.Text, DateTime.Now, DateTime.Now.AddMinutes(30), false, strRole, FormsAuthentication.FormsCookiePath); FormsIdentity fi = new FormsIdentity(fat); Response.Cookies.Add(new HttpCookie(FormsAuthentication.FormsCookieName, FormsAuthentication.Encrypt(fat))); HttpContext.Current.User = new GenericPrincipal(fi, roles); Response.Redirect(FormsAuthentication.GetRedirectUrl(user_email.Text, false)); } else { Response.Redirect("SignUpThankYou.aspx"); } } } else { errorMsg.Text = Language.Current.SIGNUP_USER_USER_REGISTRATION_FAILED; } } else { //------------------------------------------------------------------------- //-- first time on this page, so get the user ID from the ASP Request cache //------------------------------------------------------------------------- string idStr = Request["id"]; if (String.IsNullOrEmpty(idStr)) { id.Value = "0"; } else { id.Value = idStr; } thisUser.id.Value = Convert.ToInt32(id.Value); //------------------------------------------------------------------------- //-- if this is a NEW user... //------------------------------------------------------------------------- if (id.Value == "0") { //------------------------------------------------------------------------- //-- set default values //------------------------------------------------------------------------- initialUserStatus = 1; //-- 1 = unconfirmed initialTimeZone = LiftDomain.Organization.Current.time_zone.Value; initialLanguageId = LiftDomain.Organization.Current.language_id.Value; } //------------------------------------------------------------------------- //-- else, if this is an EXISTING user... //------------------------------------------------------------------------- else { //------------------------------------------------------------------------- //-- query database for data for this user //------------------------------------------------------------------------- thisUser = thisUser.doSingleObjectQuery <LiftDomain.User>("select"); initialUserStatus = thisUser.state; initialTimeZone = thisUser.time_zone; initialLanguageId = thisUser.language_id; } //------------------------------------------------------------------------- //-- populate the screen controls //------------------------------------------------------------------------- user_login.Text = thisUser.login; user_email.Text = thisUser.email; user_first_name.Text = thisUser.first_name; user_last_name.Text = thisUser.last_name; user_address.Text = thisUser.address; user_city.Text = thisUser.city; user_state.Text = thisUser.state_province; user_postal_code.Text = thisUser.postal_code; user_phone.Text = thisUser.phone; initTimeZoneList(initialTimeZone); initLanguageList(initialLanguageId); } } catch (Exception x) { //TODO: ??? WHAT DO WE DO IF THERE IS AN ERROR ??? string m = x.Message; System.Diagnostics.Debug.Print("[" + DateTime.Now.ToString() + "] *** ERROR IN SignupUser.aspx.cs::Page_Load(): " + m); Logger.log("SignupUser.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN SignupUser.aspx.cs::Page_Load(): " + m); //Response.Write(m); } finally { } }
protected void Page_Load(object sender, EventArgs e) { PasswordRequired.Enabled = false; EmailValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_MUST_BE_A_VALID_EMAIL_ADDRESS; PasswordValidator.ErrorMessage = LiftDomain.Language.Current.SHARED_PASSWORDS_DO_NOT_MATCH; if (!Organization.setCurrent()) { Response.Redirect(LiftContext.Redirect); } PageAuthorized.check(Request, Response); int initialUserStatus = 1; //-- 1 = unconfirmed string initialTimeZone = "Central Standard Time"; int initialLanguageId = 1; //-- 1 = English int initialOrgId = 0; string saltValue = string.Empty; LiftDomain.RolesUser thisRolesUser; try { //------------------------------------------------------------------------- //-- do the language setting for the SUBMIT button here //-- (unable to place <%=LiftDomain.Language.Current.SHARED_SUBMIT %> in asp:Button Text field) //------------------------------------------------------------------------- this.submitBtn.Text = LiftDomain.Language.Current.SHARED_SUBMIT.Value; //------------------------------------------------------------------------- //-- do other language settings //------------------------------------------------------------------------- edit_user_fieldset_legend = LiftDomain.Language.Current.USER_EDIT_USER.Value; //this.user_roles_2.Text = LiftDomain.Language.Current.ROLES_ADMIN.Value; this.user_roles_7.Text = LiftDomain.Language.Current.ROLES_MODERATOR.Value; this.user_roles_8.Text = LiftDomain.Language.Current.ROLES_WALL_LEADER.Value; this.user_roles_10.Text = LiftDomain.Language.Current.ROLES_WATCHMAN.Value; this.user_roles_13.Text = LiftDomain.Language.Current.ROLES_SYSTEM_ADMIN.Value; this.user_roles_14.Text = LiftDomain.Language.Current.ROLES_ORGANIZATION_ADMIN.Value; //this.user_roles_11.Text = LiftDomain.Language.Current.ROLES_TESTADMIN.Value; //this.user_roles_12.Text = LiftDomain.Language.Current.ROLES_ADMINTEST.Value; LiftDomain.User thisUser = new LiftDomain.User(); if (IsPostBack) { //------------------------------------------------------------------------- //-- get the object ID from the hidden id field on the page; //-- if there is a object ID value, then we are editing an EXISTING object //------------------------------------------------------------------------- if (!String.IsNullOrEmpty(id.Value) && (id.Value != "0")) { thisUser.id.Value = int.Parse(id.Value); if (!String.IsNullOrEmpty(password.Text.Trim())) { //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT //(user_password.Text != password_confirmation.Text) thisUser.password_hash_type.Value = "md5"; saltValue = LiftDomain.User.generateRandomSalt(); thisUser.password_salt.Value = saltValue; thisUser.crypted_password.Value = LiftDomain.User.hash(password.Text, saltValue); thisUser.last_password_changed_date.Value = LiftTime.CurrentTime; } } else { //------------------------------------------------------------------------- //-- if the object ID is blank or zero (0), then set some NEW object values (NOT id) //------------------------------------------------------------------------- thisUser.created_at.Value = LiftTime.CurrentTime; thisUser.last_logged_in_at.Value = new DateTime(2000, 1, 1, 0, 0, 0); //-- DateTime.MinValue; thisUser.login_failure_count.Value = 0; //thisUser.total_comments.Value = 0; //thisUser.total_comments_needing_approval.Value = 0; //thisUser.total_private_comments.Value = 0; //TODO: ???what if password is blank??? // TO BE DONE IN JAVASCRIPT if (String.IsNullOrEmpty(password.Text.Trim())) { } else { //TODO: ???what if passwords do not match??? // TO BE DONE IN JAVASCRIPT //(user_password.Text != password_confirmation.Text) thisUser.password_hash_type.Value = "md5"; saltValue = LiftDomain.User.generateRandomSalt(); thisUser.password_salt.Value = saltValue; thisUser.crypted_password.Value = LiftDomain.User.hash(password.Text, saltValue); thisUser.last_password_changed_date.Value = LiftTime.CurrentTime; } } //------------------------------------------------------------------------- //-- transfer screen values to the object //------------------------------------------------------------------------- //TODO: ???what if data field validation fails??? // TO BE DONE IN JAVASCRIPT //TODO: ???what if user login already exists??? // TO BE DONE IN JAVASCRIPT thisUser.login.Value = user_login.Text; thisUser.email.Value = user_email.Text; thisUser.first_name.Value = user_first_name.Text; thisUser.last_name.Value = user_last_name.Text; thisUser.address.Value = user_address.Text; thisUser.city.Value = user_city.Text; thisUser.state_province.Value = user_state.Text; thisUser.postal_code.Value = user_postal_code.Text; thisUser.phone.Value = user_phone.Text; thisUser.state.Value = Convert.ToInt32(user_status_list.SelectedItem.Value); thisUser.time_zone.Value = timezone_list.SelectedItem.Value; thisUser.language_id.Value = Convert.ToInt32(language_list.SelectedItem.Value); thisUser.organization_id.Value = Convert.ToInt32(org_list.SelectedItem.Value); thisUser.previous_increment_id.Value = 0; thisUser.updated_at.Value = LiftTime.CurrentTime; //thisUser.isapproved.Value = true; //TODO: ???need to fix when moderator user available //------------------------------------------------------------------------- //-- persist the object data to the database //------------------------------------------------------------------------- thisUser.OverrideAutoOrgAssignment = true; thisUser.id.Value = Convert.ToInt32(thisUser.doCommand("save")); //id.Value = thisUser.id.Value.ToString(); //------------------------------------------------------------------------- //-- persist the RolesUser object data to the database //-- first, delete all for this user...then insert in the selected roles //------------------------------------------------------------------------- thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.doQuery("delete_roles_users_by_user_id"); /* * if (user_roles_2.Checked) * { * thisRolesUser = new LiftDomain.RolesUser(); * thisRolesUser.user_id.Value = thisUser.id.Value; * thisRolesUser.role_id.Value = 2; * thisRolesUser.created_at.Value = LiftTime.CurrentTime; * thisRolesUser.doCommand("save"); * } */ if (user_roles_7.Checked) { thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 7; thisRolesUser.created_at.Value = LiftTime.CurrentTime; thisRolesUser.doCommand("save"); } if (user_roles_8.Checked) { thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 8; thisRolesUser.created_at.Value = LiftTime.CurrentTime; thisRolesUser.doCommand("save"); } if (user_roles_10.Checked) { thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 10; thisRolesUser.created_at.Value = LiftTime.CurrentTime; thisRolesUser.doCommand("save"); } if (user_roles_13.Checked) { thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 13; thisRolesUser.created_at.Value = LiftTime.CurrentTime; thisRolesUser.doCommand("save"); } if (user_roles_14.Checked) { thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 14; thisRolesUser.created_at.Value = LiftTime.CurrentTime; thisRolesUser.doCommand("save"); } //if (user_roles_11.Checked) //{ // thisRolesUser = new LiftDomain.RolesUser(); // thisRolesUser.user_id.Value = thisUser.id.Value; // thisRolesUser.role_id.Value = 11; // thisRolesUser.created_at.Value = LiftTime.CurrentTime; // thisRolesUser.doCommand("save"); //} //if (user_roles_12.Checked) //{ // thisRolesUser = new LiftDomain.RolesUser(); // thisRolesUser.user_id.Value = thisUser.id.Value; // thisRolesUser.role_id.Value = 12; // thisRolesUser.created_at.Value = LiftTime.CurrentTime; // thisRolesUser.doCommand("save"); //} //------------------------------------------------------------------------- //-- return to the User List page //------------------------------------------------------------------------- if (Session["last_user_list_search"] != null) { Response.Redirect("UserList.aspx?" + Session["last_user_list_search"]); } else { Response.Redirect("UserList.aspx"); } } else { //------------------------------------------------------------------------- //-- first time on this page, so get the object ID from the ASP Request cache //------------------------------------------------------------------------- string idStr = Request["id"]; if (String.IsNullOrEmpty(idStr)) { id.Value = "0"; } else { id.Value = idStr; } thisUser.id.Value = Convert.ToInt32(id.Value); //------------------------------------------------------------------------- //-- if this is a NEW user... //------------------------------------------------------------------------- if (id.Value == "0") { //------------------------------------------------------------------------- //-- set default values //------------------------------------------------------------------------- initialUserStatus = 1; //-- 1 = unconfirmed initialTimeZone = LiftDomain.Organization.Current.time_zone.Value; initialLanguageId = LiftDomain.Organization.Current.language_id.Value; initialOrgId = LiftDomain.Organization.Current.id.Value; login_label.Visible = false; edit_user_fieldset_legend = LiftDomain.Language.Current.USER_CREATE_A_NEW_USER.Value; bottomNavTableCellDelete.Visible = false; delete_user_id = string.Empty; redirect_after_delete_to_page = string.Empty; PasswordRequired.Enabled = true; } //------------------------------------------------------------------------- //-- else, if this is an EXISTING user... //------------------------------------------------------------------------- else { //------------------------------------------------------------------------- //-- query database for data for this user //------------------------------------------------------------------------- if (LiftDomain.User.Current.IsInRole(Role.SYS_ADMIN)) { thisUser.OverrideAutoOrgAssignment = true; } thisUser = thisUser.doSingleObjectQuery <LiftDomain.User>("select"); initialUserStatus = thisUser.state; initialTimeZone = thisUser.time_zone; initialLanguageId = thisUser.language_id; initialOrgId = thisUser.organization_id; login_label.Text = LiftDomain.Language.Current.USER_EDITING_USER.Value + " " + thisUser.login; edit_user_fieldset_legend = LiftDomain.Language.Current.USER_EDIT_USER.Value; bottomNavTableCellDelete.Visible = true; delete_user_id = id.Value; if (Session["last_user_list_search"] != null) { redirect_after_delete_to_page = "UserList.aspx?" + Session["last_user_list_search"]; } else { redirect_after_delete_to_page = "UserList.aspx"; } } //------------------------------------------------------------------------- //-- populate the screen controls //------------------------------------------------------------------------- user_login.Text = thisUser.login; user_email.Text = thisUser.email; user_first_name.Text = thisUser.first_name; user_last_name.Text = thisUser.last_name; user_address.Text = thisUser.address; user_city.Text = thisUser.city; user_state.Text = thisUser.state_province; user_postal_code.Text = thisUser.postal_code; user_phone.Text = thisUser.phone; /* * thisRolesUser = new LiftDomain.RolesUser(); * thisRolesUser.user_id.Value = thisUser.id.Value; * thisRolesUser.role_id.Value = 2; * thisRolesUser = thisRolesUser.doSingleObjectQuery<LiftDomain.RolesUser>("select"); * user_roles_2.Checked = (thisRolesUser.id.Value > 0); * */ thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 7; thisRolesUser = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select"); user_roles_7.Checked = (thisRolesUser.id.Value > 0); thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 8; thisRolesUser = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select"); user_roles_8.Checked = (thisRolesUser.id.Value > 0); thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 10; thisRolesUser = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select"); user_roles_10.Checked = (thisRolesUser.id.Value > 0); thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 13; thisRolesUser = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select"); user_roles_13.Checked = (thisRolesUser.id.Value > 0); thisRolesUser = new LiftDomain.RolesUser(); thisRolesUser.user_id.Value = thisUser.id.Value; thisRolesUser.role_id.Value = 14; thisRolesUser = thisRolesUser.doSingleObjectQuery <LiftDomain.RolesUser>("select"); user_roles_14.Checked = (thisRolesUser.id.Value > 0); //thisRolesUser = new LiftDomain.RolesUser(); //thisRolesUser.user_id.Value = thisUser.id.Value; //thisRolesUser.role_id.Value = 11; //thisRolesUser = thisRolesUser.doSingleObjectQuery<LiftDomain.RolesUser>("select"); //user_roles_11.Checked = (thisRolesUser.id.Value > 0); //thisRolesUser = new LiftDomain.RolesUser(); //thisRolesUser.user_id.Value = thisUser.id.Value; //thisRolesUser.role_id.Value = 12; //thisRolesUser = thisRolesUser.doSingleObjectQuery<LiftDomain.RolesUser>("select"); //user_roles_12.Checked = (thisRolesUser.id.Value > 0); initUserStatusList(initialUserStatus); initTimeZoneList(initialTimeZone); initLanguageList(initialLanguageId); initOrgList(initialOrgId); enforceRoleSettings(); } } catch (Exception x) { //TODO: ??? WHAT DO WE DO IF THERE IS AN ERROR ??? string m = x.Message; System.Diagnostics.Debug.Print("[" + DateTime.Now.ToString() + "] *** ERROR IN EditUser.aspx.cs::Page_Load(): " + m); Logger.log("EditUser.aspx.cs", x, "[" + DateTime.Now.ToString() + "] *** ERROR IN EditUser.aspx.cs::Page_Load(): " + m); } finally { } }
public void notifyAdjacent(int currentWallId, int userId, int dow, int tod, bool subscribe) { string header = headerMsg; string recvMsg = string.Empty; string giveMsg = string.Empty; string subj = string.Empty; string thisUserHeader = string.Empty; if (subscribe) { recvMsg = recvWatchMsg; giveMsg = giveWatchMsg; subj = "New Watchman Notification"; thisUserHeader = headerMsg; } else { recvMsg = noLongerRecvWatchMsg; giveMsg = noLongerGiveWatchMsg; subj = "Watchman Change Notifcation"; thisUserHeader = unsubscribeHeaderMsg; } OrgEmail oe = new OrgEmail(); oe.organization_id.Value = Organization.Current.id.Value; oe = oe.doSingleObjectQuery <OrgEmail>("select"); int prevDow = 0; int prevTod = 0; int nextDow = 0; int nextTod = 0; calcPrev(dow, tod, ref prevDow, ref prevTod); calcNext(dow, tod, ref nextDow, ref nextTod); Appt adj = new Appt(); adj["wall_id"] = currentWallId; adj["next_tod"] = nextTod; adj["next_dow"] = nextDow; adj["prev_tod"] = prevTod; adj["prev_dow"] = prevDow; adj["tzoffset"] = LiftTime.UserTzOffset; DataSet neighbors = adj.doQuery("get_adjacent"); User thisUser = new User(); thisUser.id.Value = userId; thisUser = thisUser.doSingleObjectQuery <User>("getobject"); User prior = null; User next = null; if (DatabasePersist.hasData(neighbors)) { foreach (DataRow neighbor in neighbors.Tables[0].Rows) { string rel = neighbor["rel"].ToString(); if (rel == "before") { prior = new User(); prior.id.Value = Convert.ToInt32(neighbor["user_id"]); prior = prior.doSingleObjectQuery <User>("getobject"); } if (rel == "after") { next = new User(); next.id.Value = Convert.ToInt32(neighbor["user_id"]); next = next.doSingleObjectQuery <User>("getobject"); } } } StringBuilder currentBody = new StringBuilder(thisUserHeader); replace(currentBody, "day_name", getDay(dow)); replace(currentBody, "time", getTime(tod)); if (prior != null) { StringBuilder priorBody = new StringBuilder(header); replace(priorBody, "day_name", getDay(prevDow)); replace(priorBody, "time", getTime(prevTod)); priorBody.Append(giveMsg); replace(priorBody, "next_first_name", thisUser.first_name.Value); replace(priorBody, "next_last_name", thisUser.last_name.Value); replace(priorBody, "next_email", thisUser.email.Value); replace(priorBody, "next_phone", thisUser.phone.Value); currentBody.Append(recvMsg); replace(currentBody, "prev_first_name", prior.first_name.Value); replace(currentBody, "prev_last_name", prior.last_name.Value); replace(currentBody, "prev_email", prior.email.Value); replace(currentBody, "prev_phone", prior.phone.Value); priorBody.Append(footerMsg); Email priorEmail = new Email(); priorEmail.subject = subj; priorEmail.Body = priorBody.ToString(); priorEmail.addTo(prior.email.Value); priorEmail.from = Organization.Current.getFromEmail(); priorEmail.send(); } if (next != null) { StringBuilder nextBody = new StringBuilder(header); replace(nextBody, "day_name", getDay(nextDow)); replace(nextBody, "time", getTime(nextTod)); nextBody.Append(recvMsg); replace(nextBody, "prev_first_name", thisUser.first_name.Value); replace(nextBody, "prev_last_name", thisUser.last_name.Value); replace(nextBody, "prev_email", thisUser.email.Value); replace(nextBody, "prev_phone", thisUser.phone.Value); currentBody.Append(giveMsg); replace(currentBody, "next_first_name", next.first_name.Value); replace(currentBody, "next_last_name", next.last_name.Value); replace(currentBody, "next_email", next.email.Value); replace(currentBody, "next_phone", next.phone.Value); nextBody.Append(footerMsg); Email nextEmail = new Email(); nextEmail.subject = subj; nextEmail.Body = nextBody.ToString(); nextEmail.addTo(next.email.Value); nextEmail.from = Organization.Current.getFromEmail(); nextEmail.send(); } currentBody.Append(footerMsg); Email thisEmail = new Email(); thisEmail.subject = subj; thisEmail.Body = currentBody.ToString(); thisEmail.addTo(thisUser.email.Value); thisEmail.from = Organization.Current.getFromEmail(); thisEmail.send(); }