Beispiel #1
0
        /// <summary>
        /// Handles the ItemDataBound event of the rpForums control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.RepeaterItemEventArgs"/> instance containing the event data.</param>
        protected void rpForums_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            switch (e.Item.ItemType)
            {
            case ListItemType.AlternatingItem:
            case ListItemType.Item:
            {
                Label forumLastPostingDateLabel = (Label)e.Item.FindControl("lblForumLastPostingDate");

                // check if date is NULL
                if (((DataRowView)e.Item.DataItem)["ForumLastPostingDate"] is System.DBNull)
                {
                    forumLastPostingDateLabel.Text = "Never";

                    // Date is null, there are no messages.
                    System.Web.UI.WebControls.Image noNewPostsIcon = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPosts");
                    noNewPostsIcon.Visible = true;
                }
                else
                {
                    HttpContext hcCurrent            = HttpContext.Current;
                    DateTime    forumLastPostingDate = (DateTime)(((DataRowView)e.Item.DataItem)["ForumLastPostingDate"]);
                    DateTime    lastVisitDate        = SessionAdapter.GetLastVisitDate();

                    forumLastPostingDateLabel.Text = forumLastPostingDate.ToString("dd-MMM-yyyy HH:mm");

                    // date is not 0, check if the date is > than the date in the session variable. If so, the posting is newer and we
                    // should visualize the New Messages image, otherwise the No new Messages image.
                    System.Web.UI.WebControls.Image postsIcon;

                    if (forumLastPostingDate > lastVisitDate)
                    {
                        // there are new messages since last visit
                        postsIcon = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNewPosts");
                    }
                    else
                    {
                        // no new messages
                        postsIcon = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPosts");
                    }
                    postsIcon.Visible = true;
                }
            }
            break;
            }
        }
Beispiel #2
0
        /// <summary>
        /// Event handler which will be called every time a row in the Repeater rpThreads is bound to a row in the view.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rpThreads_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            int maxAmountMessagesPerPage = SessionAdapter.GetUserDefaultNumberOfMessagesPerPage();

            switch (e.Item.ItemType)
            {
            case ListItemType.AlternatingItem:
            case ListItemType.Item:
                // Thread has always a last posting date: a thread has at least 1 posting.
                DateTime threadLastPostingDate = (DateTime)(((DataRowView)e.Item.DataItem)["ThreadLastPostingDate"]);
                DateTime lastVisitDate         = SessionAdapter.GetLastVisitDate();
                bool     isSticky      = (bool)(((DataRowView)e.Item.DataItem)["IsSticky"]);
                bool     isClosed      = (bool)(((DataRowView)e.Item.DataItem)["IsClosed"]);
                bool     bMarkedAsDone = (bool)(((DataRowView)e.Item.DataItem)["MarkedAsDone"]);

                // date is not 0, check if the date is > than the date in the session variable. If so, the posting is newer and we
                // should visualize the New Messages image, otherwise the No new Messages image. Also take into account
                // the type of the thread: sticky, closed or normal.
                System.Web.UI.WebControls.Image imgIconPosts;

                if (threadLastPostingDate > lastVisitDate)
                {
                    // there are new messages since last visit
                    if (isSticky)
                    {
                        imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNewPostsSticky");
                    }
                    else
                    {
                        if (isClosed)
                        {
                            imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNewPostsClosed");
                        }
                        else
                        {
                            // is normal
                            imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNewPosts");
                        }
                    }
                }
                else
                {
                    // no new messages
                    if (isSticky)
                    {
                        imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPostsSticky");
                    }
                    else
                    {
                        if (isClosed)
                        {
                            imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPostsClosed");
                        }
                        else
                        {
                            // is normal
                            imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPosts");
                        }
                    }
                }
                imgIconPosts.Visible = true;
                break;
            }
        }
