protected void RegisterUser_CreatedUser(object sender, EventArgs e) { ProfileCommon p = new ProfileCommon(); p.Initialize(RegisterUser.UserName, true); p.Address = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextAddress")).Text; p.Name = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextName")).Text; p.Phone = ((TextBox)RegisterUser.CreateUserStep.ContentTemplateContainer.FindControl("TextPhone")).Text; //// Save the profile - must be done since we explicitly created this profile instance p.Save(); FormsAuthentication.SetAuthCookie(RegisterUser.UserName, false /* createPersistentCookie */); if (RegisterUser.UserName == "admin") { Roles.AddUserToRole(RegisterUser.UserName, "admin"); } else { Roles.AddUserToRole(RegisterUser.UserName, "customer"); } string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { continueUrl = "~/FirstPage.aspx"; } Response.Redirect(continueUrl); }
protected void btnSubmit_Click(object sender, EventArgs e) { ProfileCommon profile = Profile.GetProfile(User.Identity.Name); profile.Options.AllowFriendRequests = Convert.ToBoolean(rblFriendRequest.SelectedValue); profile.Options.DefaultPrivacySetting = rblGroup.SelectedValue; profile.Options.ShowBirthAge = Convert.ToInt32(rblShowBirthAge.SelectedValue); profile.Save(); lblSettingsSaved.Visible = true; }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { ProfileCommon profile = Profile.GetProfile(CreateUserWizard1.UserName); profile.Options.ShowEmail = false; profile.Options.NotifyPrivateMsg = false; profile.Options.PostsPerPage = 20; profile.Save(); Roles.AddUserToRole(CreateUserWizard1.UserName, "Normal bruger"); }
protected void importBtn_Click(object sender, EventArgs e) { //at = SpringUtil.at(); String sql = "SELECT a.* , a.Param13+c.city+b.name as zipcht from ImportData a , zip b , QryCity c where a.Param13=b.id and a.Param12=c.pid"; //DataTable lists = new DataTable(); //at.DataTableFill(lists, CommandType.Text, sql); OleDbCommand cmd = new OleDbCommand(sql); DataSet ds = SQLUtil.QueryDS(cmd); //foreach (DataRow dRow in lists.Rows) foreach (DataRow dRow in ds.Tables[0].Rows) { MembershipUser user = Membership.CreateUser(dRow["Param1"].ToString(), dRow["Param2"].ToString(), dRow["Param8"].ToString(), dRow["Param9"].ToString(), dRow["Param9"].ToString(), true, out mc); user.Comment = dRow["Param3"].ToString(); Roles.AddUserToRole(dRow["Param1"].ToString(), "user"); Membership.UpdateUser(user); p = (ProfileCommon)ProfileCommon.Create(dRow["Param1"].ToString(), true); p.UserProfile.Owner = dRow["Param11"].ToString(); p.UserProfile.Name = dRow["Param5"].ToString(); p.UserProfile.Tel = dRow["Param6"].ToString(); p.UserProfile.Corp = dRow["Param3"].ToString(); p.UserProfile.City = dRow["Param12"].ToString(); p.UserProfile.Postcode = dRow["Param13"].ToString(); p.UserProfile.Address = dRow["Param4"].ToString(); p.UserProfile.Fax = dRow["Param7"].ToString(); p.UserProfile.Kind = dRow["Param10"].ToString(); p.UserProfile.Type = dRow["Param9"].ToString(); p.UserProfile.Zipcht = dRow["zipcht"].ToString(); p.Save(); UserProfiles up = new UserProfiles(); up.Username = dRow["Param1"].ToString(); up.Owner = dRow["Param11"].ToString(); up.Name = dRow["Param5"].ToString(); up.Tel = dRow["Param6"].ToString(); up.Corp = dRow["Param3"].ToString(); up.City = dRow["Param12"].ToString(); up.Postcode = dRow["Param13"].ToString(); up.Address = dRow["Param4"].ToString(); up.Fax = dRow["Param7"].ToString(); up.Kind = dRow["Param10"].ToString(); up.Type = dRow["Param9"].ToString(); up.Zipcht = dRow["zipcht"].ToString(); //mgr.Save(null, null, up); } }
protected void ChangeTheme(string themeName) { ProfileCommon profile = HttpContext.Current.Profile as ProfileCommon; if (string.Compare(themeName, Page.Theme, true) != 0) { profile.Theme = themeName; profile.Save(); Server.Transfer(HttpContext.Current.Request.RawUrl); } }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { ProfileCommon pc = new ProfileCommon(); pc.Initialize(CreateUserWizard1.UserName.ToString(), true); pc.FirstName = Firstname.Text; pc.LastName = Lastname.Text; pc.Age = Age.Text; pc.Save(); }
protected void Button2_Click(object sender, EventArgs e) { /* MembershipUser user = Membership.GetUser(TextBox1.Text); * var profile = HttpContext.Current.Profile; * profile.SetPropertyValue("Name", TextBox4.Text); * profile.Save();*/ ProfileCommon pc = Profile.GetProfile(TextBox1.Text); pc.Name = TextBox4.Text; pc.Save(); }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true); p.Name = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtName")).Text; p.BirthDate = DateTime.Parse(((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("txtBirthDate")).Text); p.Save(); //Roles.AddUserToRole(CreateUserWizard1.UserName, "Authenticated"); }
public void ChangeMember(string userID, string email, string clientID) { MembershipUser user = Membership.GetUser(userID); user.Email = email; Membership.UpdateUser(user); ProfileCommon profile = new ProfileCommon().GetProfile(userID); profile.ClientID = clientID; profile.Save(); }
public void AddNewUser(string username, string password, string email, string birthdate, string s_mob, string m_mob, string f_mob, string fullname, string gender, string address) { /* string username = Context.Request.Params.Get(""); * string password = Context.Request.Params.Get(""); * string email = Context.Request.Params.Get(""); * string birthdate = Context.Request.Params.Get(""); * string s_mob = Context.Request.Params.Get(""); * string m_mob = Context.Request.Params.Get(""); * string f_mob = Context.Request.Params.Get(""); * string fullname = Context.Request.Params.Get(""); * string gender = Context.Request.Params.Get(""); * string address = Context.Request.Params.Get("");*/ var success = new Dictionary <string, Boolean>(); Context.Response.AppendHeader("Access-Control-Allow-Origin", "*"); Context.Response.ContentType = "application/json"; /* MembershipCreateStatus status; * Membership.CreateUser(username, password, email, "Username?", username, true, out status);*/ MembershipCreateStatus status; Membership.CreateUser(username, password, email, "Username?", username, true, out status); if (status == MembershipCreateStatus.Success) { SqlConnection cn = new SqlConnection(); cn.ConnectionString = @"Data Source=.\SQLEXPRESS;AttachDbFilename=C:\Users\Mansuri\Desktop\PROJECT2020\App_Data\ASPNETDB.MDF;Integrated Security=True;User Instance=True"; cn.Open(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "INSERT INTO STUDENT(Birth_Date, M_Mobile_No, F_Mobile_No,UserName) VALUES ('" + birthdate + "' , '" + m_mob + "' , '" + f_mob + "' , '" + username + "')"; cmd.Connection = cn; cmd.ExecuteNonQuery(); ProfileCommon pc = (ProfileCommon)ProfileBase.Create(username, true); pc.Name = fullname; pc.Address = address; pc.Gender = gender; pc.MobileNo = s_mob; pc.Save(); success.Add("Success", true); cn.Close(); } else { success.Add("Success", false); } JavaScriptSerializer js = new JavaScriptSerializer(); Context.Response.Write(js.Serialize(success)); }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { ProfileCommon userProfile = Profile.GetProfile(CreateUserWizard1.UserName); userProfile.Stabsnummer = ((TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("txtStabsnummer")).Text.ToUpper(); userProfile.Firstname = ((TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("txtFirstname")).Text; userProfile.Middlename = ((TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("txtMiddlename")).Text; userProfile.Lastname = ((TextBox)CreateUserWizardStep1.ContentTemplateContainer.FindControl("txtLastname")).Text; userProfile.Save(); Roles.AddUserToRole(CreateUserWizard1.UserName, "User"); }
protected void OnCommand(object sender, CommandEventArgs e) { //Event handler for command button clicked string userID = ""; switch (e.CommandName) { case "Refresh": Cache["Users"] = new object(); this.grdUsers.DataBind(); break; case "Welcome": //Send a welcome message to the selected user userID = this.grdUsers.SelectedValue.ToString(); string userName = this.grdUsers.SelectedRow.Cells[2].Text; string email = this.grdUsers.SelectedRow.Cells[3].Text; if (new EmailServices().SendWelcomeMessage(userName, userID, email)) { Master.ShowMsgBox("Welcome email has been sent to " + userID + "."); } else { Master.ShowMsgBox("System Error: Welcome email could NOT be sent to " + userID + "."); } break; case "Reset": //Reset the selected users password userID = this.grdUsers.SelectedValue.ToString(); MembershipUser user = Membership.GetUser(userID); if (user.IsLockedOut) { //If user's account is locked out then unlock it first if (!user.UnlockUser()) { Master.ShowMsgBox("System could not unlock the user. Password was not reset."); return; } } string pwd = Membership.GeneratePassword(6, 0); user.ChangePassword(user.GetPassword(), pwd); ProfileCommon profile = new ProfileCommon().GetProfile(userID); profile.PasswordReset = true; profile.Save(); new EmailServices().SendPasswordResetMessage(user.UserName, user.Email, pwd); Master.ShowMsgBox("Password has been reset and emailed to the user."); break; } }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { try { SmtpClient smtp = new SmtpClient(); MailAddress sndr = new MailAddress("*****@*****.**", "fatihyildizhan.com__Aktivasyon E-Postası ", Encoding.Default); MailAddress receiver = new MailAddress(CreateUserWizard1.Email, "Sayın " + CreateUserWizard1.UserName, Encoding.Default); MailMessage mail = new MailMessage(sndr, receiver); string onayKodu = Guid.NewGuid().ToString(); ProfileCommon pf = Profile.GetProfile(CreateUserWizard1.UserName); pf.uyeINFO.OnayKodu = onayKodu; pf.Save(); mail.Subject = "fatihyildizhan.com__Üyelik Aktivasyonu"; mail.Body = "<P>Merhaba Sayın " + CreateUserWizard1.UserName + ",</P><P> Aktivasyon Kodunuz : " + onayKodu + "</P><P> Aktivasyon için <A title=Tıkla... href=" + "https://www.fatihyildizhan.com/userOnay.aspx" + " target=_blank>Tıkla...</A></P><P> Beklenmedik bir hata oluştuğunda lütfen <A href=" + "mailto:[email protected]" + ">[email protected]</A> adresine mail atınız. Mesajınız en geç 1 gün içerisinde cevaplanacaktır.</P><P>Sitenin içeriği Programlama Dilleri, Programlar, Haberler ve Download bölümlerinden oluşmaktadır. İstek ve Önerileriniz için iletişim bölümünü kullanabilirsiniz... <BR><BR>Son Eklenen Özellikler...<BR><SPAN class=style7><BR class=style6></SPAN><STRONG><U><FONT size=2><SPAN class=style6><SPAN class=style7>*** SSL desteği eklenmiştir...Bilgileri sitenin altındaki logodan edinebilirsiniz;</SPAN></SPAN><BR><BR></FONT></U>** Haberler bölümünden RSS leri takip edebilirsiniz ;<BR>** Java Uygulamaları ;<BR>** C# Uygulamaları ;<BR><BR></STRONG>*** Programlama Dilleri'ndeki mevcut konular için RSS yayını başlamıştır;<BR>(Sayfanın altında RSS linkini bulabilirsiniz..)<BR><BR>*** Sql Cache Dependency ;<I><BR></I>(SqlCache Dependency Nedir ? Sayfayı herhangi bir değişiklik olana kadar serverda saklar ve sitenin çalışma performansını artırır.)<BR><BR>Şuanda Kullanabileceğiniz Özellikler...<BR><BR>*Programla Dillerine İstatistik;<BR>* Üyelik Sistemi ;<BR>-- Üyeler arası mesajlaşma ;<BR> -Gelen Kutusu, Yenile, Mesaj Oku...<BR> *Giden Kutusu Yakında...<BR>* E-Posta ile Aktivasyon İşlemi ;<BR>* Detaylı Üye Profili Oluşturma / Düzenleme ;<BR>* Her konu için örneğin: destek istemek , tavsiyede bulunmak için iletişim paneli ;<BR>* Basit şekilde Java / Uygulama İndirme ;<BR>* Yönetici için Admin Paneli ;<BR><BR>Yakında Kullanıma Sunulacak Özellikler...<BR><BR>* Üyelere özel site ayarları örneğin: Size özel arkaplan rengi , buton rengi , arayüz dili ..<BR>* Üyelere özel istatistik bilgileri ..<BR>* Diğer yazılım dilleri için uygulama indirebilme ..<BR><BR> Görüşmek Üzere...<BR></P>"; mail.BodyEncoding = Encoding.Default; mail.IsBodyHtml = true; mail.Priority = MailPriority.Normal; smtp.Send(mail); } catch (Exception ex) { try { System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient(); System.Net.Mail.MailAddress sndr = new System.Net.Mail.MailAddress("*****@*****.**"); System.Net.Mail.MailAddress receiver = new System.Net.Mail.MailAddress("*****@*****.**", "FyDoxaAdmin"); string ip = Request.ServerVariables["REMOTE_ADDR"].ToString(); string zaman = DateTime.Now.ToLongTimeString(); string hata = "Inner Exception"; if (Server.GetLastError().InnerException != null) { hata = Server.GetLastError().InnerException.Message; } System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(sndr, receiver); mail.Subject = "Yeni Üye Kaydı Hatası"; mail.Body = "Hata Oluşma Zamanı : " + zaman + " <br/> Ip Adresi : " + ip + " <br/> Yardımcı Link : " + Server.GetLastError().HelpLink + " <br/> Oluşan Son Hata : " + Server.GetLastError().ToString() + " <br/> Inner Exception : " + hata + " <br/> Son Oluşan Hata'nın Data Bilgisi : " + Server.GetLastError().Data.ToString() + "Exception Adı : " + ex.ToString(); mail.BodyEncoding = Encoding.Default; mail.IsBodyHtml = true; mail.Priority = System.Net.Mail.MailPriority.Normal; smtp.Send(mail); } catch (Exception) { } } CreateUserWizard1.Visible = false; Panel1.Visible = true; txtKullaniciAd.Text = CreateUserWizard1.UserName; }
protected void BtnUpdate2_Click(object sender, EventArgs e) { //IAspnetUsersService mgrUser = (IAspnetUsersService)BaseAction.Context.GetObject("AspnetUsersService"); //IMembershipService mgrMember = (IMembershipService)BaseAction.Context.GetObject("MembershipService"); String sql = "SELECT * from aspnet_Users where UserName=@UserName "; OleDbCommand cmd = new OleDbCommand(sql); cmd.Parameters.Add("@UserName", OleDbType.Char).Value = User.Identity.Name; cmd.CommandType = CommandType.Text; DataSet ds = SQLUtil.QueryDS(cmd); string strUserID = ""; foreach (DataRow dr in ds.Tables[0].Rows) { strUserID = dr["UserId"].ToString(); } string strMemberShipSql = "update aspnet_Membership set Email=@Email where UserId=@UserId"; OleDbCommand cmdMemberShip = new OleDbCommand(strMemberShipSql); cmdMemberShip.Parameters.Add("@Email", OleDbType.Char).Value = Email.Text; cmdMemberShip.Parameters.Add("@UserId", OleDbType.Char).Value = strUserID; cmdMemberShip.CommandType = CommandType.Text; SQLUtil.ExecuteSql(cmdMemberShip); //AspnetUsers aspnetUsers = mgrUser.FindByProperty(User.Identity.Name); //AspnetMembership aspnetMembership = mgrMember.FindById(aspnetUsers.UserId); //aspnetMembership.Email = Email.Text; //mgrMember.Update(aspnetMembership); p = Profile.GetProfile(User.Identity.Name); p.UserProfile.Owner = Name.Text; p.UserProfile.Name = Name.Text; p.UserProfile.Tel = Tel.Text; p.UserProfile.Corp = Corp.Text; p.UserProfile.City = cityList.SelectedValue; p.UserProfile.Postcode = zipList.SelectedValue; p.UserProfile.Address = Address.Text; p.UserProfile.Fax = Fax.Text; p.UserProfile.Kind = Kind.SelectedValue; //p.UserProfile.Type = "1"; p.UserProfile.Zipcht = zipList.SelectedValue + cityList.SelectedItem.Text + zipList.SelectedItem.Text; p.Save(); BindProfileView(); MultiView1.ActiveViewIndex = 0; }
protected void LinkButton2_Click(object sender, EventArgs e) { TextBox1.Visible = false; TextBox2.Visible = false; TextBox3.Visible = false; TextBox4.Visible = false; TextBox5.Visible = false; TextBox6.Visible = false; TextBox7.Visible = false; TextBox8.Visible = false; DropDownList1.Visible = false; LinkButton1.Visible = true; LinkButton2.Visible = false; Label1.Visible = true; Label2.Visible = true; Label3.Visible = true; Label4.Visible = true; Label5.Visible = true; Label6.Visible = true; Label11.Visible = true; Label8.Visible = true; Label9.Visible = true; MembershipUser mem = Membership.GetUser(); string id = mem.UserName; MembershipUser u = Membership.GetUser(id); string c = u.UserName.ToString(); ProfileCommon comm = Profile.GetProfile(c); comm.name = TextBox1.Text; comm.Address = TextBox2.Text; comm.Landmark = TextBox3.Text; comm.City = TextBox4.Text; comm.State = DropDownList1.SelectedItem.Text.ToString(); comm.PostalCode = TextBox5.Text; comm.Mobile = TextBox6.Text; comm.Country = "India"; comm.ShippingEmail = TextBox8.Text; admin ad = new admin(); ad.updateuserpassword(c, TextBox7.Text); comm.Save(); ((user)this.Page.Master).data(); mailing mail = new mailing(); mail.mymail(Label10.Text, "Dear " + TextBox1.Text + "Your account details has been updated successfully." + "<br/><br/> Regards ,<br/>ZartShop.com", "Account Details"); filldata(); }
protected void OnCommand(object sender, CommandEventArgs e) { //Event handler for button command events switch (e.CommandName) { case "Cancel": Response.Redirect("Default.aspx", true); break; case "Submit": try { //Validate new password if (this.txtNewPassword.Text.Trim().Length >= Membership.MinRequiredPasswordLength) { //Change user password to the new value MembershipUser user = Membership.GetUser(); if (user.ChangePassword(this.txtOldPassword.Text, this.txtNewPassword.Text)) { //Reset user password reset flag; update cached profile ProfileCommon profile = new ProfileCommon().GetProfile(this.txtUserID.Text); profile.PasswordReset = false; profile.Save(); FormsAuthentication.SetAuthCookie(this.txtUserID.Text, false); System.Text.StringBuilder script = new System.Text.StringBuilder(); script.Append("<script language=javascript>"); script.Append("\talert('Your password has been changed.');"); script.Append("\twindow.navigate('Default.aspx');"); script.Append("</script>"); Page.ClientScript.RegisterStartupScript(typeof(Page), "PasswordChanged", script.ToString()); } else { rfvUserID.IsValid = false; rfvUserID.ErrorMessage = PASSWORD_CHANGE_ERROR; } } else { rfvUserID.IsValid = false; rfvUserID.ErrorMessage = PASSWORD_MIN_LENGHT; } } catch (Exception ex) { rfvUserID.IsValid = false; rfvUserID.ErrorMessage = "Unexpected error: " + ex.Message; } break; } }
protected void DeleteBookMark(object sender, ImageClickEventArgs e) { PageBase page = (PageBase)Page; var id = ((ImageButton)sender).CommandArgument; List <SnitzLink> bookmarks = page.Profile.BookMarks; var todelete = bookmarks.Find(i => i.ID == Convert.ToInt32(id)); bookmarks.Remove(todelete); _profile.BookMarks = bookmarks; _profile.Save(); repBookMarks.DataSource = _profile.BookMarks; repBookMarks.DataBind(); }
protected void btnGadgetLogin_Click(object sender, EventArgs e) { // first look at password if (!ConfigUtil.GetConfigItem("OpenSocialDevPassword").Equals(txtPassword.Text)) { return; } String userName = null; try { Database db = DatabaseFactory.CreateDatabase(); string sqlCommand = "select username from [user] where UserID = " + Int32.Parse(txtPersonId.Text) + ";"; DbCommand dbCommand = db.GetSqlStringCommand(sqlCommand); userName = (String)db.ExecuteScalar(dbCommand); ProfilesMembershipUser user = (ProfilesMembershipUser)Membership.GetUser(userName); // Get an instance of the ProfileCommon object ProfileCommon p = (ProfileCommon)ProfileCommon.Create(user.UserName, true); // Set our parameters from the custom authentication provider p.UserId = user.UserID; p.UserName = user.UserName; p.HasProfile = user.HasProfile; p.ProfileId = user.ProfileID; p.DisplayName = user.DisplayName; // Persist the profile data p.Save(); // Refetch the profile data Profile.Initialize(user.UserName, true); //Profile.GetProfile(user.UserName); FormsAuthentication.SetAuthCookie(userName, false); // add the gadgets Session[OpenSocialHelper.OPENSOCIAL_GADGETS] = txtGadgetURLS.Text; Session[OpenSocialHelper.OPENSOCIAL_DEBUG] = chkDebug.Checked; Session[OpenSocialHelper.OPENSOCIAL_NOCACHE] = !chkUseCache.Checked; Response.Redirect("~/Search.aspx"); } catch (Exception ex) { // do nothing } }
protected void btnEditUser_Click(object sender, EventArgs e) { string username = ddlEditUser.SelectedValue; string firstname = txtEditFirstname.Text; string lastname = txtEditLastname.Text; string password = txtEditPassword.Text; bool admin = chkbxEditAdmin.Checked; bool enabled = chkbxEditEnabled.Checked; MembershipUser user = Membership.GetUser(username); ProfileCommon profile = Profile.GetProfile(username); profile.Firstname = firstname; profile.Lastname = lastname; profile.Save(); DataAccessLayer dal = new DataAccessLayer(); dal.AddParameter("@Username", username, System.Data.DbType.String); dal.AddParameter("@Firstname", firstname, System.Data.DbType.String); dal.AddParameter("@Lastname", lastname, System.Data.DbType.String); dal.AddParameter("@By", Membership.GetUser().UserName, System.Data.DbType.String); dal.ExecuteNonQuery("EXEC dbo.UserDetailsUpdate @Username, @Firstname, @Lastname, @By"); dal.ClearParameters(); UpdateUserAdmin(username, admin); if (user.IsApproved != enabled) { user.IsApproved = enabled; Membership.UpdateUser(user); Logging.WriteLog(Logging.Action.Edit, Logging.ObjectType.ADUCUser, username, enabled ? "Enabled" : "Disabled"); } if (chkbxEditPassword.Checked) { if (user.IsLockedOut) { user.UnlockUser(); } btnEditUnlock.Visible = false; user.ChangePassword(user.ResetPassword(), txtEditPassword.Text); Logging.WriteLog(Logging.Action.ChangePassword, Logging.ObjectType.ADUCUser, user.UserName); } SetMessage(String.Format("{0} blev opdateret{1}", username, (chkbxEditPassword.Checked ? " med password " + txtEditPassword.Text : String.Empty))); }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { ProfileCommon profile = Profile.GetProfile(CreateUserWizard1.UserName); profile.Options.AllowFriendRequests = true; profile.Options.DefaultPrivacySetting = "pr"; profile.Options.DefaultFont = "Comic Sans MS"; profile.Options.ShowBirthAge = 1; profile.Personal.Birthday = Convert.ToDateTime(((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("BirthdayTextBox")).Text); profile.Personal.IsMale = Convert.ToBoolean(((RadioButtonList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("IsMaleRBL")).SelectedValue); profile.Save(); Roles.AddUserToRole(CreateUserWizard1.UserName, "User"); //Her skal man så sende en bekræftelsesemail. }
public void BookMarkTopic(int topicid) { var user = HttpContext.Current.User.Identity.Name; ProfileCommon prof = ProfileCommon.GetUserProfile(user); TopicInfo t = Topics.GetTopic(topicid); string url = String.Format("~/Content/Forums/topic.aspx?TOPIC={0}", t.Id); List <SnitzLink> bookmarks = prof.BookMarks; if (!bookmarks.Contains(new SnitzLink(t.Subject, url, 0))) { bookmarks.Add(new SnitzLink(t.Subject, url, bookmarks.Count)); prof.BookMarks = bookmarks; prof.Save(); } }
protected void CreateUserWizard1_CreatedUser(object sender, EventArgs e) { // Get the Profile of the newly created User ProfileCommon p = (ProfileCommon)ProfileCommon.Create(CreateUserWizard1.UserName, true); // User/Password has been created, populate the Profile Fields p.Name = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("NameTextBox")).Text; p.PhoneNumber = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("PhoneTextBox")).Text; p.HomeAddress = ((TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("AddressTextBox")).Text; // Update the Profile p.Save(); // Add the User Role Roles.AddUserToRole(CreateUserWizard1.UserName, "user"); }
private void mUpdateProfile(ProfileCommon userProfile) { userProfile.SetPropertyValue("DateOfBirth", DateTime.UtcNow.AddHours(3.5)); if (!string.IsNullOrEmpty(txtFirstName.Text)) { userProfile.SetPropertyValue("FirstName", txtFirstName.Text); } if (!string.IsNullOrEmpty(txtLastName.Text)) { userProfile.SetPropertyValue("LastName", txtLastName.Text); } if (!string.IsNullOrEmpty(rblGender.SelectedValue)) { userProfile.SetPropertyValue("Gender", Convert.ToBoolean(Convert.ToByte(rblGender.SelectedValue))); } if (!string.IsNullOrEmpty(txtTel.Text)) { userProfile.SetPropertyValue("Tel", txtTel.Text); } if (!string.IsNullOrEmpty(txtMobile.Text)) { userProfile.SetPropertyValue("Mobile", txtMobile.Text); } if (!string.IsNullOrEmpty(txtCity.Text)) { userProfile.SetPropertyValue("City", txtCity.Text); } if (!string.IsNullOrEmpty(txtAddress.Text)) { userProfile.SetPropertyValue("Address", txtAddress.Text); } if (!string.IsNullOrEmpty(txtDescription.Text)) { userProfile.SetPropertyValue("Description", txtDescription.Text); } userProfile.Save(); }
protected void RegisterUser_CreatedUser(object sender, EventArgs e) { if (UserRolesUtility.IsOperatorRoleExists() == false) { Roles.CreateRole(CarServiceConstants.OPERATOR_ROLE_NAME); } Roles.AddUserToRole(RegisterUser.UserName, CarServiceConstants.OPERATOR_ROLE_NAME); ProfileCommon profileCommon = Profile.GetProfile(RegisterUser.UserName); if (profileCommon != null) { TextBox firstName = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("FirstName"); if (firstName != null) { profileCommon.FirstName = firstName.Text; } TextBox lastName = (TextBox)RegisterUserWizardStep.ContentTemplateContainer.FindControl("LastName"); if (lastName != null) { profileCommon.LastName = lastName.Text; } profileCommon.Save(); } DropDownList userActive = (DropDownList)RegisterUserWizardStep.ContentTemplateContainer.FindControl("UserActive"); if (userActive != null) { int selectedValue; if (Int32.TryParse(userActive.SelectedValue, out selectedValue) && selectedValue == 0) { MembershipUser createdUser = Membership.GetUser(RegisterUser.UserName); if (createdUser != null) { createdUser.IsApproved = false; Membership.UpdateUser(createdUser); } } } string continueUrl = RegisterUser.ContinueDestinationPageUrl; if (String.IsNullOrEmpty(continueUrl)) { continueUrl = "~/Admin/Users/Users.aspx"; } Response.Redirect(continueUrl); }
public void BookMarkReply(int replyid, int page) { ReplyInfo r = Replies.GetReply(replyid); TopicInfo rt = Topics.GetTopic(r.TopicId); var user = HttpContext.Current.User.Identity.Name; ProfileCommon prof = ProfileCommon.GetUserProfile(user); string rurl = String.Format("~/Content/Forums/topic.aspx?TOPIC={0}&whichpage={1}&#{2}", r.TopicId, page + 1, r.Id); List <SnitzLink> rbookmarks = prof.BookMarks; if (!rbookmarks.Contains(new SnitzLink(rt.Subject, rurl, 0))) { rbookmarks.Add(new SnitzLink(rt.Subject, rurl, rbookmarks.Count)); prof.BookMarks = rbookmarks; prof.Save(); } }
/// <summary> /// Updates the user and profile. /// </summary> /// <param name="user">The user.</param> public static string UpdateUserAndProfile(UserDetails user) { if (user.IsValid) { MembershipUser membershipUser = Membership.GetUser(user.UserName); membershipUser.Email = user.Email; bool success = true; if (!string.IsNullOrEmpty(user.OldPassword) && !string.IsNullOrEmpty(user.NewPassword)) { success = membershipUser.ChangePassword(user.OldPassword, user.NewPassword); } if (success) { Membership.UpdateUser(membershipUser); //update profile too ProfileCommon p = new ProfileCommon(); ProfileCommon selectedProfile = p.GetProfile(user.UserName); selectedProfile.WarehouseId = user.WarehouseId; selectedProfile.RegionId = user.RegionId; selectedProfile.SalesLocationId = user.SalesLocationId; selectedProfile.OpCoId = user.OpCoId; selectedProfile.OpCoCode = ""; selectedProfile.RegionCode = ""; if (user.OpCoId != -1) { selectedProfile.OpCoCode = OpcoController.GetOpCo(user.OpCoId, false).Code; } if (user.RegionId != -1) { selectedProfile.RegionCode = OptrakRegionController.GetRegion(user.RegionId).Code; } selectedProfile.Save(); return(user.UserName); } else { throw new SystemException("The Password has not be successfully changed."); } } return(""); }
public RegistrationResponse RegisterUser(RegistrationRequest request) { RegistrationResponse response = new RegistrationResponse(); response.success = false; MembershipCreateStatus status; // create user and auto-approve // NOTE: optionally require e-mail account validation // to activate / approve user MembershipUser user = Membership.Provider.CreateUser( request.username, request.pwd, request.email, null, null, true, null, out status); if (status == MembershipCreateStatus.Success) { response.success = true; // validate / login users if (Membership.ValidateUser(request.username, request.pwd)) { // set authentication cookie FormsAuthentication.SetAuthCookie(request.username, request.createCookie); // Create an empty Profile for the newly created user ProfileCommon p = (ProfileCommon)ProfileCommon.Create(request.username, true); // store salt p.Salt = request.salt; p.Save(); try { // send email SendRegistrationMail(request.email, request.username); response.email_sent = true; } catch (Exception e) { response.email_sent = false; } } } response.message = status.ToString(); return(response); }
public void UpdateUser(string userID, string userFullName, string email, string company, string companyID) { MembershipUser user = Membership.GetUser(userID); user.Email = email; Membership.UpdateUser(user); ProfileCommon profile = new ProfileCommon().GetProfile(userID); if (profile.Type.Length == 0) { profile.Type = "client"; } profile.UserFullName = userFullName; profile.Company = company; profile.ClientVendorID = companyID; profile.Save(); }
protected void buttonUpdateUserUser_OnClick(object sender, EventArgs e) { try { ProfileCommon prof = Profile.GetProfile(HttpContext.Current.User.Identity.Name); prof.Name = tbEditNameUser.Text; prof.Title = tbEditTitleUser.Text; prof.Phone = tbEditPhoneUser.Text; prof.Email = tbEditEmailUser.Text; prof.Save(); Utils.displayStatus(ref labelStatusUser, Color.SeaGreen, "Bruker oppdatert"); } catch (Exception ex) { Utils.displayStatus(ref labelStatusUser, Color.Red, ex.Message); } }
protected void OnSendingMail(object sender, MailMessageEventArgs e) { //Event handler for event that occurs before the user is sent a password in e-mail MembershipUser user = Membership.GetUser(this.RecoverUserPassword.UserName); string password = new MembershipServices().GeneratePassword(8); user.ChangePassword(user.GetPassword(), password); //Set flag that forces user to change password on next login ProfileCommon profile = new ProfileCommon().GetProfile(user.UserName); profile.PasswordReset = true; profile.Save(); //Send an email new EmailGateway().SendPasswordResetMessage(user.UserName, user.Email, password); e.Cancel = true; }
public void CheckOrGenerateAdministrator() { string username = "******"; string password = "******"; MembershipUserCollection listOfUserNameByName = Membership.FindUsersByName(username); if (listOfUserNameByName.Count == 0) { MembershipUser m = Membership.CreateUser(username, password); ProfileCommon.Create(username).Save(); ProfileCommon p = ProfileCommon.GetProfile(username); p.RoleID = (int)PermissionType.Administrator; p.IsActive = true; p.Save(); new UserProfileBFC().Create(username, "System"); } }
public static bool approveCompany(string uid) { //Load user name from uid Guid userKey = new Guid(uid); MembershipUser user = Membership.GetUser(userKey); //Load profile from username ProfileCommon pObj = new ProfileCommon().GetProfile(user.UserName); pObj.Status = 2; pObj.Save(); string[] receiver = { user.Email.ToString() }; string body = "Hello " + user.UserName.ToString() + "\n\nYour account has been validated!"; MessageManager.send(receiver, "You account has been validated", body); return true; }
public bool CreateEnrollment(string username, string email, string password, string firstname ,string lastname ,string address ,string city , string zipcode ,string phone ,string cellphone ) { try { //string firstname = "", lastname = "", address = "", city = "", zipcode = "", phone = "", cellphone = ""; MembershipCreateStatus _status; bool bln = Membership.DeleteUser(username); //bln = Roles.DeleteRole(username); string user_name = username; //string email = "*****@*****.**"; //string password = "******"; string question = null; string answer = null; MembershipUser user = Membership.CreateUser ( user_name, password, email, question, answer, true, out _status ); Roles.AddUserToRoles(user.UserName, new string[] { "Member" }); ProfileCommon profile = new ProfileCommon(); profile = profile.GetProfile(user.UserName); //ProfileCommon profile = Profile.GetProfile(user.UserName); profile.FirstName = firstname; profile.LastName = lastname; profile.DateOfBirth = Convert.ToDateTime("1/1/1900"); profile.Sex = System.DBNull.Value.ToString(); profile.ShippingZipCode = zipcode; profile.ShippingAddress1 = address; profile.ShippingCity = city; profile.WorkPhone = phone; profile.Browser = HttpContext.Current.Request.Browser.Browser + " " + HttpContext.Current.Request.Browser.MajorVersion; profile.IPAddress = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"].ToString(); profile.LanguageCode = HttpContext.Current.Request.ServerVariables["HTTP_ACCEPT_LANGUAGE"].ToString(); profile.Timezone = TimeZone.CurrentTimeZone.StandardName.ToString(); profile.Save(); Subscriber subscriberInfo = new Subscriber(); subscriberInfo.FirstName = firstname; subscriberInfo.LastName = lastname; subscriberInfo.Email = email; subscriberInfo.SubscribedStatus = true; subscriberInfo.TotalEmailsSent = 0; Subscriber.ManageSubscription(subscriberInfo); return true; } catch (Exception ex) { return false; } }
protected void Button1_Click(object sender, EventArgs e) { // if (Roles.IsUserInRole(Context.User.Identity.Name, "admin")) { if ( (Membership.FindUsersByName(TextUserName.Text) !=null) && (Membership.FindUsersByName(TextUserName.Text).Count>0) ) { } else { Literal1.Text = "no such user:"******"Detail Information Saved Successfully!"; } else { ProfileCommon p = new ProfileCommon(); p.Initialize(Context.User.Identity.Name, true); p.Address = TextName.Text; p.Phone = TextPhone.Text; p.Name = TextName.Text; //// Save the profile - must be done since we explicitly created this profile instance p.Save(); Literal1.Text = "Detail Information Saved Successfully!"; } }