Ejemplo n.º 1
0
        public bool UnblockAccount(Administrator administrator, Member member, string reasonUnblocked)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspUnblockAccount", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@AdministratorID", administrator.AdministratorId);
                cmd.Parameters.AddWithValue("@MemberID", member.MemberId);
                cmd.Parameters.AddWithValue("@ReasonUnblocked", reasonUnblocked);

                try
                {
                    con.Open();
                    int x = cmd.ExecuteNonQuery();
                    return true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message.ToString());
                    return false;
                }
            }
        }
Ejemplo n.º 2
0
        public bool AddMessage(Messages message, Member member, Member friend)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                int x = 0;
                SqlCommand cmd = new SqlCommand("AddMessage", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@MemberID", member.MemberId);
                cmd.Parameters.AddWithValue("@FriendID", friend.MemberId);
                cmd.Parameters.AddWithValue("@MessageText", message.MessageText);

                try
                {
                    con.Open();

                     x = cmd.ExecuteNonQuery();

                }
                catch (Exception e)
                {
                    e.ToString();
                }

                if (x < 0)
                { return true; }
                else { return false; }

            }
        }
Ejemplo n.º 3
0
        public Member GetActualDisplayName(Member member)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetActualDisplayName", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {
                        member.DisplayName = reader["DisplayName"].ToString();

                    }//End while
                    reader.Close();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message.ToString());
                }
                return member;
            }
        }
Ejemplo n.º 4
0
        public List<Notification> GetCommentedOnPostNotification(Member member)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetCommentedOnPostNotification", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@MemberID", member.MemberId);

                List<Notification> NotificationsList = new List<Notification>();

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {

                        Notification aNotification = new Notification(int.Parse(reader["NotificationID"].ToString()), reader["MemberID"].ToString(), int.Parse(reader["PostID"].ToString()), reader["NotificationType"].ToString());
                        NotificationsList.Add(aNotification);
                    }//End while
                    reader.Close();
                }
                catch (Exception e)
                {
                    System.Windows.Forms.MessageBox.Show(e.Message.ToString());
                }
                return NotificationsList;
            }
        }
Ejemplo n.º 5
0
        public void ProcessRequest(HttpContext Context)
        {
            if (Context.Session["profileFriendID"] != null)
            {

                string memberId = Context.Request.QueryString["id"]; //get the querystring value that was pass on the ImageURL (see GridView MarkUp in Page1.aspx)
                memberId = SSTCryptographer.Encrypt(memberId);

                Member aMember = new Member(memberId);

                if (memberId != null)
                {
                    MemberInfoDAL dal = new MemberInfoDAL();
                    aMember = dal.GetAllMemberInfo(aMember);

                    MemoryStream ms = new MemoryStream();
                    aMember.ProfilePicture.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                    byte[] file = ms.ToArray();
                    ms.Write(file, 0, file.Length);
                    Context.Response.Buffer = true;
                    Context.Response.BinaryWrite(file);
                    ms.Dispose();
                }
                Context.Session["profileFriendID"] = Context.Session["memberID"].ToString();

            }
            else
            {
                string memberId = Context.Request.QueryString["id"]; //get the querystring value that was pass on the ImageURL (see GridView MarkUp in Page1.aspx)
                memberId = SSTCryptographer.Encrypt(memberId);

                Member aMember = new Member(memberId);

                if (memberId != null)
                {
                    MemberInfoDAL dal = new MemberInfoDAL();
                    aMember = dal.GetAllMemberInfo(aMember);

                    MemoryStream ms = new MemoryStream();
                    aMember.ProfilePicture.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                    byte[] file = ms.ToArray();
                    ms.Write(file, 0, file.Length);
                    Context.Response.Buffer = true;
                    Context.Response.BinaryWrite(file);
                    ms.Dispose();
                }

            }
        }