Beispiel #3
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                this.Title += ApplicationAdapter.GetSiteName();

                // first time loaded, fill in properties
                lblUserName.Text = SessionAdapter.GetUserNickName();

                HttpContext hcCurrent          = HttpContext.Current;
                DataTable   bookmarkStatistics = null;

                // check if user is authenticated
                if (hcCurrent.Request.IsAuthenticated)
                {
                    lblWelcomeTextLoggedIn.Visible = true;
                    bookmarkStatistics             = UserGuiHelper.GetBookmarkStatisticsAsDataTable(SessionAdapter.GetUserID());
                }
                else
                {
                    lblWelcomeTextNotLoggedIn.Visible = true;
                    bookmarkStatistics = new DataTable();
                }

                // check if the user has the action right to approve attachments on some forum. If so, show the # of attachments which need approval
                List <int> forumsWithApprovalRight = SessionAdapter.GetForumsWithActionRight(ActionRights.ApproveAttachment);
                bool       canApproveAttachments   = ((forumsWithApprovalRight != null) && (forumsWithApprovalRight.Count > 0));
                if (canApproveAttachments)
                {
                    int numberOfAttachmentsToApprove = MessageGuiHelper.GetTotalNumberOfAttachmentsToApprove(
                        SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum),
                        SessionAdapter.GetForumsWithActionRight(ActionRights.ApproveAttachment),
                        SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID());
                    if (numberOfAttachmentsToApprove > 0)
                    {
                        phAttachmentsToApprove.Visible = true;
                        phAttentionRemarks.Visible     = true;
                    }
                }
                if (SessionAdapter.HasSystemActionRight(ActionRights.QueueContentManagement))
                {
                    int numberOfThreadsInSupportQueues = SupportQueueGuiHelper.GetTotalNumberOfThreadsInSupportQueues(
                        SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum));
                    if (numberOfThreadsInSupportQueues > 0)
                    {
                        phThreadsToSupport.Visible = true;
                        phAttentionRemarks.Visible = true;
                    }
                }

                DateTime lastVisitDate = SessionAdapter.GetLastVisitDate();

                if (SessionAdapter.IsLastVisitDateValid())
                {
                    phLastVisitDate.Visible = true;
                    lblLastVisitDate.Text   = lastVisitDate.ToString("dd-MMM-yyyy HH:mm");
                }

                // Get all sections which possibly can be displayed. Obtain this from the cache, as it's hardly changing data, and
                // this page is read a lot.
                _sectionsToDisplay = CacheManager.GetAllSections();

                // Per section, create a view with all the forumdata and filter out the forums not visible for the current user.
                List <int> accessableForums            = SessionAdapter.GetForumsWithActionRight(ActionRights.AccessForum);
                List <int> forumsWithThreadsFromOthers = SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers);
                _forumViewsPerDisplayedSection = ForumGuiHelper.GetAllAvailableForumsDataViews(_sectionsToDisplay, accessableForums,
                                                                                               forumsWithThreadsFromOthers, SessionAdapter.GetUserID());

                // filter out sections which do not have displayable forums for this user
                EntityView <SectionEntity> sectionsToUse = CreateFilteredSectionsCollection();

                // show the sections with displayable forums, thus the displayable sections.
                rpSections.DataSource = sectionsToUse;
                rpSections.DataBind();

                // get bookmarks and show them in the gui
                if ((bookmarkStatistics.Rows.Count <= 0) || ((bookmarkStatistics.Rows.Count == 1) && ((int)bookmarkStatistics.Rows[0][0] == 0)))
                {
                    // no bookmarks yet
                    lblAmountBookmarks.Text           = "0";
                    lblAmountPostingsInBookmarks.Text = "0";
                    lblBookmarksLastPostingDate.Text  = "Never";
                    imgIconBookmarkNoNewPosts.Visible = true;
                }
                else
                {
                    lblAmountBookmarks.Text           = bookmarkStatistics.Rows[0]["AmountThreads"].ToString();
                    lblAmountPostingsInBookmarks.Text = bookmarkStatistics.Rows[0]["AmountPostings"].ToString();
                    DateTime dateLastPosting = (DateTime)bookmarkStatistics.Rows[0]["LastPostingDate"];
                    lblBookmarksLastPostingDate.Text = dateLastPosting.ToString("dd-MMM-yyyy HH:mm");
                    if (dateLastPosting > lastVisitDate)
                    {
                        imgIconBookmarkNewPosts.Visible = true;
                    }
                    else
                    {
                        imgIconBookmarkNoNewPosts.Visible = true;
                    }
                }

                DataTable activeThreadsStatistics = ThreadGuiHelper.GetActiveThreadsStatisticsAsDataTable(accessableForums,
                                                                                                          CacheManager.GetSystemData().HoursThresholdForActiveThreads,
                                                                                                          SessionAdapter.GetForumsWithActionRight(ActionRights.ViewNormalThreadsStartedByOthers), SessionAdapter.GetUserID());
                if (activeThreadsStatistics != null)
                {
                    if ((activeThreadsStatistics.Rows.Count <= 0) || ((activeThreadsStatistics.Rows.Count == 1) && ((int)activeThreadsStatistics.Rows[0][0] == 0)))
                    {
                        lblAmountActiveThreads.Text            = "0";
                        lblAmountPostingsInActiveThreads.Text  = "0";
                        lblActiveThreadsLastPostingDate.Text   = "Never";
                        imgIconActiveThreadsNoNewPosts.Visible = true;
                    }
                    else
                    {
                        lblAmountActiveThreads.Text           = activeThreadsStatistics.Rows[0]["AmountThreads"].ToString();
                        lblAmountPostingsInActiveThreads.Text = activeThreadsStatistics.Rows[0]["AmountPostings"].ToString();
                        DateTime dateLastPosting = (DateTime)activeThreadsStatistics.Rows[0]["LastPostingDate"];
                        lblActiveThreadsLastPostingDate.Text = dateLastPosting.ToString("dd-MMM-yyyy HH:mm");
                        if (dateLastPosting > lastVisitDate)
                        {
                            imgIconActiveThreadsNewPosts.Visible = true;
                        }
                        else
                        {
                            imgIconActiveThreadsNoNewPosts.Visible = true;
                        }
                    }
                }
            }

            RegisterCollapseExpandClientScript();
        }
