Пример #1
0
    private void DisplayStatisticsReport(StatisticsReport statisticsReport)
    {
        int count = 0;
        TableHeaderRow headerRow = new TableHeaderRow();
        headerRow.BackColor = Color.MistyRose;

        int postingsCount = 0;

        foreach (XmlNode postings in statisticsReport.RootElement.SelectNodes(@"POSTING-STATISTICS/POSTINGS"))
        {
            if (count == 0)
            {
                TableHeaderCell headerSiteCell = new TableHeaderCell();
                headerSiteCell.Text = "Site";
                headerSiteCell.Scope = TableHeaderScope.Column;
                headerRow.Cells.Add(headerSiteCell);

                TableHeaderCell headerURLNameCell = new TableHeaderCell();
                headerURLNameCell.Text = "Site Name";
                headerURLNameCell.Scope = TableHeaderScope.Column;
                headerRow.Cells.Add(headerURLNameCell);

                TableHeaderCell headerForumIDCell = new TableHeaderCell();
                headerForumIDCell.Text = "Forum ID";
                headerForumIDCell.Scope = TableHeaderScope.Column;
                headerRow.Cells.Add(headerForumIDCell);

                TableHeaderCell headerIsMessageBoardCell = new TableHeaderCell();
                headerIsMessageBoardCell.Text = "Is Messageboard";
                headerIsMessageBoardCell.Scope = TableHeaderScope.Column;
                headerRow.Cells.Add(headerIsMessageBoardCell);

                TableHeaderCell headerTitleCell = new TableHeaderCell();
                headerTitleCell.Text = "Title";
                headerTitleCell.Scope = TableHeaderScope.Column;
                headerRow.Cells.Add(headerTitleCell);

                TableHeaderCell headerTotalPostsCell = new TableHeaderCell();
                headerTotalPostsCell.Text = "Total Posts";
                headerTotalPostsCell.Scope = TableHeaderScope.Column;
                headerRow.Cells.Add(headerTotalPostsCell);

                TableHeaderCell headerTotalUsersCell = new TableHeaderCell();
                headerTotalUsersCell.Text = "Total Users";
                headerTotalUsersCell.Scope = TableHeaderScope.Column;
                headerRow.Cells.Add(headerTotalUsersCell);
            }

            TableRow row = new TableRow();
            string forumID = String.Empty;
            if (postings.SelectSingleNode(@"@FORUMID") != null)
            {
                forumID = postings.SelectSingleNode(@"@FORUMID").InnerText;
            }

            string title = String.Empty;
            if (postings.SelectSingleNode(@"@TITLE") != null)
            {
                title = postings.SelectSingleNode(@"@TITLE").InnerText;
            }

            postingsCount++;

            if (postingsCount % 2 == 0)
                row.BackColor = Color.LightGray;
            else
                row.BackColor = Color.Linen;

            string siteID = postings.SelectSingleNode(@"@SITEID").InnerText;
            string siteName = postings.SelectSingleNode(@"@URLNAME").InnerText;
            string isMessageboard = postings.SelectSingleNode(@"@ISMESSAGEBOARD").InnerText;
            string totalPosts = postings.SelectSingleNode(@"@TOTALPOSTS").InnerText;
            string totalUsers = postings.SelectSingleNode(@"@TOTALUSERS").InnerText;

            TableCell siteIDCell = new TableCell();
            siteIDCell.HorizontalAlign = HorizontalAlign.Center;
            siteIDCell.Text = siteID;
            row.Cells.Add(siteIDCell);

            TableCell siteCell = new TableCell();
            siteCell.HorizontalAlign = HorizontalAlign.Center;
            siteCell.Text = siteName;
            row.Cells.Add(siteCell);

            TableCell forumIDCell = new TableCell();
            forumIDCell.HorizontalAlign = HorizontalAlign.Center;
            forumIDCell.Text = forumID;
            HyperLink forumTitleLink = new HyperLink();
            forumTitleLink.NavigateUrl = GetBaseUrl() + siteName + @"/F" + forumID;
            forumIDCell.Controls.Add(forumTitleLink);
            row.Cells.Add(forumIDCell);

            TableCell isMessageboardCell = new TableCell();
            isMessageboardCell.HorizontalAlign = HorizontalAlign.Center;
            isMessageboardCell.Text = isMessageboard;
            row.Cells.Add(isMessageboardCell);

            TableCell titleCell = new TableCell();
            titleCell.HorizontalAlign = HorizontalAlign.Center;
            titleCell.Text = title;
            row.Cells.Add(titleCell);

            TableCell totalPostsCell = new TableCell();
            totalPostsCell.HorizontalAlign = HorizontalAlign.Center;
            totalPostsCell.Text = totalPosts;
            row.Cells.Add(totalPostsCell);

            TableCell totalUsersCell = new TableCell();
            totalUsersCell.HorizontalAlign = HorizontalAlign.Center;
            totalUsersCell.Text = totalUsers;
            row.Cells.Add(totalUsersCell);

            tblResults.Rows.Add(row);
            count++;
        }

        _total = 0;
        string postStatsTotal = statisticsReport.RootElement.SelectSingleNode(@"POSTING-STATISTICS/@TOTAL").InnerText;
        if (postStatsTotal != null)
        {
            Int32.TryParse(postStatsTotal, out _total);
        }

        if (count == 0)
        {
            TableRow nodatarow = new TableRow();
            TableCell nodataCell = new TableCell();
            nodataCell.ColumnSpan = 4;
            nodataCell.Text = @"No data for those details";
            nodatarow.Cells.Add(nodataCell);
            tblResults.Rows.Add(nodatarow);
            Count.Text = "";
        }
        else
        {
            Count.Text = String.Format(@"{0} entries out of {1} in total.", count.ToString(), _total.ToString());
        }

        tblResults.Rows.AddAt(0, headerRow);

        tblResults.CellSpacing = 5;
        tblResults.BorderWidth = 2;
        tblResults.BorderStyle = BorderStyle.Outset;

        ShowHideResultControls(true);
        UpdatePagingControls();
        StoreValues();
    }
Пример #2
0
    /// <summary>
    /// Generates the results
    /// </summary>
    /// <param name="purexml">Whether to just produce the XML</param>
    private void GetStatisticsReport(bool purexml)
    {
        tblResults.Rows.Clear();
        Count.Text = "";
        lblEntryError.Text = String.Empty;

        DateTime entryDateTime = entryDate.SelectedDate;

        int intervalvalue = 1;
        Int32.TryParse(interval.SelectedValue, out intervalvalue);

        StatisticsReport statisticsReport = new StatisticsReport(_basePage);
        statisticsReport.TryCreateStatisticsReportXML(_skip, _show, entryDateTime, intervalvalue);

        if (!purexml)
        {
            DisplayStatisticsReport(statisticsReport);
        }
        else
        {
            //Replace an existing node
            if (_basePage.WholePageBaseXmlNode.SelectSingleNode("/POSTING-STATISTICS") != null)
            {
                XmlNode statisticsReportNode = _basePage.WholePageBaseXmlNode.SelectSingleNode("/POSTING-STATISTICS");

                _basePage.WholePageBaseXmlNode.ReplaceChild(statisticsReportNode, _basePage.WholePageBaseXmlNode.OwnerDocument.ImportNode(statisticsReport.RootElement.FirstChild, true));
            }
            else
            {
                _basePage.WholePageBaseXmlNode.FirstChild.AppendChild(_basePage.WholePageBaseXmlNode.OwnerDocument.ImportNode(statisticsReport.RootElement.FirstChild, true));
            }
        }
    }