Пример #1
0
    protected void rptCategoriesNested_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            // increment the child index counter
            ++currentChildIndex;

            CategoryCount cat = (CategoryCount)e.Item.DataItem;

            // how many children are there?
            var children = cats.FindAll(
                delegate(CategoryCount c) { return(c.ParentId == cat.ParentId); });

            if (children != null && children.Count > 0)
            {
                Image img = (Image)e.Item.FindControl("TreeImage");

                if (currentChildIndex < children.Count)
                {
                    img.ImageUrl = ResolveUrl("~/graffiti-admin/common/img/m.gif");
                }
                else
                {
                    img.ImageUrl = ResolveUrl("~/graffiti-admin/common/img/b.gif");
                }
            }
        }
    }
Пример #2
0
        public async Task <List <CategoryCount> > NumberOfCategories(List <Movie_Category> MovieCategoryVM, List <Category> CategoryVM)
        {
            List <CategoryCount> CategoryCountList = new List <CategoryCount>();

            foreach (var category in CategoryVM)
            {
                CategoryCount Counter  = new CategoryCount();
                int           CountInt = 0;
                foreach (var movieCategory in MovieCategoryVM)
                {
                    if (category.Id == movieCategory.FK_CategoryID)
                    {
                        CountInt++;
                    }
                }

                Counter.Name  = category.CategoryName;
                Counter.Count = CountInt;
                CategoryCountList.Add(Counter);
            }
            IEnumerable <CategoryCount> SortedList = CategoryCountList.OrderByDescending(CategoryCount => CategoryCount.Count);

            List <CategoryCount> FinalList = new List <CategoryCount>();

            foreach (var item in SortedList)
            {
                FinalList.Add(item);
            }

            return(FinalList);
        }
            public object Get(CategoryCount request)
            {
                var resp = new Dto <long>();

                resp.Result = Handler.Count(request.IncludeDeleted);

                return(resp);
            }
Пример #4
0
        //returns a hashtable of newly assigned cats tp docId based on k neighbors and c top cats
        public Hashtable GetNewCategories(int docId, int k, int c)
        {
            Console.WriteLine("calculating for docId=" + docId + " k=" + k + " c=" + c);

            Hashtable allCats = new Hashtable();

            d.ResultDocument[] results = searcher.Search(docId, k);
            foreach (d.ResultDocument doc in results)
            {
                ArrayList cats = dcLoader.GetDocCategories(doc.DocId);
                if (cats != null)
                {
                    foreach (int catId in cats)
                    {
                        if (allCats.Contains(catId))
                        {
                            CategoryCount cc = (CategoryCount)allCats[catId];
                            cc.catCount = cc.catCount + 1;
                        }
                        else
                        {
                            allCats.Add(catId, new CategoryCount(catId, 1));
                        }
                    }
                }
            }
            //now make an array
            CategoryCount[]       arrCats = new CategoryCount[allCats.Count];
            IDictionaryEnumerator en      = allCats.GetEnumerator();
            int cursor = 0;

            while (en.MoveNext())
            {
                arrCats[cursor++] = (CategoryCount)en.Value;
            }

            Array.Sort(arrCats);                                   //sort by catCount

            ArrayList maincats = dcLoader.GetDocCategories(docId); //relevant cats

            Hashtable result          = new Hashtable();
            int       numberOfTopCats = Math.Min(c, arrCats.Length);

            for (int i = 0; i < numberOfTopCats; i++)
            {
                result.Add(arrCats[i].catId, true);
            }

            return(result);
        }
Пример #5
0
            public int CompareTo(object o)
            {
                CategoryCount cc2 = (CategoryCount)o;

                if (catCount > cc2.catCount)
                {
                    return(-1);
                }
                else if (catCount < cc2.catCount)
                {
                    return(1);
                }
                else
                {
                    return(0);
                }
            }
Пример #6
0
    protected void rptCategories_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
        {
            CategoryCount cc = (CategoryCount)e.Item.DataItem;

            HyperLink a = (HyperLink)e.Item.FindControl("parentCategory");

            if (cc.Count != 0)
            {
                a.NavigateUrl = "javascript:categoryselect('" + cc.ID + "')";
                a.Text        = cc.Name + " (" + cc.Count + ")";
            }
            else
            {
                a.Attributes.Add("style", "text-decoration: none;");
                a.Text = cc.Name;
            }

            List <CategoryCount> children = (List <CategoryCount>) cats.FindAll(
                delegate(CategoryCount c)
            {
                return(c.ParentId == cc.ID);
            });

            children.Sort(
                delegate(CategoryCount c, CategoryCount c1)
            {
                return(c.Name.CompareTo(c1.Name));
            });

            if (children != null && children.Count > 0)
            {
                Repeater c = (Repeater)e.Item.FindControl("rptCategoriesNested");
                c.ItemDataBound += new RepeaterItemEventHandler(rptCategoriesNested_ItemDataBound);
                c.DataSource     = children;
                c.DataBind();

                currentChildIndex = 0;
            }
        }
    }