Ejemplo n.º 6
0
        public Member GetAllMemberInfo(Member member)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspGetAllMemberInfo", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@MemberID", member.MemberId);

               // List<Member> memberList = new List<Member>();

                try
                {
                    con.Open();
                    SqlDataReader reader = cmd.ExecuteReader();
                    while (reader.Read())
                    {

                        byte[] imageBytes = reader["ProfilePicture"] as byte[];
                        MemoryStream ms = new MemoryStream(imageBytes, 0, imageBytes.Length);
                        // Convert byte[] to Image
                        ms.Write(imageBytes, 0, imageBytes.Length);
                        Image image = Image.FromStream(ms, true);

                                member.FirstName = Convert.ToString(reader["FirstName"]);
                                member.LastName = Convert.ToString(reader["LastName"]);
                                member.DisplayName = Convert.ToString(reader["DisplayName"]);
                                member.Email =  Convert.ToString(reader["Email"]);
                                member.RegistrationDate = Convert.ToDateTime(reader["RegistrationDate"]);
                                member.Description = Convert.ToString(reader["Description"]);
                                member.Campus =  Convert.ToString(reader["Campus"]);
                                member.MemberType = Convert.ToString(reader["MemberType"]);
                                member.IsOnline = Convert.ToBoolean(reader["isOnline"]);
                                member.ProfilePicture = image;

                        //memberList.Add(memberInfo);
                    }//End while
                    reader.Close();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message.ToString());
                }
                return member;
            }
        }
Ejemplo n.º 7
0
        public bool BlockMember(Member member, Member friend)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspBlockMember", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@MemberID", member.MemberId);
                cmd.Parameters.AddWithValue("@FriendID", friend.MemberId);

                try
                {
                    con.Open();
                    int x = cmd.ExecuteNonQuery();
                    return true;
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message.ToString());
                    return false;
                }
            }
        }
Ejemplo n.º 8
0
        public int InsertChatText(Group group, string ChatText, Member member)
        {
            using (SqlConnection dbcon = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspInsertChatText", dbcon);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@ChatText", ChatText));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    dbcon.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return postId;

            }
        }
Ejemplo n.º 9
0
        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
        }
Ejemplo n.º 10
0
        public ArrayList GetMemberDisplayName(string MemberId)
        {
            ArrayList custArray;
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspGetMemberDisplayName", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@MemberID", MemberId));

                con.Open();
                SqlDataReader dbReader = cmd.ExecuteReader();
                custArray = new ArrayList();

                while (dbReader.Read())
                {
                    Member aCountry = new Member(dbReader["DisplayName"].ToString(), 0);
                    custArray.Add(aCountry);
                }
                con.Close();
            }
            return custArray;
        }
Ejemplo n.º 11
0
        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;
        }
Ejemplo n.º 12
0
        public string FriendRequestSentNotifications()
        {
            string notification = "";

            NewsfeedDAL newsFeedDAL = new NewsfeedDAL();

            NotificationDAL notificationDAL = new NotificationDAL();

            List<Notification> NotificationsList = new List<Notification>();
            NotificationsList = notificationDAL.GetFriendRequestSentNotificationsForAMember(aMember);

            for (int i = 0; i < NotificationsList.Count; ++i)
            {
                #region FriendRequestSent
                //memberlist
                List<Member> MemberList = new List<Member>();
                Member aFriend = new Member(NotificationsList[i].MemberId);
                MemberList = notificationDAL.GetMemberDisplayName(aFriend);

                string FriendDisplayName = MemberList[0].DisplayName;

                notification += FriendDisplayName + " sent you a friend request\n\n";
                #endregion
            }
            return notification;
        }
Ejemplo n.º 13
0
        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;
        }
Ejemplo n.º 14
0
        public void AddEventPost(string sessionMemberID, string startDate, string endDate, string name, string host, string venue, int groupID, string details, string type)
        {
            memberID = sessionMemberID;
            StringBuilder htmlText = new StringBuilder();
            Member aMember = new Member(memberID);

            Group aGroup = new Group(groupID);

            PostDAL postDAL = new PostDAL();

            Reusable_Methods reusable_Methods = new Reusable_Methods();

             /*
              * NEEDS ATTENTION !!!!!!!!!
              *
              *
              */

            DateTime startDateD = reusable_Methods.CreateDateTime(startDate);
            DateTime endDateD = reusable_Methods.CreateDateTime(endDate);

              /*
            * END NEEDS ATTENTION !!!!!!!!!
            */

            //DateTime startDateD = reusable_Methods.FormatDateFromDateTimePicker(startDate);
              //  DateTime endDateD = reusable_Methods.FormatDateFromDateTimePicker(endDate);

            Event_Post aEvent_Post = new Event_Post(name, details, venue, startDateD, endDateD, host, type);
            int postId = postDAL.InsertEvent(aEvent_Post, aGroup, aMember);

            #region GET POST
            ArrayPosts = bl.GetASinglePost(postId);
            int count = ArrayPosts.Count;

            for (int i = 0; i < count; ++i)
            {

                OpenWrapper(i);

                #region EVENT POST
                GetEventPosts();
                #endregion

                CloseWrapper();

            }

            #endregion

             string postToClients = concatinater.ToString();

            //Updating all Clients
            Clients.insertEvent(Context.ConnectionId, postToClients, groupID);
        }
