예제 #1
0
        private void GenerateRecentContent(string type)
        {
            if (type == "submissions")
            {
                //We need to add a table for submissions, since they are just trs and tds
                Literal lit1 = new Literal();
                lit1.Text = "<table width=\"100%\">";
                recentContentPanel.Controls.Add(lit1);

                SubmissionManagementBO bo      = new SubmissionManagementBO();
                List <SubmissionVO>    subList = bo.GetListOfSubmissionsByUser(5, UserID);

                foreach (SubmissionVO sub in subList)
                {
                    Submission submission = (Submission)Page.LoadControl("~/Controls/Submission.ascx");
                    submission.ID           = "submission" + sub.SubmissionID;
                    submission.submissionID = sub.SubmissionID;

                    recentContentPanel.Controls.Add(submission);
                }

                //We need to close the table tag we added
                Literal lit2 = new Literal();
                lit2.Text = "</table>";
                recentContentPanel.Controls.Add(lit2);
            }
            else if (type == "comments")
            {
                CommentManagementBO bo      = new CommentManagementBO();
                List <CommentVO>    comList = bo.GetListOfCommentsByUserID(5, UserID);

                foreach (CommentVO comment in comList)
                {
                    Comment com = (Comment)Page.LoadControl("~/Controls/Comment.ascx");
                    com.ID           = "comment" + comment.CommentID;
                    com.commentDepth = 0;
                    com.commentID    = comment.CommentID;

                    recentContentPanel.Controls.Add(com);
                }
            }
        }
        protected void AddComments()
        {
            if (submissionID != 0)
            {
                CommentManagementBO bo          = new CommentManagementBO();
                List <CommentVO>    commentList = bo.GetListOfSubmissionComments(submissionID);
                commentList = bo.SortComments(commentList);

                CommentVO   previousComment = new CommentVO();
                Stack <int> pcStack         = new Stack <int>();
                int         depth           = 0;

                foreach (CommentVO comment in commentList)
                {
                    //This determines the depth of the comment
                    //We only want to be indenting once, not every postback
                    if (!Page.IsPostBack)
                    {
                        if (comment.ParentCommentID == 0)
                        {
                            pcStack.Push(comment.CommentID);
                            depth = 0;
                        }
                        else if (comment.ParentCommentID == pcStack.Peek())
                        {
                            if (comment.ParentCommentID == previousComment.CommentID)
                            {
                                pcStack.Push(comment.CommentID);
                                depth++;
                            }
                        }
                        else
                        {
                            pcStack.Pop();
                            depth--;
                        }
                    }

                    Comment com = (Comment)Page.LoadControl("~/Controls/Comment.ascx");
                    com.ID           = "comment" + comment.CommentID;
                    com.commentDepth = depth;
                    com.commentID    = comment.CommentID;

                    commentPanel.Controls.Add(com);

                    previousComment = comment;
                }
            }
            else if (userID != 0)
            {
                CommentManagementBO bo          = new CommentManagementBO();
                List <CommentVO>    commentList = bo.GetListOfCommentsByUserID(userID, 5);

                foreach (CommentVO comment in commentList)
                {
                    Comment com = (Comment)Page.LoadControl("~/Controls/Comment.ascx");
                    com.ID        = "comment" + comment.CommentID;
                    com.commentID = comment.CommentID;

                    commentPanel.Controls.Add(com);
                }
            }
        }