private void btnSubmit_Click(object sender, EventArgs e) { if (!this.Page.IsValid) { this.Page.FindControl("valSummary").Visible = true; return; } if (!(this.tbEmail.Text.Trim().ToLower() != this.iEmail.Value)) { this.CreateAccount(); return; } PersonCollection personCollection = new PersonCollection(); personCollection.LoadByEmail(this.tbEmail.Text.Trim()); if (personCollection.Count <= 0) { this.CreateAccount(); return; } this.phExistingAccounts.Controls.Clear(); StringBuilder stringBuilder = new StringBuilder(); foreach (Person current in personCollection) { using (List <Arena.Security.Login> .Enumerator enumerator2 = current.Logins.GetEnumerator()) { if (enumerator2.MoveNext()) { Arena.Security.Login arg_A5_0 = enumerator2.Current; stringBuilder.AppendFormat("{0} - <a href='default.aspx?page={1}&email={2}'>Send Info</a><br>", current.FullName, this.RequestInfoPageIDSetting, this.tbEmail.Text.Trim()); } } } if (stringBuilder.Length > 0) { this.phExistingAccounts.Controls.Add(new LiteralControl(stringBuilder.ToString())); this.pnlMessage.Visible = true; this.pnlEmailExists.Visible = true; this.iEmail.Value = this.tbEmail.Text.Trim().ToLower(); return; } this.CreateAccount(); }
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); } }