Ejemplo n.º 15
0
        public int InsertPhoto(Photo_Post photo_Post, Group group, Member member)
        {
            using (SqlConnection connection = new SqlConnection(ConnectionString))
            {
                MemoryStream ms = new MemoryStream();
                photo_Post.Photo.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);

                SqlCommand cmd = new SqlCommand("uspInsertPhoto", connection);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@Photo", ms.ToArray()));
                cmd.Parameters.Add(new SqlParameter("@PhotoName", photo_Post.PhotoName));
                cmd.Parameters.Add(new SqlParameter("@PhotoCaption", photo_Post.PhotoCaption));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    connection.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return postId;

            }
        }
Ejemplo n.º 16
0
        public int InsertEvent(Event_Post events, Group group, Member member)
        {
            using (SqlConnection dbcon = new SqlConnection(ConnectionString))
            {
                SqlCommand cmd = new SqlCommand("uspInsertEvent", dbcon);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.Add(new SqlParameter("@GroupID", group.GroupId));
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));
                cmd.Parameters.Add(new SqlParameter("@EventName", events.EventName));
                cmd.Parameters.Add(new SqlParameter("@EventDetails", events.EventDetails));
                cmd.Parameters.Add(new SqlParameter("@EventVenue", events.EventVenue));
                cmd.Parameters.Add(new SqlParameter("@StartDate", events.StartDate));
                cmd.Parameters.Add(new SqlParameter("@EndDate", events.EndDate));
                cmd.Parameters.Add(new SqlParameter("@Host", events.Host));
                cmd.Parameters.Add(new SqlParameter("@EventType", events.EventType));

                SqlParameter returnValue = new SqlParameter("@Return_Value", DbType.Int32);
                returnValue.Direction = ParameterDirection.ReturnValue;

                cmd.Parameters.Add(returnValue);
                int postId = 0;
                try
                {
                    dbcon.Open();
                    cmd.ExecuteNonQuery();
                    postId = Int32.Parse(cmd.Parameters["@Return_Value"].Value.ToString());
                }
                catch (SqlException e)
                {
                    MessageBox.Show(e.ToString());
                }
                return postId;
            }
        }
Ejemplo n.º 17
0
        public bool InsertPostRatingNotification(Rating rating, Member member, Member friend, Post post)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspInsertPostRatingNotification", con);
                cmd.CommandType = CommandType.StoredProcedure;

                cmd.Parameters.AddWithValue("@RatingID", rating.RatingId);
                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;
                }
            }
        }
Ejemplo n.º 18
0
        protected void LoginButton_Click(object sender, EventArgs e)
        {
            Member_Status member_Status;
            dal = new LoginDAL();

            string username = LoginUser.UserName;
            string password = LoginUser.Password;

            //Validate the Credentials against the active directory
            userInformation = new ActiveDirectoryDAL(username, password);

            username = SSTCryptographer.Encrypt(username);

            bool isValid = userInformation.ValidateCredentials();
            if (!isValid) //Invalid Credentials
            {
                failureText = "Incorrect username or password.";
                ErrorInfo.Visible = true;
            }
            else if (dal.GetMemberStatus(member_Status = new Member_Status(username)))
            {
                failureText = "Your account has been suspended.";
                ErrorInfo.Visible = true;
            }
            else //Valid Credentials
            {
                userInformation.GetUserInformation();

                if (IsSchoolOfICTMember())
                {
                    //treat the case where we set the remember me check box
                    if (LoginUser.RememberMeSet)
                    {
                        RememberMe(username, password);
                    }

                    dal = new LoginDAL();

                    //save data into db if first time login
                    Member member;
                    if (!dal.MemberExists(member = new Member(username)))
                    {
                        //add member to database
                        member = new Member(username, userInformation.GetFirstName(), userInformation.GetLastName(), userInformation.GetDisplayName(), userInformation.GetEmail(), userInformation.GetThumbnailPhoto(), userInformation.GetDescription(), userInformation.GetCompany(), ValidateMemberType());
                        dal.InsertMember(member);

                        //assign member to groups
                       AssignMemberToGroups(username);
                    }

                    Session["memberID"] = username;
                   // Server.Transfer("~/Home.aspx");
                Response.Redirect("~/Home.aspx"); //Redirect to home page if the user is a memeber of the faculty of ICT
                }
                else
                {
                    //Display error message if the user is not a memeber of the faculty of ICT
                    failureText = "Sorry. You need to be a registered school of ICT member in order to gain access to this site";
                    ErrorInfo.Visible = true;
                }
            }
        }
