public void AddComment(string sessionMemberID, string postID, string commentTxt) { Comments comment = new Comments(); comment.MemberId = sessionMemberID; comment.CommentText = commentTxt; Post post = new Post(); post.PostId = int.Parse(postID); comment.PostId = post.PostId; messageDAL.InsertComment(comment); StringBuilder commentBuilder = new StringBuilder(); //################################### //refreshing Comments //################################### DataTable comments = messageDAL.GetAllComments(post); foreach (DataRow row in comments.Rows) { date = Convert.ToDateTime(row["CreateDate"]).ToString("M"); //Building single message view box commentBuilder.Append("<div id='"); commentBuilder.Append((row["CommentID"]).ToString()); commentBuilder.Append("' class='aComment'><div class='deleteComment floatright'>"); if ((row["MemberID"]).ToString() == sessionMemberID) { commentBuilder.Append("<a class='btnDleteComment ui-icon ui-icon-close tip' title='Delete this comment'></a>"); } else { commentBuilder.Append("<a class='btnOpenMenuComment ui-icon ui-icon-circle-triangle-s tip' title='More options..'></a>"); } commentBuilder.Append("</div><h5><a style='font-weight:normal;' "); commentBuilder.Append("id='" + (row["MemberID"]).ToString() + "'> "); commentBuilder.Append(row["Friend"].ToString()); commentBuilder.Append("</a><span class='DateWithTime ui-corner-all floatright'>"); Reusable_Methods reusable_Methods = new Reusable_Methods(); date = reusable_Methods.FormatDateTime(Convert.ToDateTime(row["CreateDate"])); commentBuilder.Append(date); commentBuilder.Append("</span></h5><p>"); commentBuilder.Append((row["CommentText"]).ToString()); commentBuilder.Append("</p></div>"); //End Building } string commentCount = messageDAL.CountComments(post).ToString(); string commentText = commentBuilder.ToString(); //Updating all Clients Clients.updatingComments(Context.ConnectionId, commentCount, commentText, postID); }
public int CountComments(Post post) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspCountComments", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@PostID", post.PostId)); SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32); returnValue.Direction = ParameterDirection.ReturnValue; cmd.Parameters.Add(returnValue); con.Open(); cmd.ExecuteNonQuery(); int value = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString()); return value; } }
public Article_Post getChatText(ref Post aPost) { Article_Post aArticle = new Article_Post(); using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetChatText", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@PostID", aPost.PostId)); con.Open(); SqlDataReader dbReader = cmd.ExecuteReader(); while (dbReader.Read()) { aPost.CreateDate = DateTime.Parse(dbReader["CreateDate"].ToString()); aArticle.ArticleText = dbReader["ArticleText"].ToString(); } con.Close(); } return aArticle; }
public void DeleteAComment(string sessionMemberID, int postID, int commentID) { NewsfeedDAL dal = new NewsfeedDAL(); Comments aComment = new Comments(commentID); dal.FlagComment(aComment); Post aPost = new Post(postID); string commentCount = messageDAL.CountComments(aPost).ToString(); //Updating all Clients Clients.removeDeletedComment(Context.ConnectionId, commentCount, commentID, postID); }
public List<Member> SearchUntaggedMember(Member aMember, Post aPost) { Member m; List<Member> members = new List<Member>(); using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspSearchFriendsToTag", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PostID", aPost.PostId); cmd.Parameters.AddWithValue("@Search", aMember.DisplayName); cmd.Parameters.AddWithValue("@MemberID", aMember.MemberId); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { m = new Member(Convert.ToString(reader["MemberID"]), Convert.ToString(reader["DisplayName"])); members.Add(m); }//End while reader.Close(); } catch (Exception ex) { ex.ToString(); // MessageBox.Show(ex.Message); } return members; } }
private void OpenWrapper(int i) { #region OPENING WRAPPER aPost = (Post)ArrayPosts[i]; ArrayMembers = bl.GetMemberDisplayName(aPost.MemberId); countMembers = ArrayMembers.Count; for (int a = 0; a < countMembers; ++a) { aMember = (Member)ArrayMembers[a]; NotificationDAL notificationDAL = new NotificationDAL(); Group group = new Group(aPost.GroupId); string groupDescription = notificationDAL.GetGroupDescription2(group); concatinater.Append("<div class='aPost typeOfText' id='"); concatinater.Append(aPost.PostId); concatinater.Append("'><div class='msgeHeading ui-corner-all' ><h2 class='ui-corner-all'> Posted by: <a href='#' id='"); concatinater.Append(aPost.MemberId); concatinater.Append("' class='btnMemberProfile' style='font-weight:normal; '>"); concatinater.Append(aMember.DisplayName); bool isForMember = false; string date = ""; date = reusable_Methods.FormatDateTime(aPost.CreateDate); if (aPost.MemberId == memberID) { isForMember = true; } if (GroupID == aPost.GroupId) { } else { concatinater.Append("</a> <span class='space'></span> in group: <a id='"); concatinater.Append(aPost.GroupId); concatinater.Append("' class='btnGoToGroupPage groupDesc'>"); concatinater.Append(groupDescription); } concatinater.Append("</a>"); if (isForMember) { concatinater.Append("<span class='ui-icon ui-icon-closethick floatright deletePost pointer ' title ='Delete this post' style='display:none;'></span>"); } concatinater.Append("<span class='DateWithTime ui-corner-all floatright'>"); concatinater.Append(date); //concatinater.Append(Convert.ToDateTime(aPost.CreateDate).ToString("D")); concatinater.Append("</span></h2></div> <div class='postContentArea'> <div> "); } #endregion }
public DataTable GetRefreshComments(Post post, Comments comment) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspRefreshComments", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PostID", post.PostId); cmd.Parameters.AddWithValue("@LastCommentID", comment.Commentid); DataTable Comments = new DataTable(); try { con.Open(); da = new SqlDataAdapter(cmd); da.Fill(Comments); } catch (SqlException) { throw new ApplicationException("Error connection to database"); } return Comments; } }
public ArrayList GetTop20VideoPostsForAGroup(int groupID) { ArrayList custArray; using (SqlConnection dbConnection = new SqlConnection(ConnectionString)) { SqlCommand dbCommand = new SqlCommand("uspGetTop20VideoPostsForAGroup", dbConnection); dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.AddWithValue("@GroupID", groupID); dbConnection.Open(); SqlDataReader dbReader = dbCommand.ExecuteReader(); custArray = new ArrayList(); while (dbReader.Read()) { Post aCountry = new Post(int.Parse(dbReader["PostID"].ToString()), DateTime.Parse(dbReader["CreateDate"].ToString()), int.Parse(dbReader["GroupID"].ToString()), dbReader["MemberID"].ToString(), dbReader["PostType"].ToString()); custArray.Add(aCountry); } dbConnection.Close(); } return custArray; }
public string TagNotifications() { string notification = ""; NewsfeedDAL newsFeedDAL = new NewsfeedDAL(); NotificationDAL notificationDAL = new NotificationDAL(); List<Notification> NotificationsList = new List<Notification>(); NotificationsList = notificationDAL.GetTagNotificationsForAMember(aMember); for (int i = 0; i < NotificationsList.Count; ++i) { #region TagRating //memberlist List<Member> MemberList = new List<Member>(); Member aFriend = new Member(NotificationsList[i].MemberId); MemberList = notificationDAL.GetMemberDisplayName(aFriend); string FriendDisplayName = MemberList[0].DisplayName; //memberslist List<Member> PostOwnerMemberList = new List<Member>(); Post aPost = new Post(NotificationsList[i].PostId); PostOwnerMemberList = notificationDAL.GetPostOwner(aPost); List<Post> PostList = new List<Post>(); PostList = notificationDAL.GetPostCreateDate(aPost); string memberLoggedOn = aMember.MemberId; if (memberLoggedOn == PostOwnerMemberList[0].MemberId) { notification += FriendDisplayName + " tagged you on your post which you posted " + FormatDateTime(PostList[0].CreateDate) + " \n\n"; } else if (FriendDisplayName == PostOwnerMemberList[0].DisplayName) { notification += "You were tagged on " + PostOwnerMemberList[0].DisplayName + "'s post by " + FriendDisplayName + " " + FormatDateTime(PostList[0].CreateDate) + "\n\n"; } else { notification += FriendDisplayName + " tagged you on " + PostOwnerMemberList[0].DisplayName + "'s post which was posted " + FormatDateTime(PostList[0].CreateDate) + " \n\n"; } #endregion } return notification; }
public List<Event_Post> GetEventName(Post post) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetEventName", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PostID", post.PostId); List<Event_Post> EventList = new List<Event_Post>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Event_Post aEvent = new Event_Post(reader["EventName"].ToString()); EventList.Add(aEvent); }//End while reader.Close(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message.ToString()); } return EventList; } }
public string CommentRatingNotifications() { string notification = ""; NewsfeedDAL newsFeedDAL = new NewsfeedDAL(); NotificationDAL notificationDAL = new NotificationDAL(); List<Notification> NotificationsList = new List<Notification>(); NotificationsList = notificationDAL.GetCommentRatingNotificationsForAMember(aMember); for (int i = 0; i < NotificationsList.Count; ++i) { #region CommentRating //memberlist List<Member> MemberList = new List<Member>(); Member aFriend = new Member(NotificationsList[i].MemberId); MemberList = notificationDAL.GetMemberDisplayName(aFriend); string FriendDisplayName = MemberList[0].DisplayName; List<Comments> CommentList = new List<Comments>(); Comments aComment = new Comments(NotificationsList[i].CommentId); CommentList = notificationDAL.GetCommentTextAndCreateDate(aComment); //memberslist MemberList = new List<Member>(); Post aPost = new Post(CommentList[0].PostId); MemberList = notificationDAL.GetPostOwner(aPost); string postDisplayText = ""; if (CommentList[0].CommentText.Length > 30) { postDisplayText = CommentList[0].CommentText.Substring(0, 30) + "..."; } else { postDisplayText = CommentList[0].CommentText; } notification += FriendDisplayName + " liked your comment '" + postDisplayText + "' which you posted " + FormatDateTime(CommentList[0].CreateDate) + " on " + MemberList[0].DisplayName + " post\n\n"; #endregion } return notification; }
public string CommentNotifications() { string notification = ""; NewsfeedDAL newsFeedDAL = new NewsfeedDAL(); NotificationDAL notificationDAL = new NotificationDAL(); List<Notification> NotificationsList = new List<Notification>(); NotificationsList = notificationDAL.GetCommentedOnPostNotification(aMember); for (int i = 0; i < NotificationsList.Count; ++i) { #region Comment notification //memberlist List<Member> MemberList = new List<Member>(); Member aFriend = new Member(NotificationsList[i].MemberId); MemberList = notificationDAL.GetMemberDisplayName(aFriend); string FriendDisplayName = MemberList[0].DisplayName; //memberslist MemberList = new List<Member>(); Post aPost = new Post(NotificationsList[i].PostId); MemberList = notificationDAL.GetPostOwner(aPost); List<Post> PostList = new List<Post>(); PostList = notificationDAL.GetPostCreateDate(aPost); List<Post> PostTypeList = new List<Post>(); PostTypeList = notificationDAL.GetPostType(aPost); string postType = ""; if (PostTypeList[0].PostType == "Event") { postType = "event"; } else if (PostTypeList[0].PostType == "Text") { postType = "post"; } else if (PostTypeList[0].PostType == "Photo") { postType = "photo"; } else if (PostTypeList[0].PostType == "Article") { postType = "article"; } else if (PostTypeList[0].PostType == "Video") { postType = "video"; } else if (PostTypeList[0].PostType == "File") { postType = "file post"; } notification += FriendDisplayName + " commented on your " + postType + " which you posted " + FormatDateTime(PostList[0].CreateDate) + " \n\n"; #endregion } return notification; }
public bool InsertTagNotification(Member member, Member friend, Post post) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspInsertTagNotification", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@MemberID", member.MemberId); cmd.Parameters.AddWithValue("@FriendID", friend.MemberId); cmd.Parameters.AddWithValue("@PostID", post.PostId); try { con.Open(); int x = cmd.ExecuteNonQuery(); return true; } catch (Exception e) { MessageBox.Show(e.Message.ToString()); return false; } } }
public List<Post> GetPostType(Post post) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetPostType", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@PostID", post.PostId)); List<Post> PostList = new List<Post>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Post aMember = new Post(reader["PostType"].ToString()); PostList.Add(aMember); }//End while reader.Close(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message.ToString()); } return PostList; } }
public List<Rating> GetPostRatingID(Post post, Member member) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetPostRatingID", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PostID", post.PostId); cmd.Parameters.AddWithValue("@MemberID", member.MemberId); List<Rating> RatingList = new List<Rating>(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Rating rating = new Rating(int.Parse(reader["RatingID"].ToString())); RatingList.Add(rating); }//End while reader.Close(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message.ToString()); } return RatingList; } }
public ArrayList GetPostCaption(Post post) { ArrayList custArray; using (SqlConnection dbConnection = new SqlConnection(ConnectionString)) { SqlCommand dbCommand = new SqlCommand("uspGetPostCaption", dbConnection); dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId)); dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType)); dbConnection.Open(); SqlDataReader dbReader = dbCommand.ExecuteReader(); custArray = new ArrayList(); if (post.PostType == "Event") { while (dbReader.Read()) { Event_Post aCountry = new Event_Post(dbReader["EventName"].ToString()); custArray.Add(aCountry); } } else if (post.PostType == "Text") { while (dbReader.Read()) { Text_Post aCountry = new Text_Post(dbReader["PostText"].ToString()); custArray.Add(aCountry); } } else if (post.PostType == "Photo") { while (dbReader.Read()) { Photo_Post aCountry = new Photo_Post(dbReader["PhotoCaption"].ToString()); custArray.Add(aCountry); } } else if (post.PostType == "Article") { while (dbReader.Read()) { Article_Post aCountry = new Article_Post(dbReader["Title"].ToString()); custArray.Add(aCountry); } } else if (post.PostType == "Video") { while (dbReader.Read()) { Video_Post aCountry = new Video_Post(dbReader["VideoCaption"].ToString()); custArray.Add(aCountry); } } else if (post.PostType == "File") { while (dbReader.Read()) { File_Post aCountry = new File_Post(dbReader["FileCaption"].ToString()); custArray.Add(aCountry); } } dbConnection.Close(); } return custArray; }
public Post GetMostRecentPostDate(Member member) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetMostRecentPostDate", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId)); Post post = new Post(); try { con.Open(); SqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { post.CreateDate = DateTime.Parse(reader["CreateDate"].ToString()); }//End while reader.Close(); } catch (Exception e) { System.Windows.Forms.MessageBox.Show(e.Message.ToString()); } return post; } }
public string EventNotifications() { string notification = ""; NotificationDAL notificationDAL = new NotificationDAL(); List<Notification> NotificationsList = new List<Notification>(); NotificationsList = notificationDAL.GetEventNotificationsForGroupMembers(); for (int i = 0; i < NotificationsList.Count; ++i) { int postId = NotificationsList[i].PostId; Post aPost = new Post(postId); List<Event_Post> EventNameList = new List<Event_Post>(); EventNameList = notificationDAL.GetEventName(aPost); string eventDisplayText = ""; if (EventNameList[0].EventName.Length > 30) { eventDisplayText = EventNameList[0].EventName.Substring(0, 30) + "..."; } else { eventDisplayText = EventNameList[0].EventName; } List<Member> GroupMembersList = new List<Member>(); Group aGroup = new Group(NotificationsList[i].GroupId); GroupMembersList = notificationDAL.GetGroupMembers(aGroup); for (int j = 0; j < GroupMembersList.Count; ++j) { string friendId = aMember.MemberId; //PERSON WHO IS LOGGED IN //CHECK TO SEE IF PE if (friendId == GroupMembersList[j].MemberId) { List<Member> MemberList = new List<Member>(); Member aFriend = new Member(NotificationsList[i].MemberId); MemberList = notificationDAL.GetMemberDisplayName(aFriend); List<Group> GroupList = new List<Group>(); Group Group = new Group(NotificationsList[i].GroupId); GroupList = notificationDAL.GetGroupDescription(Group); notification += MemberList[0].DisplayName + " created the event '" + eventDisplayText + "' in the group '" + GroupList[0].GroupDescription + "'\n\n"; } } } return notification; }
public void DeleteAPost(int postID) { NewsfeedDAL newsfeedDAL = new NewsfeedDAL(); Post aPost = new Post(postID); newsfeedDAL.FlagPost(aPost); //Updating all Clients Clients.removeDeletedPost(Context.ConnectionId, postID); }
public string PostRatingNotifications() { string notification = ""; NewsfeedDAL newsFeedDAL = new NewsfeedDAL(); NotificationDAL notificationDAL = new NotificationDAL(); List<Notification> NotificationsList = new List<Notification>(); NotificationsList = notificationDAL.GetPostRatingNotificationsForAMember(aMember); ArrayList ArrayPosts; for (int i = 0; i < NotificationsList.Count; ++i) { #region PostRating List<Member> MemberList = new List<Member>(); Member aFriend = new Member(NotificationsList[i].MemberId); MemberList = notificationDAL.GetMemberDisplayName(aFriend); List<Post> PostList = new List<Post>(); Post aPost = new Post(NotificationsList[i].PostId); PostList = notificationDAL.GetPostType(aPost); if (PostList[0].PostType == "Event") { aPost = new Post(NotificationsList[i].PostId, PostList[0].PostType); ArrayPosts = notificationDAL.GetPostCaption(aPost); Event_Post aEvent_Post; aEvent_Post = (Event_Post)ArrayPosts[i]; PostList = new List<Post>(); aPost = new Post(NotificationsList[i].PostId); PostList = new List<Post>(); PostList = notificationDAL.GetPostCreateDate(aPost); string postDisplayText = ""; if (aEvent_Post.EventName.Length > 30) { postDisplayText = aEvent_Post.EventName.Substring(0, 30) + "..."; } else { postDisplayText = aEvent_Post.EventName; } notification += MemberList[0].DisplayName + " liked your event '" + postDisplayText + "' which you posted " + FormatDateTime(PostList[0].CreateDate) + "\n\n"; } else if (PostList[0].PostType == "Text") { aPost = new Post(NotificationsList[i].PostId, PostList[0].PostType); ArrayPosts = notificationDAL.GetPostCaption(aPost); Text_Post aText_Post; aText_Post = (Text_Post)ArrayPosts[0]; PostList = new List<Post>(); aPost = new Post(NotificationsList[i].PostId); PostList = new List<Post>(); PostList = notificationDAL.GetPostCreateDate(aPost); string postDisplayText = ""; if (aText_Post.PostText.Length > 30) { postDisplayText = aText_Post.PostText.Substring(0, 30) + "..."; } else { postDisplayText = aText_Post.PostText; } notification += MemberList[0].DisplayName + " liked your post '" + postDisplayText + "' which you posted " + FormatDateTime(PostList[0].CreateDate) + "\n\n"; } else if (PostList[0].PostType == "Photo") { aPost = new Post(NotificationsList[i].PostId, PostList[0].PostType); ArrayPosts = notificationDAL.GetPostCaption(aPost); Photo_Post aPhoto_Post; aPhoto_Post = (Photo_Post)ArrayPosts[0]; PostList = new List<Post>(); aPost = new Post(NotificationsList[i].PostId); PostList = new List<Post>(); PostList = notificationDAL.GetPostCreateDate(aPost); string postDisplayText = ""; if (aPhoto_Post.PhotoCaption.Length > 30) { postDisplayText = aPhoto_Post.PhotoCaption.Substring(0, 30) + "..."; } else { postDisplayText = aPhoto_Post.PhotoCaption; } notification += MemberList[0].DisplayName + " liked your photo '" + postDisplayText + "' which you posted " + FormatDateTime(PostList[0].CreateDate) + "\n\n"; } else if (PostList[0].PostType == "Article") { aPost = new Post(NotificationsList[i].PostId, PostList[0].PostType); ArrayPosts = notificationDAL.GetPostCaption(aPost); Article_Post aArticle_Post; aArticle_Post = (Article_Post)ArrayPosts[0]; PostList = new List<Post>(); aPost = new Post(NotificationsList[i].PostId); PostList = new List<Post>(); PostList = notificationDAL.GetPostCreateDate(aPost); string postDisplayText = ""; if (aArticle_Post.Title.Length > 30) { postDisplayText = aArticle_Post.Title.Substring(0, 30) + "..."; } else { postDisplayText = aArticle_Post.Title; } notification += MemberList[0].DisplayName + " liked your article '" + postDisplayText + "' which you posted " + FormatDateTime(PostList[0].CreateDate) + "\n\n"; } else if (PostList[0].PostType == "Video") { aPost = new Post(NotificationsList[i].PostId, PostList[0].PostType); ArrayPosts = notificationDAL.GetPostCaption(aPost); Video_Post aVideo_Post; aVideo_Post = (Video_Post)ArrayPosts[0]; PostList = new List<Post>(); aPost = new Post(NotificationsList[i].PostId); PostList = new List<Post>(); PostList = notificationDAL.GetPostCreateDate(aPost); string postDisplayText = ""; if (aVideo_Post.VideoCaption.Length > 30) { postDisplayText = aVideo_Post.VideoCaption.Substring(0, 30) + "..."; } else { postDisplayText = aVideo_Post.VideoCaption; } notification += MemberList[0].DisplayName + " liked your video '" + postDisplayText + "' which you posted " + FormatDateTime(PostList[0].CreateDate) + "\n\n"; } else if (PostList[0].PostType == "File") { aPost = new Post(NotificationsList[i].PostId, PostList[0].PostType); ArrayPosts = notificationDAL.GetPostCaption(aPost); File_Post aFile_Post; aFile_Post = (File_Post)ArrayPosts[0]; PostList = new List<Post>(); aPost = new Post(NotificationsList[i].PostId); PostList = new List<Post>(); PostList = notificationDAL.GetPostCreateDate(aPost); string postDisplayText = ""; if (aFile_Post.FileCaption.Length > 30) { postDisplayText = aFile_Post.FileCaption.Substring(0, 30) + "..."; } else { postDisplayText = aFile_Post.FileCaption; } notification += MemberList[0].DisplayName + " liked your file post '" + postDisplayText + "' which you posted " + FormatDateTime(PostList[0].CreateDate) + "\n\n"; } #endregion } return notification; }
public void InsertChatText(string sessionMemberID, int groupID, string ChatText) { //Article_Post article_Post = new Article_Post(ChatText); Group group = new Group(groupID); Member thisMember = new Member(sessionMemberID); int postID = chatDAL.InsertChatText(group, ChatText, thisMember); Post post = new Post(postID); Article_Post thisArticle = chatDAL.getChatText(ref post); //BulabulaApp.Other_Classes. date new = reusable_Methods.FormatDateTime(aPost.CreateDate); Reusable_Methods reusable_Methods = new Reusable_Methods(); string date = reusable_Methods.FormatDateTimeForChat(post.CreateDate); thisMember = chatDAL.GetMemberDisplayName(thisMember); concatinater.Append(" <div class='chatMemberWrapper'>"); concatinater.Append("<div class='memberNameSection '> <a id="); concatinater.Append(thisMember.MemberId); concatinater.Append(" class='btnMemberProfile pointer' ><em>"); concatinater.Append(thisMember.DisplayName); concatinater.Append("</em></a></div>"); concatinater.Append("</a></div>"); concatinater.Append("<div class='chatContentSection '>"); concatinater.Append(thisArticle.ArticleText); concatinater.Append("</div> <div class='clr'></div>"); concatinater.Append(" </div>"); string chatString = concatinater.ToString(); Clients.updateChat(Context.ConnectionId, chatString, groupID.ToString(), sessionMemberID); }
public bool FlagPost(Post post) { using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspDeletePost", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@PostID", post.PostId); try { con.Open(); int x = cmd.ExecuteNonQuery(); return true; } catch (Exception e) { e.ToString(); return false; } } }
public void LikeAPost( string sessionMemberID, int postID) { NotificationDAL notificationDAL = new NotificationDAL(); RateAndTagDAL dal = new RateAndTagDAL(); Post aPost = new Post(postID); List<Member> MemberList = new List<Member>(); MemberList = notificationDAL.GetPostOwner(aPost); Member aFriend = new Member(MemberList[0].MemberId); string memberId = sessionMemberID; Member aMember = new Member(memberId); //Check if like exists if (dal.PostRatingExists(aMember, aPost) == 0) { dal.RatePost(aMember, aPost); List<Rating> RatingList = new List<Rating>(); RatingList = notificationDAL.GetPostRatingID(aPost, aMember); Rating aRating = new Rating(RatingList[0].RatingId); if (RatingList.Count > 0) { notificationDAL.InsertPostRatingNotification(aRating, aMember, aFriend, aPost); } } else { //MessageBox.Show("already rated by u"); } aPost.PostId = postID; int numberofPostLikes = newsFeedDAL.CountPostLikes(aPost); //Updating all Clients Clients.updatePostLikeCount(numberofPostLikes, postID); }
public ArrayList GetPost(Post post) { ArrayList custArray; using (SqlConnection dbConnection = new SqlConnection(ConnectionString)) { SqlCommand dbCommand = new SqlCommand("uspGetPost", dbConnection); dbCommand.CommandType = CommandType.StoredProcedure; dbCommand.Parameters.Add(new SqlParameter("@PostID", post.PostId)); dbCommand.Parameters.Add(new SqlParameter("@PostType", post.PostType)); dbConnection.Open(); SqlDataReader dbReader = dbCommand.ExecuteReader(); custArray = new ArrayList(); if (post.PostType == "Event") { while (dbReader.Read()) { Event_Post aCountry = new Event_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["EventName"].ToString(), dbReader["EventDetails"].ToString(), dbReader["EventVenue"].ToString(), DateTime.Parse(dbReader["StartDate"].ToString()), DateTime.Parse(dbReader["EndDate"].ToString()), dbReader["Host"].ToString(), dbReader["EventType"].ToString()); custArray.Add(aCountry); } } else if (post.PostType == "Text") { while (dbReader.Read()) { Text_Post aCountry = new Text_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PostText"].ToString()); custArray.Add(aCountry); } } else if (post.PostType == "Photo") { while (dbReader.Read()) { Photo_Post aCountry = new Photo_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["PhotoCaption"].ToString(), dbReader["PhotoName"].ToString()); custArray.Add(aCountry); } } //else if (post.PostType == "Article") //{ // while (dbReader.Read()) // { // Article_Post aCountry = new Article_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["Title"].ToString(), dbReader["ArticleText"].ToString()); // custArray.Add(aCountry); // } //} else if (post.PostType == "Video") { while (dbReader.Read()) { Video_Post aCountry = new Video_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["VideoCaption"].ToString(), long.Parse(dbReader["VideoSize"].ToString()), dbReader["VideoName"].ToString()); custArray.Add(aCountry); } } else if (post.PostType == "File") { while (dbReader.Read()) { File_Post aCountry = new File_Post(int.Parse(dbReader["PostID"].ToString()), dbReader["FileCaption"].ToString(), long.Parse(dbReader["FileSize"].ToString()), dbReader["FileName"].ToString()); custArray.Add(aCountry); } } dbConnection.Close(); } return custArray; }
public void TagAPost(string sessionMemberID, int postID, string friendID) { NotificationDAL notificationDAL = new NotificationDAL(); //Tag method here Member m; Post p; bool isTagged = tagDAL.TagFriend(p = new Post(postID), m = new Member(friendID)); // INSERT NOTIFICATION string friendId = friendID; Member aFriend = new Member(friendId); string memberId = sessionMemberID; Member aMember = new Member(memberId); aPost.PostId = postID; notificationDAL.InsertTagNotification(aMember, aFriend, aPost); //return number of tags int numberoftags = newsFeedDAL.CountPostTags(aPost); Clients.updateTagCount(numberoftags, postID); }
public ArrayList GetTop20VideoPosts() { ArrayList custArray; using (SqlConnection dbConnection = new SqlConnection(ConnectionString)) { SqlCommand dbCommand = new SqlCommand("uspGetTop20VideoPosts", dbConnection); dbConnection.Open(); SqlDataReader dbReader = dbCommand.ExecuteReader(); custArray = new ArrayList(); while (dbReader.Read()) { Post aCountry = new Post(int.Parse(dbReader["PostID"].ToString()), DateTime.Parse(dbReader["CreateDate"].ToString()), int.Parse(dbReader["GroupID"].ToString()), dbReader["MemberID"].ToString(), dbReader["PostType"].ToString()); custArray.Add(aCountry); } dbConnection.Close(); } return custArray; }
public void UntagAPost(string sessionMemberID, int postID, string friendID) { Member m; Post p; bool isTagged = tagDAL.DeleteTag(p = new Post(postID), m = new Member(friendID)); aPost.PostId = postID; //returns number of tags int numberoftags = newsFeedDAL.CountPostTags(aPost); //Updating all Clients Clients.updateTagCount(numberoftags, postID); }
public ArrayList GetTop2Comments(Post post) { ArrayList custArray; using (SqlConnection con = new SqlConnection(ConnectionString)) { SqlCommand cmd = new SqlCommand("uspGetTop2Comments", con); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@PostID", post.PostId)); con.Open(); SqlDataReader dbReader = cmd.ExecuteReader(); custArray = new ArrayList(); while (dbReader.Read()) { Comments aCountry = new Comments(int.Parse(dbReader["CommentID"].ToString()), dbReader["CommentText"].ToString(), DateTime.Parse(dbReader["CreateDate"].ToString()), int.Parse(dbReader["PostID"].ToString()), dbReader["MemberID"].ToString()); custArray.Add(aCountry); } con.Close(); } return custArray; }
private void GenerateProfile(Member aMember) { #region RIGHT COLUMN GET ALL JOINED GROUPS //JOINED GROUPS============================================================================== Reusable_Methods reusable_Methods = new Reusable_Methods(aMember); allgroups = reusable_Methods.RightColumnGetAllJoinedGroups(); //============================================================================================ #endregion #region RIGHT COLUMN MEMBER INFORMATION //MEMBER INFORMATION ON RIGHT COLUMN========================================================================== //MEMBER INFO AND PROFILE MemberInfoDAL dal = new MemberInfoDAL(); // Member member = new Member(); aMember = dal.GetAllMemberInfo(aMember); profilesMemnerID.Value = aMember.MemberId; //Set the ImageUrl to the path of the handler with the querystring value ProfileImage.ImageUrl = "ProfilePicHandler.ashx?id=" + SSTCryptographer.Decrypt(aMember.MemberId); //call the method to get the image information and display it in Label Control //======================================================================================================= #endregion #region MAIN COLUMN MEMBER INFORMATION //MEMBER INFORMATION ON MAIN DISPLAY========================================================================== StringBuilder memberData = new StringBuilder(); memberData.Append("<tr><td style='font-weight: bold;' > "); memberData.Append("First Name:</td><td>"); memberData.Append(aMember.FirstName); memberData.Append("</td></tr> <tr><td style='font-weight: bold;'>"); memberData.Append("Last Name:</td><td>"); memberData.Append(aMember.LastName); memberData.Append("</td></tr> <tr><td style='font-weight: bold;' > "); memberData.Append("Display Name:</td><td>"); memberData.Append(aMember.DisplayName); memberData.Append("</td></tr> <tr><td style='font-weight: bold;' > "); memberData.Append("Email:</td><td>"); memberData.Append(aMember.Email); memberData.Append("</td></tr> <tr><td style='font-weight: bold;' > "); memberData.Append("Description:</td><td>"); memberData.Append(aMember.Description); memberData.Append("</td></tr> <tr><td style='font-weight: bold;' > "); memberData.Append("Campus:</td><td>"); memberData.Append(aMember.Campus); memberData.Append("</td></tr> <tr><td style='font-weight: bold;' > "); memberData.Append("Account Type:</td><td>"); memberData.Append(aMember.MemberType); memberData.Append("</td></tr> <tr><td style='font-weight: bold;' > "); if (aMember.IsOnline == false) { memberData.Append("Online Status:</td><td style='color:red;'>"); memberData.Append("Offline"); memberData.Append("</td></tr>"); } else { memberData.Append("Online Status:</td><td style='color:green;'>"); memberData.Append("Online"); memberData.Append("</td></tr>"); } memberDataMain = memberData.ToString(); #endregion #region MAIN COLUMN MOST RECENT POST DATE //MOST RECENT POST DATE ON MAIN DISPLAY========================================================================== NotificationDAL notificationDAL = new NotificationDAL(); StringBuilder recentPostDate = new StringBuilder(); Post aPost = new Post(); aPost = notificationDAL.GetMostRecentPostDate(aMember); if (aPost.CreateDate == DateTime.Parse("1/1/0001 12:00:00 AM")) { reusable_Methods = new Reusable_Methods(); string date = reusable_Methods.FormatDateTime(aPost.CreateDate); recentPostDate.Append("<p style='font-size: 1.2em; color: #A3ADB5;'>Most recent post date<span style='color: #0e93be;'> - "); recentPostDate.Append("No posts"); recentPostDate.Append("</span></p>"); mostRecentPostDate = recentPostDate.ToString(); } else { reusable_Methods = new Reusable_Methods(); string date = reusable_Methods.FormatDateTime(aPost.CreateDate); recentPostDate.Append("<p style='font-size: 1.2em; color: #A3ADB5;'>Most recent post date<span style='color: #0e93be;'> - "); recentPostDate.Append(date); recentPostDate.Append("</span></p>"); mostRecentPostDate = recentPostDate.ToString(); } #endregion #region MAIN ACTUAL DISPLAY NAME MemberInfoDAL memberInfoDAL = new MemberInfoDAL(); Member actualMember = new Member(Context.Session["memberID"].ToString()); aMember = memberInfoDAL.GetActualDisplayName(actualMember); actualMemberDisplayName = aMember.DisplayName; #endregion }