Beispiel #4
0
        /// <summary>
        /// Event handler which will be called every time a row in the Repeater rpThreads is bound to a row in the view.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void rpThreads_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e)
        {
            int maxAmountMessagesPerPage = SessionAdapter.GetUserDefaultNumberOfMessagesPerPage();

            switch (e.Item.ItemType)
            {
            case ListItemType.AlternatingItem:
            case ListItemType.Item:
                // Thread has always a last posting date: a thread has at least 1 posting.
                DateTime threadLastPostingDate = (DateTime)(((DataRowView)e.Item.DataItem)["ThreadLastPostingDate"]);
                DateTime lastVisitDate         = SessionAdapter.GetLastVisitDate();
                bool     isSticky = (bool)(((DataRowView)e.Item.DataItem)["IsSticky"]);
                bool     isClosed = (bool)(((DataRowView)e.Item.DataItem)["IsClosed"]);

                // date is not 0, check if the date is > than the date in the session variable. If so, the posting is newer and we
                // should visualize the New Messages image, otherwise the No new Messages image. Also take into account
                // the type of the thread: sticky, closed or normal.
                System.Web.UI.WebControls.Image imgIconPosts;

                if (threadLastPostingDate > lastVisitDate)
                {
                    // there are new messages since last visit
                    if (isSticky)
                    {
                        imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNewPostsSticky");
                    }
                    else
                    {
                        if (isClosed)
                        {
                            imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNewPostsClosed");
                        }
                        else
                        {
                            // is normal
                            imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNewPosts");
                        }
                    }
                }
                else
                {
                    // no new messages
                    if (isSticky)
                    {
                        imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPostsSticky");
                    }
                    else
                    {
                        if (isClosed)
                        {
                            imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPostsClosed");
                        }
                        else
                        {
                            // is normal
                            imgIconPosts = (System.Web.UI.WebControls.Image)e.Item.FindControl("imgIconNoNewPosts");
                        }
                    }
                }
                imgIconPosts.Visible = true;
                if (((DataRowView)e.Item.DataItem)["ClaimedByUserID"] != DBNull.Value)
                {
                    // thread is claimed by someone
                    HyperLink lnkClaimerThread = (HyperLink)e.Item.FindControl("lnkClaimerThread");
                    lnkClaimerThread.NavigateUrl += ((DataRowView)e.Item.DataItem)["ClaimedByUserID"].ToString();
                    lnkClaimerThread.Text         = HttpUtility.HtmlEncode((string)((DataRowView)e.Item.DataItem)["NickNameClaimedThread"]);
                    Label lblClaimDate = (Label)e.Item.FindControl("lblClaimDate");
                    lblClaimDate.Text = ((DateTime)((DataRowView)e.Item.DataItem)["ClaimedOn"]).ToString("dd-MMM-yyyy HH:mm.ss", DateTimeFormatInfo.InvariantInfo);
                }
                break;
            }
        }