Exemplo n.º 1
0
        private void GenerateVideoWeighting()
        {
            //get videos user hasn't watched yet

            foreach (DataRow dr in Unwatched.Rows)
            {
                int x = 0;
                if (Int32.TryParse(dr["VideoId"].ToString(), out x))
                {
                    DataTable dt = SQL.GetVideoTags(x);
                    //get tags of each video
                    VideoWeight vw = new VideoWeight(dr["VideoName"].ToString(), 0, 0, 0);
                    foreach (DataRow tdr in dt.Rows)
                    {
                        int y = 0;
                        if (Int32.TryParse(tdr["Tag_TagId"].ToString(), out y))
                        {
                            //get name from datarow
                            foreach (UserProfileListItem uli in UserProfileTagList)
                            {    // if tag ids match  0 = tagId
                                if (uli.Tag == y)
                                {
                                    vw.Weight += uli.Occurance;
                                }
                            }
                        }
                    }
                    VideoWeights.Add(vw);
                }
            }
        }
Exemplo n.º 2
0
        private void GenerateVideoMetrics()
        {
            //get all video records that user hasn't watched


            if (Unwatched.Rows.Count > 0)
            {
                foreach (DataRow dr in Unwatched.Rows)
                {
                    int awt = 0;
                    Int32.TryParse(dr["AverageWatchTime"].ToString(), out awt);

                    int pl = 0;
                    Int32.TryParse(dr["PercentageLiked"].ToString(), out pl);

                    VideoWeight vp = new VideoWeight(dr["VideoName"].ToString(), -1, -1, awt, pl);

                    vp.Metric = (vp.AverageWatchTime + (vp.PercentageLiked / 100)) / 60; //

                    RecommendedVideos.Add(vp);
                }
            }
            RecommendedVideos = RecommendedVideos.OrderByDescending(v => v.Metric).ToList();
        }