public int AddOperator( string Email, string AlternateEmail, string FirstName, string LastName, int?GroupId, string UserName, string Password, string SecretQuestion, string SecretAnswer, int?status, string style) { MembersManager mMgr = new MembersManager(); MembersDs.MembersRow member = mMgr.AddMember(UserName, Email, AlternateEmail, Password, SecretAnswer, SecretAnswer, "", FirstName, "", LastName, Gender.Unknown, null, status, 0, "", "", lw.WebTools.WebContext.Profile.UserId, true); if (member == null) { return(-1); } CreateOperatorProfile(member.MemberId, GroupId, style); return(member.MemberId); }
public bool AddFriend(int MemberId, int FriendId, bool notify) { string sql = String.Format("select * from Friends where MemberId={0} and FriendId={1}", MemberId, FriendId); DataTable friends = DBUtils.GetDataSet(sql, cte.lib).Tables[0]; if (friends.Rows.Count > 0) { sql = string.Format("Update Friends set Status={0} where MemberId={1} and FriendId={2}", (int)FriendStatus.Approved, MemberId, FriendId); DBUtils.ExecuteQuery(sql, cte.lib); } else { sql = string.Format("Insert into Friends (MemberId, FriendId, Status, DateAdded) values ({0}, {1}, {2}, getdate())", MemberId, FriendId, (int)FriendStatus.Approved); DBUtils.ExecuteQuery(sql, cte.lib); } sql = String.Format("select * from Friends where MemberId={0} and FriendId={1}", FriendId, MemberId); friends = DBUtils.GetDataSet(sql, cte.lib).Tables[0]; if (friends.Rows.Count == 0) { sql = string.Format("Insert into Friends (MemberId, FriendId, Status, DateAdded) values ({0}, {1}, {2}, getdate())", FriendId, MemberId, (int)FriendStatus.Pending); DBUtils.ExecuteQuery(sql, cte.lib); } MembersDs.MembersRow member = GetMember(MemberId); MembersDs.MembersRow friend = GetMember(FriendId); if (notify) { Config cfg = new Config(); Mail mail = new Mail("friend-request"); mail.Data = new System.Collections.Specialized.NameValueCollection(); mail.Data["MemberId"] = member["Geuid"].ToString(); mail.Data["MemberName"] = member.FirstName + " " + member.LastName; mail.Data["MemberEmail"] = member.Email; mail.Data["Picture"] = (member["Picture"] != System.DBNull.Value ? member["Picture"] : "").ToString(); mail.Data["FriendId"] = friend["Geuid"].ToString(); mail.Data["FriendName"] = friend.FirstName + " " + friend.LastName; mail.Data["FriendEmail"] = friend.Email; mail.Data["FriendPicture"] = (friend["Picture"] != System.DBNull.Value ? friend["Picture"] : "").ToString(); if (!String.IsNullOrWhiteSpace(friend.Email)) { mail.To = friend.Email; } if (!String.IsNullOrWhiteSpace(friend.AlternateEmail)) { mail.To = friend.AlternateEmail; } mail.Subject = member.FirstName + " " + member.LastName + " Added you on " + cfg.GetKey("SiteName"); mail.Send(); } return(true); }
public bool DeclineFriendship(int MemberId, int FriendId, bool notify) { string sql = "Update Friends set Status={0} where MemberId={1} and FriendId={2}; Update Friends set Status={0} where MemberId={2} and FriendId={1}"; sql = string.Format(sql, (int)FriendStatus.Deleted, MemberId, FriendId); DBUtils.ExecuteQuery(sql, cte.lib); MembersDs.MembersRow member = GetMember(MemberId); MembersDs.MembersRow friend = GetMember(FriendId); if (notify) { Config cfg = new Config(); Mail mail = new Mail("friend-declined"); mail.Data = new System.Collections.Specialized.NameValueCollection(); mail.Data["MemberId"] = member["Geuid"].ToString(); mail.Data["MemberName"] = member.FirstName + " " + member.LastName; mail.Data["MemberEmail"] = member.Email; mail.Data["Profile"] = member.UserName; mail.Data["Picture"] = (member["Picture"] != System.DBNull.Value ? member["Picture"] : "").ToString(); mail.Data["FriendId"] = friend["Geuid"].ToString(); mail.Data["FriendName"] = friend.FirstName + " " + friend.LastName; mail.Data["FriendEmail"] = friend.Email; mail.Data["FriendPicture"] = (friend["Picture"] != System.DBNull.Value ? friend["Picture"] : "").ToString(); mail.To = friend.Email; if (!String.IsNullOrWhiteSpace(friend.AlternateEmail)) { mail.ToList.Add(friend.AlternateEmail); } mail.Subject = member.FirstName + " " + member.LastName + " Declined your Request on " + cfg.GetKey("SiteName"); mail.Send(); } return(true); }
public void GenerateUniqueUserName(MembersDs.MembersRow member) { string sql = String.Format("Update Members set UserName='******' where MemberId={1}", StringUtils.ToURL(String.Format("{0}-{1}-{2}", member.FirstName, member.LastName, member.MemberId)), member.MemberId); DBUtils.ExecuteQuery(sql, cte.lib); }
public bool AddFriend(int MemberId, string FriendId, bool notify) { MembersDs.MembersRow member = GetMemberByGuId(FriendId); if (member != null) { return(AddFriend(MemberId, member.MemberId, notify)); } return(false); }
/// <summary> /// Gets a list of the roles that a specified user is in for the configured applicationName. /// </summary> /// <param name="username">The user to return a list of roles for.</param> /// <returns> /// A string array containing the names of all the roles that the specified user is in for the configured applicationName. /// </returns> public override string[] GetRolesForUser(string username) { MembersDs.MembersRow member = null; try { member = manager.GetMember(username); string memberRole = member.Roles.ToString().Replace(" ", string.Empty); string[] allRoles = memberRole.Split(",".ToCharArray()); return(allRoles); } catch (Exception) { return(new string[0]); } }
/// <summary> /// Gets a value indicating whether the specified user is in the specified role for the configured applicationName. /// </summary> /// <param name="username">The user name to search for.</param> /// <param name="roleName">The role to search in.</param> /// <returns> /// true if the specified user is in the specified role for the configured applicationName; otherwise, false. /// </returns> public override bool IsUserInRole(string username, string roleName) { try { MembersDs.MembersRow member = manager.GetMember(username); Roles role; bool isValidRole = Enum.TryParse <Roles>(roleName, out role); if (!isValidRole) { return(false); } bool isMember = (member.Roles.EnsureEnum <Roles>() & role) == role; return(isMember); } catch (Exception) { return(false); } }
public void UpdatePrivacySettings(MembersDs.MembersRow member, int Privacy) { member.Privacy = Privacy; UpdatePrivacySettings(member.MemberId, Privacy); }
public void UpdateMemberPicture(int MemberId, System.Web.HttpPostedFile picture, bool DeleteOldPicture, bool useGUID) { MembersDs.MembersRow member = GetMember(MemberId); UpdateMemberPicture(member, picture, DeleteOldPicture, useGUID); }
/// <summary> /// Updates the member main picture and returns the image as string /// </summary> /// <param name="MemberId">Id of the related member</param> /// <param name="picture"> /// If set to null, the function returns the actual present picture in the DB, if no picture in /// DB the function returns null /// </param> /// <param name="DeleteOldPicture"></param> public string MemberPicture(int MemberId, System.Web.HttpPostedFile picture, bool DeleteOldPicture) { MembersDs.MembersRow member = GetMember(MemberId); try { if (picture != null) { string newPicture = ""; string imagesPath = Path.Combine(WebContext.Server.MapPath("~"), lw.CTE.MembersSettings.MemberPicturesFolder); if (picture != null && picture.ContentLength == 0 && !DeleteOldPicture) { return(null); } if (picture != null && picture.InputStream.Length > 0) { newPicture = string.Format("{0}-{1}-{2}.jpg", StringUtils.ToURL(member.FirstName), StringUtils.ToURL(member.LastName), System.Guid.NewGuid().ToString().Substring(16) ); string path = Path.Combine(imagesPath, member.UserName); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } path = Path.Combine(path, newPicture); picture.SaveAs(path); lw.GraphicUtils.ImageUtils.Resize(path, path, MembersSettings.ProfilePictureWidth, MembersSettings.ProfilePictureHeight); lw.GraphicUtils.ImageUtils.Resize(path, path.Replace(".jpg", "-m.jpg"), MembersSettings.MProfilePictureWidth, MembersSettings.MProfilePictureHeight); lw.GraphicUtils.ImageUtils.CropImage(path, path.Replace(".jpg", "-s.jpg"), MembersSettings.SProfilePictureWidth, MembersSettings.SProfilePictureHeight, GraphicUtils.ImageUtils.AnchorPosition.Default); DeleteOldPicture = true; } if (DeleteOldPicture) { if (member["Picture"] != DBNull.Value && !String.IsNullOrEmpty(member.Picture) && member["Picture"].ToString() != newPicture) { string path = Path.Combine(imagesPath, member.Picture); if (File.Exists(path)) { File.Delete(path); } } member.Picture = newPicture; } string sql = string.Format("Update Members set Picture = '{1}' where MemberId={0}", MemberId, newPicture); DBUtils.ExecuteQuery(sql, cte.lib); return(newPicture); } else { if (!String.IsNullOrWhiteSpace(member.Picture)) { return(member.Picture); } else { return(null); } } } catch (Exception e) { lw.WebTools.ErrorHandler.HandleError(e); } return(null); }
public void UpdateMemberPicture(MembersDs.MembersRow member, System.Web.HttpPostedFile picture, bool DeleteOldPicture) { UpdateMemberPicture(member, picture, DeleteOldPicture, false); }
public int UpdateMember(int MemberId, string userName, string password, string email, string AlternateEmail, string SecretQuestion, string SecretAnswer, string title, string firstName, string middleName, string lastName, Gender?gender, DateTime?dateOfBirth, int?status, int?ChangedBy, bool?JoinNewsletter, string PrivateComments, string Comments, string FullName) { /* or Email='{1}' */ string cond = string.Format("(UserName='******' or Email='{1}') and MemberId<>{2}", StringUtils.SQLEncode(userName), StringUtils.SQLEncode(email), MemberId); if (GetMembers(cond).Rows.Count > 0 && email != "") { ErrorContext.Add("validation", ContentManager.ErrorMsg(Errors.UserAlreadyExists)); return(-1); } MembersDsTableAdapters.MembersTableAdapter adp = new lw.Members.MembersDsTableAdapters.MembersTableAdapter(); MembersDs.MembersRow member = (MembersDs.MembersRow) this.GetMember(MemberId); member.UserName = userName; member.Email = email; if (!string.IsNullOrEmpty(password)) { member.Password = EncryptPassword(password); } if (AlternateEmail != null) { member.AlternateEmail = AlternateEmail; } if (SecretQuestion != null) { member.SecretQuestion = SecretQuestion; } if (SecretAnswer != null) { member.SecretQuestionAnswer = SecretAnswer; } if (title != null) { member.Title = title; } if (firstName != null) { member.FirstName = firstName; } if (lastName != null) { member.LastName = lastName; } if (gender != null) { member.Gender = (short)gender; } if (dateOfBirth != null) { member.DateOfBirth = dateOfBirth.Value; } if (status != null) { member.Status = status.Value; } if (JoinNewsletter != null) { member.JoinNewsletter = JoinNewsletter.Value; } if (ChangedBy != null) { member.ChangedBy = ChangedBy.Value; } if (PrivateComments != null) { member.PrivateComments = PrivateComments; } if (Comments != null) { member.Comments = Comments; } if (middleName != null) { member.MiddleName = middleName; } member.LastModified = DateTime.Now; return(adp.Update(member)); }