示例#1
0
    private void LoadNews()
    {
        //if (BusiBlocks.SecurityHelper.CanRead(Page.User, category, null) == false)
        //    throw new BusiBlocks.InvalidPermissionException("read category");
        var news = new List <Item>();

        IList <Access> accessibleList = AccessManager.GetUsersAccessibleItems(Page.User.Identity.Name, BusiBlocks.ItemType.NewsItem, BusiBlocks.AccessType.View);

        foreach (Access access in accessibleList)
        {
            Category category = NewsManager.GetCategory(access.ItemId);
            news.AddRange(NewsManager.GetPublishedItems(category, false));
        }

        List <KeyValuePair <Item, TrafficLightStatus> > newsWithTLList = new List <KeyValuePair <Item, TrafficLightStatus> >();

        if (accessibleList != null)
        {
            foreach (Item newsItem in news)
            {
                if (!newsWithTLList.Exists(i => i.Key.Id == newsItem.Id))
                {
                    if (newsItem != null)
                    {
                        TrafficLightStatus tflStatus = NewsManager.GetTrafficLight(Page.User.Identity.Name, newsItem);
                        if (tflStatus.RequiresAck)
                        {
                            if (tflStatus.Acknowledged)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (tflStatus.Viewed)
                            {
                                continue;
                            }
                        }
                        if (newsWithTLList.Count < 5)
                        {
                            newsWithTLList.Add(new KeyValuePair <Item, TrafficLightStatus>(newsItem, tflStatus));
                        }
                    }
                }
            }
        }

        lblNoResults.Visible = newsWithTLList.Count == 0;

        listRepeater.DataSource = newsWithTLList;
        listRepeater.DataBind();
    }
    private void LoadMessages()
    {
        List <Access> accessibleList = AccessManager.GetUsersAccessibleItems(Page.User.Identity.Name, BusiBlocks.ItemType.ForumTopic, BusiBlocks.AccessType.View);
        //IList<PersonType> personTypes = PersonManager.GetPersonTypesByUser(Page.User.Identity.Name);
        var itemsToList = new List <BusiBlocks.CommsBlock.Forums.Topic>();

        // todo MASSIVE problem here. When we create a forum topic, we store the permissions for it as the forum Category.
        // Then we retrieve all 'topics' by looking at the categories in the access table.
        // Then we are expected to display those 'topics', even though we have now lost that information (since we
        // stored them as categories.
        // We should have stored them as topicIds not categoryIds in the access table, then retrieved those topics

        // For the moment, filter the duplicate category items in the accessible list.
        var cleanAccessList = new List <Access>();

        foreach (Access access in accessibleList)
        {
            if (!cleanAccessList.Exists(delegate(Access a) { return(a.ItemId == access.ItemId); }))
            {
                cleanAccessList.Add(access);
            }
        }

        foreach (Access access in cleanAccessList)
        {
            BusiBlocks.CommsBlock.Forums.Category      category = BusiBlocks.CommsBlock.Forums.ForumsManager.GetCategory(access.ItemId);
            IList <BusiBlocks.CommsBlock.Forums.Topic> items    = BusiBlocks.CommsBlock.Forums.ForumsManager.GetTopics(category, new BusiBlocks.PagingInfo(0, 1));

            foreach (BusiBlocks.CommsBlock.Forums.Topic item in items)
            {
                if (!itemsToList.Exists(delegate(BusiBlocks.CommsBlock.Forums.Topic i) { return(i.Id == item.Id); }))
                {
                    //if (item.RequiresAck)
                    //{
                    //    if (item.Acknowledged)
                    //        continue;
                    //}
                    //else
                    //{
                    //    if (item.Viewed)
                    //        continue;
                    //}
                    itemsToList.Add(item);
                }
            }
        }

        lblNoResults.Visible = itemsToList.Count == 0;

        listRepeater.DataSource = itemsToList;
        listRepeater.DataBind();
    }
示例#3
0
    /// <summary>
    /// Retrieve all the articles.
    /// </summary>
    private void LoadArticles()
    {
        var articles = new List <Article>();

        // Get eligible document categories
        // todo Refactor Versioning so that I can pass the categories that I'm interested in (viewable news categories),
        // and then it returns be all the versionItems that are in those categories.
        IList <Access> accessibleList = AccessManager.GetUsersAccessibleItems(Page.User.Identity.Name, BusiBlocks.ItemType.DocoCategory, BusiBlocks.AccessType.View);

        foreach (Access accessItem in accessibleList)
        {
            Category category = DocoManager.GetCategory(accessItem.ItemId);
            articles.AddRange(DocoManager.GetArticles(category, ArticleStatus.EnabledAndApproved, false)
                              .Where(x => x.RequiresAck)
                              .Distinct(new KeyEqualityComparer <Article>(x => x.Name)));
        }

        // Filter articles to only include those that have not been viewed or ack'd
        var itemsToList = new List <Article>();

        foreach (Article article in articles)
        {
            if (!itemsToList.Exists(i => i.Id == article.Id))
            {
                if (article.RequiresAck)
                {
                    if (article.Acknowledged)
                    {
                        continue;
                    }
                }
                else
                {
                    if (article.Viewed)
                    {
                        continue;
                    }
                }
                //restricting to display only 5 items for each dashboard.
                if (itemsToList.Count < 5)
                {
                    itemsToList.Add(article);
                }
            }
        }

        lblNoResults.Visible    = itemsToList.Count == 0;
        listRepeater.DataSource = itemsToList;
        listRepeater.DataBind();
    }