Ejemplo n.º 1
0
        public void Refresh(StyleGuide.API api)
        {
            StyleGuide.SgCategories.Categories cats = null;
            if (!string.IsNullOrWhiteSpace(tbSearch.Text))
            {
                cats = api.getAllCategoriesContainsEntitiesOrderByType(tbSearch.Text, true);
            }
            else
            {
                cats = api.getAllCategoriesOrderByType(null, true);
            }
            if (cats != null)
            {
                this.lbError.Text = "";

                this.trvCat.Nodes.Clear();
                bool selected = false;
                foreach (StyleGuide.SgCategories.Category cat in cats)
                {
                    TreeNode node  = new TreeNode();
                    int      xDays = App_Code.webConfig.ShowEntityCountModifiedInLastXdays();
                    int      count = api.getEntityCountModifiedLaterthan(cat.ID, DateTime.Now.AddDays(xDays * -1));
                    if (count >= 1)
                    {
                        node.Text = cat.Name + string.Format("<span style='color:red;padding-left:5px;'>{0}*</span>", count);
                    }
                    else
                    {
                        node.Text = cat.Name;
                    }
                    node.Value   = cat.ID.ToString();
                    node.ToolTip = cat.Name;
                    if (!selected)
                    {
                        node.Select();
                        selected = true;
                    }
                    this.trvCat.Nodes.Add(node);
                    node = null;
                }
                trvCat_SelectedNodeChanged(this.trvCat, null);
            }
            else
            {
                this.trvCat.Nodes.Clear();
                this.rptType.DataSource = null;
                this.rptType.DataBind();
                this.divShowAllEntityType.Visible = false;
                this.lbError.Text = "No Entity found.";
            }
        }