/// <summary> /// Adds the given family member to the configured tag (and tag member status). /// This logic was harvested dirctly from our custom UserConfirmation.ascx module /// which is a variant of Arena's UserConfirmation. /// </summary> /// <param name="fm">a family member</param> private void AddToTag(FamilyMember fm) { string text = base.CurrentUser.Identity.Name; if (text == string.Empty) { text = "Cccev.Core.FamilyRegistration.ascx"; } int profileId = -1; int lookupID = -1; int lookupID2 = -1; try { if (this.ProfileIDSetting.Contains("|")) { profileId = int.Parse(this.ProfileIDSetting.Split(new char[] { '|' })[1]); } else { profileId = int.Parse(this.ProfileIDSetting); } lookupID = int.Parse(this.SourceLUIDSetting); lookupID2 = int.Parse(this.StatusLUIDSetting); } catch (System.Exception inner2) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "If using a ProfileID setting for this module, then a valid numeric 'ProfileID', 'SourceLUID', and 'StatusLUID' setting must all be used!", inner2); } Profile profile = new Profile(profileId); Lookup lookup6 = new Lookup(lookupID); Lookup lookup7 = new Lookup(lookupID2); if (profile.ProfileID == -1 || lookup6.LookupID == -1 || lookup7.LookupID == -1) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "'ProfileID', 'SourceLUID', and 'StatusLUID' must all be valid IDs"); } ProfileMember profileMember = new ProfileMember(); profileMember.ProfileID = profile.ProfileID; profileMember.PersonID = fm.PersonID; profileMember.Source = lookup6; profileMember.Status = lookup7; profileMember.DatePending = DateTime.Now; profileMember.Save(text); if (profile.ProfileType == ProfileType.Serving) { ServingProfile servingProfile = new ServingProfile(profile.ProfileID); new ServingProfileMember(profileMember.ProfileID, profileMember.PersonID) { HoursPerWeek = servingProfile.DefaultHoursPerWeek }.Save(); } }
private void CreateAccount() { Arena.Security.Login login = new Arena.Security.Login(this.tbLoginID.Text); if (login.PersonID != -1) { int num = 0; string text = this.tbFirstName.Text.Substring(0, 1).ToLower() + this.tbLastName.Text.Trim().ToLower(); if (text != this.tbLoginID.Text.Trim().ToLower()) { login = new Arena.Security.Login(text); } while (login.PersonID != -1) { num++; login = new Arena.Security.Login(text + num.ToString()); } this.lblMessage.Text = "The Desired Login ID you selected is already in use in our system. Please select a different Login ID. Suggestion: <b>" + text + num.ToString() + "</b>"; this.pnlMessage.Visible = true; this.lblMessage.Visible = true; return; } Lookup lookup; try { lookup = new Lookup(int.Parse(this.MemberStatusIDSetting)); if (lookup.LookupID == -1) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "Member Status setting must be a valid Member Status Lookup value."); } } catch (System.Exception inner) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "Member Status setting must be a valid Member Status Lookup value.", inner); } int organizationID = base.CurrentPortal.OrganizationID; string text2 = base.CurrentUser.Identity.Name; if (text2 == string.Empty) { text2 = "NewAccount.ascx"; } Person person = new Person(); person.RecordStatus = RecordStatus.Pending; person.MemberStatus = lookup; if (ddlCampus.SelectedValue != string.Empty || this.CampusSetting != string.Empty) { // use the user set value if it exists, otherwise use the admin configured module setting string campusString = (ddlCampus.SelectedValue != string.Empty) ? ddlCampus.SelectedValue : this.CampusSetting; try { person.Campus = new Campus(int.Parse(campusString)); } catch { person.Campus = null; } } person.FirstName = this.tbFirstName.Text.Trim(); person.LastName = this.tbLastName.Text.Trim(); if (this.tbBirthDate.Text.Trim() != string.Empty) { try { person.BirthDate = DateTime.Parse(this.tbBirthDate.Text); } catch { } } if (this.ddlMaritalStatus.SelectedValue != string.Empty) { person.MaritalStatus = new Lookup(int.Parse(this.ddlMaritalStatus.SelectedValue)); } if (this.ddlGender.SelectedValue != string.Empty) { try { person.Gender = (Gender)Enum.Parse(typeof(Gender), this.ddlGender.SelectedValue); } catch { } } PersonAddress personAddress = new PersonAddress(); personAddress.Address = new Address(this.tbStreetAddress.Text.Trim(), string.Empty, this.tbCity.Text.Trim(), this.ddlState.SelectedValue, this.tbZipCode.Text.Trim(), false); personAddress.AddressType = new Lookup(SystemLookup.AddressType_Home); personAddress.Primary = true; person.Addresses.Add(personAddress); PersonPhone personPhone = new PersonPhone(); personPhone.Number = this.tbHomePhone.PhoneNumber.Trim(); personPhone.PhoneType = new Lookup(SystemLookup.PhoneType_Home); person.Phones.Add(personPhone); if (this.tbWorkPhone.PhoneNumber.Trim() != string.Empty) { personPhone = new PersonPhone(); personPhone.Number = this.tbWorkPhone.PhoneNumber.Trim(); personPhone.Extension = this.tbWorkPhone.Extension; personPhone.PhoneType = new Lookup(SystemLookup.PhoneType_Business); person.Phones.Add(personPhone); } if (this.tbCellPhone.PhoneNumber.Trim() != string.Empty) { personPhone = new PersonPhone(); personPhone.Number = this.tbCellPhone.PhoneNumber.Trim(); personPhone.PhoneType = new Lookup(SystemLookup.PhoneType_Cell); personPhone.SMSEnabled = this.cbSMS.Checked; person.Phones.Add(personPhone); } if (this.tbEmail.Text.Trim() != string.Empty) { PersonEmail personEmail = new PersonEmail(); personEmail.Active = true; personEmail.Email = this.tbEmail.Text.Trim(); person.Emails.Add(personEmail); } person.Save(organizationID, text2, false); person.SaveAddresses(organizationID, text2); person.SavePhones(organizationID, text2); person.SaveEmails(organizationID, text2); Family family = new Family(); family.OrganizationID = organizationID; family.FamilyName = this.tbLastName.Text.Trim() + " Family"; family.Save(text2); new FamilyMember(family.FamilyID, person.PersonID) { FamilyID = family.FamilyID, FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult) }.Save(text2); Arena.Security.Login login2 = new Arena.Security.Login(); login2.PersonID = person.PersonID; login2.LoginID = this.tbLoginID.Text.Trim(); login2.Password = this.tbPassword.Text.Trim(); if (bool.Parse(this.EmailVerificationSetting)) { login2.Active = false; } else { login2.Active = true; } login2.Save(text2); login2 = new Arena.Security.Login(login2.LoginID); if (bool.Parse(this.EmailVerificationSetting)) { NewUserAccountEmailVerification newUserAccountEmailVerification = new NewUserAccountEmailVerification(); Dictionary <string, string> dictionary = new Dictionary <string, string>(); dictionary.Add("##FirstName##", person.FirstName); dictionary.Add("##LastName##", person.LastName); dictionary.Add("##Birthdate##", person.BirthDate.ToShortDateString()); dictionary.Add("##MaritalStatus##", person.MaritalStatus.Value); dictionary.Add("##Gender##", person.Gender.ToString()); dictionary.Add("##StreetAddress##", (person.Addresses.Count > 0) ? person.Addresses[0].Address.StreetLine1 : "N/A"); dictionary.Add("##City##", (person.Addresses.Count > 0) ? person.Addresses[0].Address.City : "N/A"); dictionary.Add("##State##", (person.Addresses.Count > 0) ? person.Addresses[0].Address.State : "N/A"); dictionary.Add("##ZipCode##", (person.Addresses.Count > 0) ? person.Addresses[0].Address.PostalCode : "N/A"); dictionary.Add("##HomePhone##", this.tbHomePhone.PhoneNumber); dictionary.Add("##WorkPhone##", this.tbWorkPhone.PhoneNumber); dictionary.Add("##CellPhone##", this.tbCellPhone.PhoneNumber); dictionary.Add("##Login##", this.tbLoginID.Text); dictionary.Add("##Password##", this.tbPassword.Text); dictionary.Add("##VerificationURL##", string.Format(base.CurrentOrganization.Url + (base.CurrentOrganization.Url.EndsWith("/") ? "" : "/") + "default.aspx?page={0}&pid={1}&un={2}&org={3}&h={4}", new object[] { string.IsNullOrEmpty(this.NewUserVerificationPageSetting) ? "" : this.NewUserVerificationPageSetting, person.PersonID.ToString(), login2.LoginID, base.CurrentOrganization.OrganizationID.ToString(), this.CreateHash(login2.PersonID.ToString() + login2.DateCreated.ToString() + login2.LoginID) })); newUserAccountEmailVerification.Send(person.Emails.FirstActive, dictionary, login2.PersonID); } else { FormsAuthentication.SetAuthCookie(login2.LoginID, false); base.Response.Cookies["portalroles"].Value = string.Empty; } if (this.ProfileIDSetting != string.Empty) { int profileId = -1; int lookupID = -1; int lookupID2 = -1; try { if (this.ProfileIDSetting.Contains("|")) { profileId = int.Parse(this.ProfileIDSetting.Split(new char[] { '|' })[1]); } else { profileId = int.Parse(this.ProfileIDSetting); } lookupID = int.Parse(this.SourceLUIDSetting); lookupID2 = int.Parse(this.StatusLUIDSetting); } catch (System.Exception inner2) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "If using a ProfileID setting for the NewAccount module, then a valid numeric 'ProfileID', 'SourceLUID', and 'StatusLUID' setting must all be used!", inner2); } Profile profile = new Profile(profileId); Lookup lookup2 = new Lookup(lookupID); Lookup lookup3 = new Lookup(lookupID2); if (profile.ProfileID == -1 || lookup2.LookupID == -1 || lookup3.LookupID == -1) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "'ProfileID', 'SourceLUID', and 'StatusLUID' must all be valid IDs"); } ProfileMember profileMember = new ProfileMember(); profileMember.ProfileID = profile.ProfileID; profileMember.PersonID = person.PersonID; profileMember.Source = lookup2; profileMember.Status = lookup3; profileMember.DatePending = DateTime.Now; profileMember.Save(text2); if (profile.ProfileType == ProfileType.Serving) { ServingProfile servingProfile = new ServingProfile(profile.ProfileID); new ServingProfileMember(profileMember.ProfileID, profileMember.PersonID) { HoursPerWeek = servingProfile.DefaultHoursPerWeek }.Save(); } } string text3 = base.Session["RedirectValue"].ToString(); if (!string.IsNullOrEmpty(text3)) { base.Session["RedirectValue"] = null; base.Response.Redirect(text3); } }
/// <summary> /// Add a placemark object to a profile. If the placemark is a PersonPlacemark /// then the associated person record is used. If it is a FamilyPlacemark then /// all the members of the family are used. Otherwise the placemark is ignored. /// This method only adds individuals who are not already a member of the tag. /// </summary> /// <param name="placemark">The placemark to add to the profile.</param> /// <param name="profile">The profile to add the members to.</param> private void AddPlacemarkToProfile(Placemark placemark, Profile profile) { List <Person> people = new List <Person>(); // // Convert the placemark into a list of people that should be added. // if (placemark.GetType() == typeof(PersonPlacemark)) { people.Add(((PersonPlacemark)placemark).GetPerson()); } else if (placemark.GetType() == typeof(FamilyPlacemark)) { foreach (Person p in ((FamilyPlacemark)placemark).GetFamily().FamilyMembersActive) { people.Add(p); } } // // For each person found, verify that they should be added and then // add them if they are not already in the profile. // foreach (Person p in people) { ProfileMember pm; // // Verify they are an adult if the user wants only adults. // if (profileOnlyAdults.Checked == true) { FamilyMember fm = new FamilyMember(p.FamilyId, p.PersonID); if (!fm.FamilyRole.Guid.ToString().Equals("e410e1a6-8715-4bfb-bf03-1cd18051f815", StringComparison.InvariantCultureIgnoreCase)) { continue; } } // // Verify they are not already in the profile. // pm = new ProfileMember(profile.ProfileID, p); if (pm.ProfileID == -1) { pm = new ProfileMember(); // // Add them to the profile. // pm.ProfileID = profile.ProfileID; pm.PersonID = p.PersonID; pm.Source = ProfileSource; pm.Status = ProfileStatus; pm.DateActive = DateTime.Now; pm.Save(ArenaContext.Current.User.Identity.Name); // // If this is a serving profile, we need a little more information. // if (profile.ProfileType == Enums.ProfileType.Serving) { ServingProfile sp = new ServingProfile(profile.ProfileID); ServingProfileMember spm = new ServingProfileMember(pm.ProfileID, pm.PersonID); spm.HoursPerWeek = sp.DefaultHoursPerWeek; spm.Save(ArenaContext.Current.User.Identity.Name); } } } }
/// <summary> /// Adds the person to the tag provided in the RedirectValue /// (similar to Arena's ProfileMemberAdd module) /// </summary> private void AddToTag(string queryString) { var activityNote = "Person added themself through web interface."; // Just in case there's no profile in the querystring AND in case it's not a number... try { var userID = (base.CurrentUser.Identity.Name != null && base.CurrentUser.Identity.Name != "") ? base.CurrentUser.Identity.Name : "UserConfirmation.ascx"; string[] values = queryString.Split('&'); var item = (from string q in values where q.StartsWith("profile=") select q).FirstOrDefault(); if (item == null) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "Profile id was missing from querystring."); } var notes = (from string q in values where q.StartsWith("Notes=") select q).FirstOrDefault(); var moreInfo = (from string q in values where q.StartsWith("MoreInfo") select q).FirstOrDefault(); int profileId = int.Parse(item.Split('=')[1]); Profile profile = new Profile(profileId); ProfileMember profileMember = new ProfileMember(profile.ProfileID, person); if (profileMember.ProfileID == -1) { int lookupID = -1; int lookupID2 = -1; try { lookupID = int.Parse(this.SourceLUIDSetting); lookupID2 = int.Parse(this.StatusLUIDSetting); } catch (Exception inner) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "A valid numeric 'Default Source ID', and 'Default Status ID' setting are required!", inner); } if (profile.ProfileType == ProfileType.Event) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "Event tags are not supported."); } else { profileMember.ProfileID = profile.ProfileID; profileMember.PersonID = person.PersonID; profileMember.Source = new Lookup(lookupID); profileMember.Status = new Lookup(lookupID2); profileMember.DatePending = DateTime.Now; if (moreInfo != null) { profileMember.MemberNotes += "User Requested More Information! "; } if (notes != null) { profileMember.MemberNotes += HttpUtility.UrlDecode(notes.Split('=')[1]); } profileMember.Save(userID); if (profile.ProfileType == ProfileType.Serving) { ServingProfile servingProfile = new ServingProfile(profile.ProfileID); new ServingProfileMember(profileMember.ProfileID, profileMember.PersonID) { HoursPerWeek = servingProfile.DefaultHoursPerWeek }.Save(); } } } else if (notes != null) { activityNote = HttpUtility.UrlDecode(notes.Split('=')[1]); } int lookupID3 = new Lookup(SystemLookup.ServingActivityType_StatusChange).LookupID; new ProfileMemberActivityData().SaveProfileMemberActivity(profile.ProfileID, person.PersonID, userID, lookupID3, activityNote); Response.Redirect(RedirectAfterSuccessURLSetting, true); } catch (Exception) { lblMessage.Text = "An error occurred which prevented us from adding you to that opportunity. Please contact the church office."; lblMessage.Visible = true; pnlMessage.Visible = true; } }
private void UpdateAccount() { int organizationID = base.CurrentPortal.OrganizationID; string text = base.CurrentUser.Identity.Name; if (text == string.Empty) { text = "UserConfirmation.ascx"; } // New cccev code... if (this.person.PersonID == -1) { TryFindExistingPerson(); } // End cccev code Person oldPerson = new Person(this.person.PersonID); bool isNewPerson = this.person.PersonID == -1; if (isNewPerson) { this.person.RecordStatus = RecordStatus.Pending; Lookup lookup; try { lookup = new Lookup(int.Parse(this.MemberStatusIDSetting)); if (lookup.LookupID == -1) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "Member Status setting must be a valid Member Status Lookup value."); } } catch (System.Exception inner) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "Member Status setting must be a valid Member Status Lookup value.", inner); } this.person.MemberStatus = lookup; if (this.CampusSetting != string.Empty) { try { this.person.Campus = new Campus(int.Parse(this.CampusSetting)); } catch { this.person.Campus = null; } } else if (RequireCampusSetting) { this.person.Campus = new Campus(int.Parse(this.ddlCampus.SelectedValue)); } } this.person.FirstName = this.tbFirstName.Text.Trim(); this.person.LastName = this.tbLastName.Text.Trim(); this.person.Emails.FirstActive = this.tbEmail.Text.Trim(); // Campus if (RequireCampusSetting) { this.person.Campus = new Campus(int.Parse(this.ddlCampus.SelectedValue)); } // Birth Date if (RequireBirthDateSetting && this.tbBirthDate.Text.Trim() != string.Empty) // Cccev { try { this.person.BirthDate = DateTime.Parse(this.tbBirthDate.Text); } catch { } } // Marital Status if (RequireMaritalStatusSetting && this.ddlMaritalStatus.SelectedValue != string.Empty) // Cccev { this.person.MaritalStatus = new Lookup(int.Parse(this.ddlMaritalStatus.SelectedValue)); } // Gender if (RequireGenderSetting && this.ddlGender.SelectedValue != string.Empty) // Cccev { try { this.person.Gender = (Gender)Enum.Parse(typeof(Gender), this.ddlGender.SelectedValue); } catch { } } // Address Lookup lookup2 = new Lookup(SystemLookup.AddressType_Home); PersonAddress personAddress = this.person.Addresses.FindByType(lookup2.LookupID); if (personAddress == null) { personAddress = new PersonAddress(); personAddress.AddressType = lookup2; this.person.Addresses.Add(personAddress); } if (RequireAddressSetting) // Cccev { personAddress.Address = new Address(this.tbStreetAddress.Text.Trim(), string.Empty, this.tbCity.Text.Trim(), this.ddlState.SelectedValue, this.tbZipCode.Text.Trim(), false); personAddress.Primary = true; } // Home Phone Lookup lookup3 = new Lookup(SystemLookup.PhoneType_Home); PersonPhone personPhone = this.person.Phones.FindByType(lookup3.LookupID); if (personPhone == null) { personPhone = new PersonPhone(); personPhone.PhoneType = lookup3; this.person.Phones.Add(personPhone); } if (RequireHomePhoneSetting) // Cccev { personPhone.Number = this.tbHomePhone.PhoneNumber.Trim(); } // Business Phone Lookup lookup4 = new Lookup(SystemLookup.PhoneType_Business); PersonPhone personPhone2 = this.person.Phones.FindByType(lookup4.LookupID); if (personPhone2 == null) { personPhone2 = new PersonPhone(); personPhone2.PhoneType = lookup4; this.person.Phones.Add(personPhone2); } if (RequireWorkPhoneSetting) // Cccev { personPhone2.Number = this.tbWorkPhone.PhoneNumber.Trim(); } // Cell Phone Lookup lookup5 = new Lookup(SystemLookup.PhoneType_Cell); PersonPhone personPhone3 = this.person.Phones.FindByType(lookup5.LookupID); if (personPhone3 == null) { personPhone3 = new PersonPhone(); personPhone3.PhoneType = lookup5; this.person.Phones.Add(personPhone3); } if (RequireCellPhoneSetting) // Cccev { personPhone3.Number = this.tbCellPhone.PhoneNumber.Trim(); personPhone3.SMSEnabled = this.cbCellSMS.Checked; } string personChanges = this.GetPersonChanges(oldPerson, this.person, isNewPerson); this.person.Save(organizationID, text, false); this.person.SaveAddresses(organizationID, text); this.person.SavePhones(organizationID, text); this.person.SaveEmails(organizationID, text); this.SaveAttributeValues(this.person); if (isNewPerson) { string userName = new LoginData().CreateNewLogin(this.person.PersonID, text); FormsAuthentication.SetAuthCookie(userName, false); base.Response.Cookies["portalroles"].Value = string.Empty; Family family = new Family(); family.OrganizationID = organizationID; family.FamilyName = this.tbLastName.Text.Trim() + " Family"; family.Save(text); new FamilyMember(family.FamilyID, this.person.PersonID) { FamilyID = family.FamilyID, FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult) }.Save(text); if (this.ProfileIDSetting != string.Empty) { int profileId = -1; int lookupID = -1; int lookupID2 = -1; try { if (this.ProfileIDSetting.Contains("|")) { profileId = int.Parse(this.ProfileIDSetting.Split(new char[] { '|' })[1]); } else { profileId = int.Parse(this.ProfileIDSetting); } lookupID = int.Parse(this.SourceLUIDSetting); lookupID2 = int.Parse(this.StatusLUIDSetting); } catch (System.Exception inner2) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "If using a ProfileID setting for the NewAccount module, then a valid numeric 'ProfileID', 'SourceLUID', and 'StatusLUID' setting must all be used!", inner2); } Profile profile = new Profile(profileId); Lookup lookup6 = new Lookup(lookupID); Lookup lookup7 = new Lookup(lookupID2); if (profile.ProfileID == -1 || lookup6.LookupID == -1 || lookup7.LookupID == -1) { throw new ModuleException(base.CurrentPortalPage, base.CurrentModule, "'ProfileID', 'SourceLUID', and 'StatusLUID' must all be valid IDs"); } ProfileMember profileMember = new ProfileMember(); profileMember.ProfileID = profile.ProfileID; profileMember.PersonID = this.person.PersonID; profileMember.Source = lookup6; profileMember.Status = lookup7; profileMember.DatePending = DateTime.Now; profileMember.Save(text); if (profile.ProfileType == ProfileType.Serving) { ServingProfile servingProfile = new ServingProfile(profile.ProfileID); new ServingProfileMember(profileMember.ProfileID, profileMember.PersonID) { HoursPerWeek = servingProfile.DefaultHoursPerWeek }.Save(); } } } if (this.NotifySetting != string.Empty) { this.SendNotification(this.person, personChanges); } string text2 = base.Session["RedirectValue"].ToString().Trim(); if (this.tbNotes.Text.Trim() != string.Empty) { text2 = text2 + "&Notes=" + (this.tbNotes.Text.Trim()); } if (text2 != string.Empty) { AddToTag(text2); base.Session["RedirectValue"] = null; //text2 += "&confirmed=true"; //base.Response.Redirect(text2, true); } }
private void btnSubmit_Click(object sender, EventArgs e) { int i, profileID; CheckBox cbox; ProfileMember pm; Profile profile; Lookup luSource, luStatus; string userID = CurrentUser.Identity.Name; // // Lookup the profile source. // luSource = new Lookup(Int32.Parse(SourceLUIDSetting)); luStatus = new Lookup(Int32.Parse(StatusLUIDSetting)); if (luSource.LookupID == -1 || luStatus.LookupID == -1) { } // // Walk each of the controls found and determine if we need to // take any action for the value of that control. // for (i = 0; i < phProfiles.Controls.Count; i++) { // // If the control is not a checkbox or radio button then // ignore it. // if (phProfiles.Controls[i].GetType() != typeof(CheckBox) && phProfiles.Controls[i].GetType() != typeof(RadioButton)) { continue; } // // Pretend the control is a checkbox, if it is a radio button // it will cast fine since the radio button inherits from a // check box. // cbox = (CheckBox)phProfiles.Controls[i]; profileID = Int32.Parse(cbox.ID); profile = new Profile(profileID); // // If this control is turned on and it is not a "none of the above" // setting, then we need to take action. // if (cbox.Checked == true && profile.ProfileID != -1) { // // Verify this person is not already in the profile. // pm = new ProfileMember(profileID, ArenaContext.Current.Person); if (pm.ProfileID == -1) { // // The person needs to be added to the profile, generate all // the standard information. // pm = new ProfileMember(); pm.ProfileID = profileID; pm.PersonID = ArenaContext.Current.Person.PersonID; pm.Source = luSource; pm.Status = luStatus; pm.DatePending = DateTime.Now; pm.Save(userID); // // If the profile is a serving tag then we need to generate // a little bit more information. // if (profile.ProfileType == ProfileType.Serving) { ServingProfile sProfile = new ServingProfile(profile.ProfileID); ServingProfileMember sMember = new ServingProfileMember(pm.ProfileID, pm.PersonID); sMember.HoursPerWeek = sProfile.DefaultHoursPerWeek; sMember.Save(); } } } } // // Redirect browser back to originating page. // Response.Redirect(iRedirect.Value); }
private void CreateAccount() { Arena.Security.Login login; string loginID; if (CustomLoginSetting == true) { // Ensure that login ID is unique loginID = tbLoginID.Text; login = new Arena.Security.Login(loginID); if (login.PersonID != -1) { int loginCount = 0; loginID = tbFirstName.Text.Substring(0, 1).ToLower() + tbLastName.Text.Trim().ToLower(); if (loginID != loginID.ToLower()) { login = new Arena.Security.Login(loginID); } while (login.PersonID != -1) { loginCount++; login = new Arena.Security.Login(loginID + loginCount.ToString()); } lblMessage.Text = "The Desired Login ID you selected is already in use in our system. Please select a different Login ID. Suggestion: <b>" + loginID + loginCount.ToString() + "</b>"; pnlMessage.Visible = true; lblMessage.Visible = true; return; } } else { Int32 loginCount = 0; // // Construct a login Id that can be used. // do { if (loginCount == 0) { loginID = tbFirstName.Text + " " + tbLastName.Text; } else { loginID = tbFirstName.Text + " " + tbLastName.Text + loginCount.ToString(); } loginID = loginID.ToLower(); login = new Arena.Security.Login(loginID); loginCount++; } while (login.PersonID != -1); } Lookup memberStatus; try { memberStatus = new Lookup(Int32.Parse(MemberStatusIDSetting)); if (memberStatus.LookupID == -1) { throw new ModuleException(CurrentPortalPage, CurrentModule, "Member Status setting must be a valid Member Status Lookup value."); } } catch (System.Exception ex) { throw new ModuleException(CurrentPortalPage, CurrentModule, "Member Status setting must be a valid Member Status Lookup value.", ex); } int organizationID = CurrentPortal.OrganizationID; string userID = CurrentUser.Identity.Name; if (userID == string.Empty) { userID = "NewAccount.ascx"; } Person person = new Person(); person.RecordStatus = RecordStatus.Pending; person.MemberStatus = memberStatus; if (CampusSetting != string.Empty) { try { person.Campus = new Arena.Organization.Campus(Int32.Parse(CampusSetting)); } catch { person.Campus = null; } } person.FirstName = tbFirstName.Text.Trim(); person.LastName = tbLastName.Text.Trim(); if (tbBirthDate.Text.Trim() != string.Empty) { try { person.BirthDate = DateTime.Parse(tbBirthDate.Text); } catch { } } if (ddlMaritalStatus.SelectedValue != string.Empty) { person.MaritalStatus = new Lookup(Int32.Parse(ddlMaritalStatus.SelectedValue)); } if (ddlGender.SelectedValue != string.Empty) { try { person.Gender = (Gender)Enum.Parse(typeof(Gender), ddlGender.SelectedValue); } catch { } } PersonAddress personAddress = new PersonAddress(); personAddress.Address = new Address( tbStreetAddress.Text.Trim(), string.Empty, tbCity.Text.Trim(), ddlState.SelectedValue, tbZipCode.Text.Trim(), false); personAddress.AddressType = new Lookup(SystemLookup.AddressType_Home); personAddress.Primary = true; person.Addresses.Add(personAddress); PersonPhone phone = new PersonPhone(); phone.Number = tbHomePhone.PhoneNumber.Trim(); phone.PhoneType = new Lookup(SystemLookup.PhoneType_Home); person.Phones.Add(phone); if (tbWorkPhone.PhoneNumber.Trim() != string.Empty) { phone = new PersonPhone(); phone.Number = tbWorkPhone.PhoneNumber.Trim(); phone.Extension = tbWorkPhone.Extension; phone.PhoneType = new Lookup(SystemLookup.PhoneType_Business); person.Phones.Add(phone); } if (tbCellPhone.PhoneNumber.Trim() != string.Empty) { phone = new PersonPhone(); phone.Number = tbCellPhone.PhoneNumber.Trim(); phone.PhoneType = new Lookup(SystemLookup.PhoneType_Cell); phone.SMSEnabled = cbSMS.Checked; person.Phones.Add(phone); } if (tbEmail.Text.Trim() != string.Empty) { PersonEmail personEmail = new PersonEmail(); personEmail.Active = true; personEmail.Email = tbEmail.Text.Trim(); person.Emails.Add(personEmail); } person.Save(organizationID, userID, false); person.SaveAddresses(organizationID, userID); person.SavePhones(organizationID, userID); person.SaveEmails(organizationID, userID); Family family = new Family(); family.OrganizationID = organizationID; family.FamilyName = tbLastName.Text.Trim() + " Family"; family.Save(userID); FamilyMember fm = new FamilyMember(family.FamilyID, person.PersonID); fm.FamilyID = family.FamilyID; fm.FamilyRole = new Lookup(SystemLookup.FamilyRole_Adult); fm.Save(userID); Arena.Security.Login personLogin = new Arena.Security.Login(); personLogin.PersonID = person.PersonID; personLogin.LoginID = loginID; personLogin.Password = tbPassword.Text.Trim(); personLogin.Active = true; personLogin.Save(userID); // Use security system to set the UserID within a client-side Cookie FormsAuthentication.SetAuthCookie(personLogin.LoginID, false); Response.Cookies["portalroles"].Value = string.Empty; if (ProfileIDSetting != string.Empty) { int profileID = -1; int sourceLUID = -1; int statusLUID = -1; try { if (ProfileIDSetting.Contains("|")) { profileID = Int32.Parse(ProfileIDSetting.Split('|')[1]); } else { profileID = Int32.Parse(ProfileIDSetting); } sourceLUID = Int32.Parse(SourceLUIDSetting); statusLUID = Int32.Parse(StatusLUIDSetting); } catch (System.Exception ex) { throw new ModuleException(CurrentPortalPage, CurrentModule, "If using a ProfileID setting for the NewAccount module, " + "then a valid numeric 'ProfileID', 'SourceLUID', and 'StatusLUID' setting must all be used!", ex); } Profile profile = new Profile(profileID); Lookup sourceLu = new Lookup(sourceLUID); Lookup statusLu = new Lookup(statusLUID); if (profile.ProfileID != -1 && sourceLu.LookupID != -1 && statusLu.LookupID != -1) { ProfileMember profileMember = new ProfileMember(); profileMember.ProfileID = profile.ProfileID; profileMember.PersonID = person.PersonID; profileMember.Source = sourceLu; profileMember.Status = statusLu; profileMember.DatePending = DateTime.Now; profileMember.Save(userID); if (profile.ProfileType == ProfileType.Serving) { ServingProfile sProfile = new ServingProfile(profile.ProfileID); ServingProfileMember sMember = new ServingProfileMember(profileMember.ProfileID, profileMember.PersonID); sMember.HoursPerWeek = sProfile.DefaultHoursPerWeek; sMember.Save(); } } else { throw new ModuleException(CurrentPortalPage, CurrentModule, "'ProfileID', 'SourceLUID', and 'StatusLUID' must all be valid IDs"); } } // // If we are letting the user pick their own login ID then just redirect // the browser back to the originating page. Otherwise put up some text to // tell the user what their new login ID is. // if (CustomLoginSetting == true) { Response.Redirect(iRedirect.Value); } else { pnlCreateAccount.Visible = false; lbLoginCreated.Text = "Your account has been created. Your login ID is \"" + loginID + "\".<BR /><BR />You may use this login ID the next time you visit this site.<BR />"; pnlLoginCreated.Visible = true; } }