Example #1
0
        private void PopulateViewedArticles(string sort)
        {
            List <Tuple <string, double> > articles = RatingHelper.GetUserRatings(userID);

            DataTable dt = new DataTable();

            dt.Columns.Add("Article");
            dt.Columns.Add("Rating", System.Type.GetType("System.Double"));

            foreach (Tuple <string, double> a in articles)
            {
                DataRow dr = dt.NewRow();
                //encode
                if (a.Item1.Length > Settings.Default.TruncateArticleLength)
                {
                    dr["Article"] = Server.HtmlEncode(a.Item1.Substring(0, Settings.Default.TruncateArticleLength - 3)) + "...";
                }
                else
                {
                    dr["Article"] = Server.HtmlEncode(a.Item1);
                }
                dr["Rating"] = a.Item2;

                dt.Rows.Add(dr);
            }
            dt.DefaultView.Sort        = sort;
            RatingsListView.DataSource = dt.DefaultView;
            RatingsListView.DataBind();
        }
Example #2
0
        protected void filter_Click(object sender, EventArgs e)
        {
            double lowerBound = 0;
            double upperBound = 0;

            if (!double.TryParse(lowerBoundBox.Text, out lowerBound))
            {
                lowerBound = Settings.Default.defaultLowerBound;
            }
            if (!double.TryParse(upperBoundBox.Text, out upperBound))
            {
                upperBound = Settings.Default.defaultUpperBound;
            }

            DataTable dt = GenerateTable(isLoggedIn, userID, lowerBound, upperBound);

            dt.DefaultView.Sort        = "Rating DESC";
            RatingsListView.DataSource = dt.DefaultView;
            RatingsListView.DataBind();
        }
Example #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            //we've never seen this user before or they've cleared their cookies
            if (Request.Cookies["session"] != null && Guid.TryParse(Request.Cookies["session"].Value, out session))
            {
                userID = Auth.checkSession(session);
                if (userID > 0)
                {
                    isLoggedIn = true;
                }
            }

            if (!Page.IsPostBack)
            {
                DataTable dt = GenerateTable(isLoggedIn, userID, Settings.Default.defaultLowerBound, Settings.Default.defaultUpperBound);
                dt.DefaultView.Sort        = "Rating DESC";
                RatingsListView.DataSource = dt.DefaultView;
                RatingsListView.DataBind();
            }
        }