private string GetDisplayItemCount(Category category) { var newsItems = NewsManager.GetItems(category, false); int itemCount = NewsManager.CountItems(newsItems, Username); return(String.Format("({0})", itemCount)); }
protected void CreateCategoryNode <T>(T category, bool isAdmin) { var tempNode = typeof(T); string nodeName = string.Empty; string nodeId = string.Empty; string nodeParentName = string.Empty; string nodeParentId = string.Empty; string createLink = string.Empty; string createLinkText = string.Empty; bool hasAccess = false; var tempCategory = category; string createLinkStyle = string.Empty; if (tempNode.FullName.Contains("News")) { nodeName = (category as BusiBlocks.CommsBlock.News.Category).Name; nodeId = (category as BusiBlocks.CommsBlock.News.Category).Id; if ((category as BusiBlocks.CommsBlock.News.Category).ParentCategory != null) { nodeParentName = (category as BusiBlocks.CommsBlock.News.Category).ParentCategory.Name; nodeParentId = (category as BusiBlocks.CommsBlock.News.Category).ParentCategory.Id; } BusiBlocks.CommsBlock.News.Category x = NewsManager.GetCategoryByName(nodeName, true); tempCategory = (T)Convert.ChangeType(x, typeof(T)); createLink = Navigation.Communication_NewsCategoryNewItem(x).GetAbsoluteClientUrl(false); } else if (tempNode.FullName.Contains("Doco")) { nodeName = (category as BusiBlocks.DocoBlock.Category).DisplayName; nodeId = (category as BusiBlocks.DocoBlock.Category).Id; if ((category as BusiBlocks.DocoBlock.Category).ParentCategory != null) { nodeParentName = (category as BusiBlocks.DocoBlock.Category).ParentCategory.DisplayName; nodeParentId = (category as BusiBlocks.DocoBlock.Category).ParentCategory.Id; } BusiBlocks.DocoBlock.Category x = DocoManager.GetCategory(nodeId); tempCategory = (T)Convert.ChangeType(x, typeof(T)); createLink = Navigation.Doco_NewArticle(nodeId).GetAbsoluteClientUrl(false); } if (RadTreeView1.FindNodeByText(nodeName) == null) { RadTreeNode node = new RadTreeNode(nodeName, nodeId); string itemCount = string.Empty; //create node icons and links for new item. if (CategoryType == "News") { node.ImageUrl = "../app_themes/default/icons/commCat.gif"; var cat = NewsManager.GetCategory(nodeId); var newsItems = NewsManager.GetItems(cat, false); itemCount = NewsManager.CountItems(newsItems, Page.User.Identity.Name).ToString(); createLinkText = "Announcement"; createLinkStyle = "newAnnounce"; createLink = Navigation.Communication_NewsNewItem(NewsManager.GetCategory((category as BusiBlocks.CommsBlock.News.Category).Id)).GetAbsoluteClientUrl(false); } else if (CategoryType == "Doco") { node.ImageUrl = "../App_Themes/Default/icons/folder.png"; itemCount = DocoManager.CountItems(nodeId, Page.User.Identity.Name, Utilities.GetUserName(Page.User.Identity.Name)).ToString(); createLinkStyle = "newDoc"; createLinkText = "Document"; } Panel p = new Panel(); p.ID = "pnlNode"; p.CssClass = "tvNode"; Label lblName = new Label(); lblName.ID = "lblDivNodeName"; lblName.Text = nodeName + " (" + itemCount + ") "; Label lblContextMenu = new Label(); lblContextMenu.ID = "lblContextMenu"; lblContextMenu.CssClass = nodeId + "_tvContext hideElement"; //if user can edit then no need to check for contribute. hasAccess = SecurityHelper.CheckWriteAccess(Page.User.Identity.Name, nodeId); nodeName = "\'" + Utilities.EscapeSpecialCharacters(nodeName) + "\'"; if (isAdmin) { string url = tempNode.FullName.Contains("News") ? Navigation.Communication_NewsCategoryEditItem(nodeId).GetClientUrl(this, false) : Navigation.Admin_DocoDetails(nodeId).GetClientUrl(this, false); lblContextMenu.Text = "<a href=" + url + " class='edit'>Edit</a> "; string ParentCatId = string.Empty; //if all categories are listed as one node i.e. as list then the root is always null.(caters for any node with null parent) if (nodeParentId != string.Empty) { ParentCatId = nodeParentId; } lblContextMenu.Text += "<a href=# class='deleteitem' onclick=\"showDeleteCategoryPopup('Category','" + nodeId + "'," + nodeName + ",'','Delete');\">Delete</a> " +//delete link "<a href=# class='addCategory' onclick=\"showAddCategoryPopup('Category','" + nodeId + "',''," + nodeName + ",'Add');\">Add Category</a>"; } else { if (hasAccess) { lblContextMenu.Text = "<a href='" + createLink + "' class='" + createLinkStyle + "'>Create " + createLinkText + "</a>"; } } p.Controls.Add(lblName); p.Controls.Add(lblContextMenu); node.Controls.Add(p); RadTreeNode tNode = RadTreeView1.FindNode(x => x.Text.Contains(nodeParentName)); if (tNode == null) { RadTreeView1.Nodes.Add(node); } else if (nodeParentId != string.Empty) { if (tNode != null) { RadTreeView1.FindNodeByText(nodeParentName).Nodes.Add(node); } } else { RadTreeView1.Nodes.Add(node); } } }