Ejemplo n.º 1
0
    /// <summary>
    /// Generates the results
    /// </summary>
    /// <param name="purexml">Whether to just produce the XML</param>
    private void GetMessageBoardStatistics(bool purexml)
    {
        tblModStatsPerTopic.Rows.Clear();
        tblModStatsTopicTotals.Rows.Clear();
        tblHostsPostsPerTopic.Rows.Clear();
        lblEntryError.Text = String.Empty;

        DateTime entryDateTime = entryDate.SelectedDate;

        if (entryDateTime >= DateTime.Now.Date)
        {
            lblEntryError.Text = "The date selected must be before today.";
            return;
        }

        MessageBoardStatistics messageBoardStatistics = new MessageBoardStatistics(_basePage);
        messageBoardStatistics.TryCreateMessageBoardStatisticsXML(entryDateTime);

        if (!purexml)
        {
            DisplayMessageBoardStatistics(messageBoardStatistics);
        }
        else
        {
            //Replace an existing node
            if (_basePage.WholePageBaseXmlNode.SelectSingleNode("/MESSAGEBOARDSTATS") != null)
            {
                XmlNode messageBoardStatisticsNode = _basePage.WholePageBaseXmlNode.SelectSingleNode("/MESSAGEBOARDSTATS");

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