コード例 #1
0
    protected void AddArticleToList(IList <Article> articles, string name)
    {
        if (!string.IsNullOrEmpty(name))
        {
            BusiBlocks.DocoBlock.Category category = DocoManager.GetCategoryByName(name, true);

            if (category != null)
            {
                AddArticles(category, articles);
            }
            else// wild card scenario.
            {
                IList <BusiBlocks.DocoBlock.Category> categories = DocoManager.GetCategoryByLikeName(name, true);

                foreach (BusiBlocks.DocoBlock.Category item in categories)
                {
                    AddArticles(item, articles);
                }
            }
        }
    }
コード例 #2
0
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        if (e.CommandName.Equals("Edt"))
        {
            //Navigation.Doco_EditArticle(e.CommandArgument.ToString()).Redirect(this);
            var lnk = (LinkButton)e.Item.FindControl("imgBtnEdit");

            var img = (Image)e.Item.FindControl("imgType");

            if (img.ImageUrl.Contains("onlineDoc"))
            {
                Navigation.Doco_ViewArticle(e.CommandArgument.ToString(), 0, lnk.Attributes["catid"], "draft").Redirect(
                    this);
            }
            else
            {
                Navigation.Doco_EditArticle(e.CommandArgument.ToString()).Redirect(this);
            }
        }
        else if (e.CommandName.Equals("Delete"))
        {
            string docId = e.CommandArgument.ToString();

            Article articleToDelete      = DocoManager.GetArticle(docId);
            string  itemNameBeforeDelete = articleToDelete.Title;
            string  catIdBeforeDel       = articleToDelete.Category.Id;
            DocoManager.DeleteArticle(articleToDelete);

            Controls_TreeView tree = (Controls_TreeView)this.Parent.FindControl("tree1");
            tree.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetViewableCategories(Page.User.Identity.Name), false, false, string.Empty);
            tree.RebindNode(catIdBeforeDel, false);

            ((IFeedback)Page.Master).ShowFeedback(BusiBlocksConstants.Blocks.Documents.ShortName, articleToDelete.GetType().Name, Feedback.Actions.Deleted, itemNameBeforeDelete);
        }
        else if (e.CommandName == RadGrid.FilterCommandName)
        {
            Pair           filterPair = (Pair)e.CommandArgument;
            List <Article> items      = new List <Article>();

            switch (filterPair.Second.ToString())
            {
            case "Category":
                TextBox tbPattern = (e.Item as GridFilteringItem)["Category"].Controls[0] as TextBox;
                FilterExpression = tbPattern.Text;
                BindWithFilter(items);
                RadGrid1.DataBind();
                if (!string.IsNullOrEmpty(FilterExpression))
                {
                    var foundArticles = DocoManager.GetCategoryByLikeName(FilterExpression.Split(',').First(), true);
                    if (foundArticles.Count > 0)
                    {
                        Controls_TreeView tree = (Controls_TreeView)this.Parent.FindControl("tree1");
                        tree.PopulateTreeView <BusiBlocks.DocoBlock.Category>(DocoManager.GetViewableCategories(Page.User.Identity.Name), false, false, string.Empty);
                        string selectedNode = (foundArticles.FirstOrDefault()).Id;
                        tree.RebindNode(selectedNode, true);
                    }
                }
                break;

            default:
                break;
            }
        }
    }