예제 #1
0
    private void AddArticles(BusiBlocks.DocoBlock.Category category, IList <Article> articles)
    {
        IList <Article> artls = DocoManager.GetArticles(category, ArticleStatus.All, false);

        foreach (Article article in artls)
        {
            articles.Add(article);
        }
    }
예제 #2
0
    private void LoadList(Category category)
    {
        //Get the standard articles
        IList <Article> articles = DocoManager.GetArticles(category, ArticleStatus.All, false);

        // Add all the document instances to the list.
        string[] arr = articles.Select(x => x.Id).ToArray();
        list.SetState(string.Join(",", arr));
    }
예제 #3
0
    public void Bind()
    {
        IList <BusiBlocks.DocoBlock.Category> categories = DocoManager.GetViewableCategories(Page.User.Identity.Name);
        List <Article> allArticles = new List <Article>();

        foreach (BusiBlocks.DocoBlock.Category category in categories)
        {
            List <Article> articles = (List <Article>)DocoManager.GetArticles(category, ArticleStatus.All, false);
            articles.ToList().ForEach(x => allArticles.Add(x));
        }
        RadGrid1.DataSource = allArticles;
    }
예제 #4
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();
    }
예제 #5
0
    private IList <Article> GetAllArticles()
    {
        IList <Category> categories = DocoManager.GetAllCategories();
        IList <Article>  articles   = new List <Article>();

        foreach (Category category in categories)
        {
            if (SecurityHelper.CanUserView(Page.User.Identity.Name, category.Id))
            {
                IList <Article> arts = DocoManager.GetArticles(category, ArticleStatus.All, false);
                foreach (Article article in arts)
                {
                    articles.Add(article);
                }
            }
        }
        return(articles);
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        var articlesIManage = new List <Article>();
        var accesses        = new List <Access>();

        // Go through each group I watch
        foreach (Access access in Profile.ManagedGroups.Accesses)
        {
            accesses.AddRange(AccessManager.GetItemsMatchingAccess(access, BusiBlocks.ItemType.DocoCategory, BusiBlocks.AccessType.View));
        }

        foreach (Access access in accesses)
        {
            articlesIManage.AddRange(DocoManager.GetArticles(DocoManager.GetCategory(access.ItemId), ArticleStatus.EnabledAndApproved, false));
        }

        listDocAckRepeater.DataSource = articlesIManage.Where(delegate(Article article) { return(article.RequiresAck); });
        listDocAckRepeater.DataBind();

        listDocViewedRepeater.DataSource = articlesIManage.Where(delegate(Article article) { return(!article.RequiresAck); });
        listDocViewedRepeater.DataBind();
    }
예제 #7
0
    protected void DeleteCategoryClick(object sender, EventArgs e)
    {
        string categoryName       = string.Empty;
        string categoryId         = popDeleteCategory.ReferrerId;
        string categoryTypeName   = string.Empty;
        string parentCategoryName = string.Empty;
        bool   deleteFailure      = false;

        // Need to figure out if this is a comms block category or a doco block category.
        if (!string.IsNullOrEmpty(categoryId))
        {
            BusiBlocks.CommsBlock.News.Category news = null;
            try
            {
                news = NewsManager.GetCategory(categoryId);
            }
            catch (NewsCategoryNotFoundException) { }
            if (news != null)
            {
                categoryTypeName = news.GetType().Name;
                categoryName     = news.Name;

                // Don't allow the root category to be deleted.
                if (news.ParentCategory == null)
                {
                    ((IFeedback)this.Page.Master).ShowFeedback(
                        BusiBlocksConstants.Blocks.Administration.LongName,
                        news.Name,
                        Feedback.Actions.Error,
                        "Cannot delete the highest level category"
                        );
                    return;
                }

                parentCategoryName = news.ParentCategory.Name;
                IList <BusiBlocks.CommsBlock.News.Item>     newsItems         = NewsManager.GetItems(news, true);
                IList <BusiBlocks.CommsBlock.News.Category> newsSubCategories = NewsManager.GetCategories(news.Id, true);
                // NewsManager.GetCategories returns the root category, so it will always have at least one item
                if (newsSubCategories.Count <= 1 && newsItems.Count == 0)
                {
                    NewsManager.DeleteCategory(news);
                    PopulateTreeView <BusiBlocks.CommsBlock.News.Category>(NewsManager.GetViewableCategories(Page.User.Identity.Name), true, false, string.Empty);
                }
                else
                {
                    deleteFailure = true;
                }
            }
            else
            {
                BusiBlocks.DocoBlock.Category doco = null;
                try
                {
                    doco = DocoManager.GetCategory(categoryId);
                }
                catch (DocoCategoryNotFoundException) { }

                if (doco != null)
                {
                    categoryTypeName   = doco.GetType().Name;
                    categoryName       = doco.DisplayName;
                    parentCategoryName = doco.ParentCategory.DisplayName;

                    IList <Article> docoItems = DocoManager.GetArticles(doco, ArticleStatus.All, true);
                    IList <BusiBlocks.DocoBlock.Category> docoSubCategories = DocoManager.GetAllCategoriesBelow(doco.Id);
                    if (docoSubCategories.Count == 0 && docoItems.Count == 0)
                    {
                        DocoManager.DeleteCategory(doco);
                        this.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetAllCategories(), true, false, string.Empty);
                    }
                    else
                    {
                        deleteFailure = true;
                    }
                }
            }
            RadTreeView1.DataBind();
        }
        //Displaying feedback.
        if (deleteFailure)
        {
            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Error,
                ErrorCategoryNotEmpty
                );
            RadTreeView1.FindNodeByText(categoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(categoryName).Selected = true;
        }
        else
        {
            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Deleted,
                categoryName
                );
            RadTreeView1.FindNodeByText(parentCategoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(parentCategoryName).Selected = true;
        }
    }