예제 #1
0
    protected void AddCategoryClick(object sender, EventArgs e)
    {
        string categoryName     = popAddCategory.Value;
        string categoryId       = popAddCategory.ReferrerId;
        string categoryTypeName = string.Empty;

        // 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);
                categoryTypeName = news.GetType().Name;
            }
            catch (NewsCategoryNotFoundException) { }
            if (news != null)
            {
                BusiBlocks.CommsBlock.News.Category childCategory = NewsManager.CreateCategory(categoryName);
                childCategory.ParentCategory = news;
                NewsManager.UpdateCategory(childCategory);
                this.PopulateTreeView <BusiBlocks.CommsBlock.News.Category>(NewsManager.GetAllCategories(), true, false, string.Empty);
            }
            else
            {
                BusiBlocks.DocoBlock.Category doco = null;
                try
                {
                    doco             = DocoManager.GetCategory(categoryId);
                    categoryTypeName = doco.GetType().Name;
                }
                catch (DocoCategoryNotFoundException) { }
                if (doco != null)
                {
                    BusiBlocks.DocoBlock.Category childDocoCategory = DocoManager.CreateCategory(categoryName);
                    childDocoCategory.ParentCategory = doco;
                    DocoManager.UpdateCategory(childDocoCategory);
                    this.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetAllCategories(), true, false, string.Empty);
                }
            }
            RadTreeView1.DataBind();
            RadTreeView1.FindNodeByText(categoryName).ExpandParentNodes();
            RadTreeView1.FindNodeByText(categoryName).Selected = true;

            ((IFeedback)this.Page.Master).ShowFeedback(
                BusiBlocksConstants.Blocks.Administration.LongName,
                categoryTypeName,
                Feedback.Actions.Created,
                categoryName
                );
        }
    }
예제 #2
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);
    }
예제 #3
0
    public IList <Category> GetAllEditableCategories()
    {
        IList <Category> categories = DocoManager.GetAllCategories();

        IList <Category> toRemove = new List <Category>();

        foreach (Category cat in categories)
        {
            // Remove this category from the list if it is not viewable by this user.
            if (!BusiBlocks.SecurityHelper.CheckWriteAccess(Page.User.Identity.Name, cat.Id))
            {
                toRemove.Add(cat);
            }
        }
        foreach (Category cat in toRemove)
        {
            categories.Remove(cat);
        }
        return(categories);
    }
예제 #4
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;
        }
    }
예제 #5
0
    public IList <Category> GetAllViewableCategories()
    {
        IList <Category> categories = DocoManager.GetAllCategories();

        return(categories);
    }
예제 #6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     tree1.EnableDragAndDrop();
     tree1.PopulateTreeView <Category>(DocoManager.GetAllCategories(), true, false, string.Empty);
 }