Пример #1
0
    private void LoadList()
    {
        if (!string.IsNullOrEmpty(CategoryName))
        {
            BusiBlocks.CommsBlock.Forums.Category category = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategoryByName(CategoryName, true);

            var paging = new BusiBlocks.PagingInfo(ListPagingSize, CurrentPage);
            IList <BusiBlocks.CommsBlock.Forums.Topic> topics = BusiBlocks.CommsBlock.Forums.ForumsManager.GetTopics(category,
                                                                                                                     paging);

            var allowedTopics = new List <BusiBlocks.CommsBlock.Forums.Topic>();

            IList <PersonType> groups = PersonManager.GetPersonTypesByUser(Page.User.Identity.Name);

            foreach (BusiBlocks.CommsBlock.Forums.Topic topic in topics)
            {
                if (BusiBlocks.SecurityHelper.CanUserView(Page.User.Identity.Name, topic.Category.Id))
                {
                    // If the user is in at least one group, then let them continue.
                    if (groups.Count > 0)
                    {
                        allowedTopics.Add(topic);
                    }
                }
            }

            lblCurrentPage.InnerText = (CurrentPage + 1).ToString();
            lblTotalPage.InnerText   = paging.PagesCount.ToString();

            listRepeater.DataSource = allowedTopics;
            listRepeater.DataBind();

            if (CurrentPage == 0)
            {
                linkPrev.Enabled = false;
            }
            else
            {
                linkPrev.Enabled = true;
            }
            if (CurrentPage + 1 >= paging.PagesCount)
            {
                linkNext.Enabled = false;
            }
            else
            {
                linkNext.Enabled = true;
            }
        }
    }
Пример #2
0
    private SyndicationLibrary.RSS.RssFeed CreateRssFeed()
    {
        DateTime fromDate = DateTime.Now.AddDays(-MESSAGE_AGE);

        SyndicationLibrary.RSS.RssFeed rss;
        using (System.IO.FileStream stream = new System.IO.FileStream(BusiBlocks.PathHelper.LocateServerPath(TEMPLATE_FILE), System.IO.FileMode.Open, System.IO.FileAccess.Read))
            rss = SyndicationLibrary.RSS.RssFeed.GetFeed(stream);

        if (rss == null)
        {
            throw new ApplicationException("Failed to load rss from " + TEMPLATE_FILE);
        }


        var paging = new BusiBlocks.PagingInfo(MAX_MESSAGES, 0);
        IList <BusiBlocks.CommsBlock.Forums.Message> messages = BusiBlocks.CommsBlock.Forums.ForumsManager.FindMessages(
            BusiBlocks.Filter.MatchOne(GetSelectedForums()),
            null,
            null,
            null,
            fromDate,
            null,
            paging);

        DateTime lastPubDate = DateTime.MinValue;

        foreach (BusiBlocks.CommsBlock.Forums.Message msg in messages)
        {
            rss.Channel.Items.Add(CreateRssItem(msg));

            if (msg.UpdateDate > lastPubDate)
            {
                lastPubDate = msg.UpdateDate;
            }
        }

        rss.Channel.PublicationDate = lastPubDate;
        rss.Channel.LastBuildDate   = lastPubDate;

        return(rss);
    }
Пример #3
0
    private SyndicationLibrary.RSS.RssFeed CreateRssFeed()
    {
        DateTime fromDate = DateTime.Now.AddDays(-MESSAGE_AGE);

        SyndicationLibrary.RSS.RssFeed rss;
        using (System.IO.FileStream stream = new System.IO.FileStream(BusiBlocks.PathHelper.LocateServerPath(TEMPLATE_FILE), System.IO.FileMode.Open, System.IO.FileAccess.Read))
            rss = SyndicationLibrary.RSS.RssFeed.GetFeed(stream);

        if (rss == null)
        {
            throw new ApplicationException("Failed to load rss from " + TEMPLATE_FILE);
        }


        BusiBlocks.PagingInfo paging = new BusiBlocks.PagingInfo(MAX_MESSAGES, 0);
        IList <BusiBlocks.DocoBlock.Article> articles = BusiBlocks.DocoBlock.DocoManager.FindArticles(
            BusiBlocks.Filter.MatchOne(GetSelectedCategories()),
            null, null, null, null,
            fromDate,
            null,
            BusiBlocks.DocoBlock.ArticleStatus.EnabledAndApproved,
            paging);

        DateTime lastPubDate = DateTime.MinValue;

        foreach (BusiBlocks.DocoBlock.Article article in articles)
        {
            rss.Channel.Items.Add(CreateRssItem(article));

            if (article.UpdateDate > lastPubDate)
            {
                lastPubDate = article.UpdateDate;
            }
        }

        rss.Channel.PublicationDate = lastPubDate;
        rss.Channel.LastBuildDate   = lastPubDate;

        return(rss);
    }
Пример #4
0
    private void LoadList(int page)
    {
        try
        {
            string[] searchFor    = BusiBlocks.SplitHelper.SplitSearchText(txtSearchFor.Text);
            string[] authorSearch = BusiBlocks.SplitHelper.SplitSearchText(txtAuthor.Text);

            var paging = new BusiBlocks.PagingInfo(ListPagingSize, page);
            IList <BusiBlocks.CommsBlock.Forums.Message> messages = BusiBlocks.CommsBlock.Forums.ForumsManager.FindMessages(
                BusiBlocks.Filter.MatchOne(GetSelectedForums()),
                BusiBlocks.Filter.ContainsAll(searchFor),
                BusiBlocks.Filter.ContainsOne(authorSearch),
                null,
                null, null,
                paging);

            searchResult.LoadList(messages, page, (int)paging.PagesCount);
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Page.Master).SetException(GetType(), ex);
        }
    }
Пример #5
0
    private void LoadList(int page)
    {
        try
        {
            string[] searchFor    = BusiBlocks.SplitHelper.SplitSearchText(txtSearchFor.Text);
            string[] authorSearch = BusiBlocks.SplitHelper.SplitSearchText(txtAuthor.Text);

            BusiBlocks.PagingInfo paging = new BusiBlocks.PagingInfo(LIST_PAGING_SIZE, page);
            IList <BusiBlocks.DocoBlock.Article> articles = BusiBlocks.DocoBlock.DocoManager.FindArticles(
                BusiBlocks.Filter.MatchOne(GetSelectedCategories()),
                BusiBlocks.Filter.ContainsAll(searchFor),
                BusiBlocks.Filter.ContainsOne(authorSearch),
                null, null, null, null,
                BusiBlocks.DocoBlock.ArticleStatus.EnabledAndApproved,
                paging);

            searchResult.LoadList(articles, page, (int)paging.PagesCount);
        }
        catch (Exception ex)
        {
            throw ex;
            ((IFeedback)Master).SetException(GetType(), ex);
        }
    }