Ejemplo n.º 19
0
        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);
        }
Ejemplo n.º 20
0
        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;
        }
Ejemplo n.º 21
0
 public Reusable_Methods(Member aMember)
 {
     this.aMember = aMember;
 }
Ejemplo n.º 22
0
        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);
        }
Ejemplo n.º 23
0
        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;
        }
Ejemplo n.º 24
0
        public void MoveShape(string postText, string sessionMemberID, int groupID)
        {
            memberID = sessionMemberID;
            StringBuilder htmlText = new StringBuilder();
            Member aMember = new Member(memberID);
            htmlText.Append(postText);

            //htmlText.Replace("cat", "dog",);
            //htmlText.S
            //string[] parts = postText.Split('');
            Text_Post aText_Post = new Text_Post(postText);
            Group aGroup = new Group();
            aGroup.GroupId = groupID;

            int postId = postDAL.InsertText(aGroup, aText_Post, aMember);

            #region GET POST
            ArrayPosts = bl.GetASinglePost(postId);
            int count = ArrayPosts.Count;

            for (int i = 0; i < count; ++i)
            {

                OpenWrapper(i);

                #region TEXT POST
                GetTextPosts();
                #endregion

                CloseWrapper();

            }
            string postToClients = concatinater.ToString();

            #endregion

            //Updating all Clients
            Clients.shapeMoved(Context.ConnectionId, postToClients, groupID);
        }
Ejemplo n.º 25
0
        public string MessageNotifications()
        {
            string notification = "";

            NotificationDAL notificationDAL = new NotificationDAL();

            List<Notification> NotificationsList = new List<Notification>();
            NotificationsList = notificationDAL.GetMessageNotificationForAMember(aMember);

            for (int i = 0; i < NotificationsList.Count; ++i)
            {
                List<Member> MemberList = new List<Member>();
                Member aFriend = new Member(NotificationsList[i].MemberId);
                MemberList = notificationDAL.GetMemberDisplayName(aFriend);

                Message aMessage = new Message(NotificationsList[i].MessageId);

                aMessage = notificationDAL.GetMessageDateTime(aMessage);

                notification += MemberList[0].DisplayName + " sent you a message at " + FormatDateTime(aMessage.DateTime) + "\n\n";
            }
            return notification;
        }
Ejemplo n.º 26
0
        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);
        }
Ejemplo n.º 27
0
        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;
        }
Ejemplo n.º 28
0
        public void UnlikeAPost(string sessionMemberID, int postID)
        {
            RateAndTagDAL dal = new RateAndTagDAL();

             string memberId = sessionMemberID;
             Member aMember = new Member(memberId);
             aPost.PostId = postID;
             dal.DeletePostLike(aMember, aPost);

             int numberofPostLikes = newsFeedDAL.CountPostLikes(aPost);

             //Updating all Clients
             Clients.updatePostLikeCount(numberofPostLikes, postID);
        }
Ejemplo n.º 29
0
        public Member GetMemberDisplayName(Member member)
        {
            using (SqlConnection con = new SqlConnection(ConnectionString))
            {

                SqlCommand cmd = new SqlCommand("uspGetMemberDisplayName", con);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new SqlParameter("@MemberID", member.MemberId));

                con.Open();
                SqlDataReader dbReader = cmd.ExecuteReader();

                while (dbReader.Read())
                {
                    member.DisplayName = dbReader["DisplayName"].ToString();

                }
                con.Close();
            }
            return member;
        }
Ejemplo n.º 30
0
        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);
        }