예제 #1
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;
    }
예제 #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        var link = new HtmlLink();

        link.Href = Navigation.Doco_CategoryRss(null).GetServerUrl(true);
        link.Attributes.Add("rel", "alternate");
        link.Attributes.Add("type", "application/rss+xml");
        link.Attributes.Add("title", "Doco news");
        Header.Controls.Add(link);

        tree1.PopulateTreeView <Category>(DocoManager.GetViewableCategories(User.Identity.Name), false, false, string.Empty);
    }
예제 #3
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;
            }
        }
    }