public LogDataItemCollection GetReferrerLog(DateTime date) { return(BlogXUtils.GetReferrerLog(date)); }
private void WebForm1_PreRender(object sender, System.EventArgs e) { Control root = content; SiteConfig config = SiteConfig.GetSiteConfig(); string siteRoot = config.Root.ToUpper(); Hashtable data = new Hashtable(); foreach (LogDataItem log in BlogXUtils.GetReferrerLog(DateTime.Now)) { bool exclude = false; if (log.UrlReferrer != null) { exclude = log.UrlReferrer.ToUpper().StartsWith(siteRoot); } if (!exclude) { if (!data.Contains(log.UrlReferrer)) { data[log.UrlReferrer] = 0; } data[log.UrlReferrer] = ((int)data[log.UrlReferrer]) + 1; } } ArrayList list = new ArrayList(data.Count); foreach (DictionaryEntry de in data) { list.Add(new RefItem(de.Key.ToString(), (int)de.Value)); } list.Sort(new RefItem.Comparer()); int total = 0; Table table = new Table(); foreach (RefItem item in list) { TableRow row = new TableRow(); row.Cells.Add(new TableCell()); row.Cells.Add(new TableCell()); HyperLink link = new HyperLink(); string text = item.url; if (text != null && text.Length > 0) { if (text.Length > 40) { text = text.Substring(0, 40) + "..."; } } else { text = "(none)"; } link.Text = text; link.NavigateUrl = item.url.ToString(); row.Cells[0].Controls.Add(link); row.Cells[1].Text = item.count.ToString(); total += item.count; table.Rows.Add(row); } TableRow totalRow = new TableRow(); totalRow.Cells.Add(new TableCell()); totalRow.Cells.Add(new TableCell()); totalRow.Cells[0].Text = "Total"; totalRow.Cells[1].Text = total.ToString(); table.Rows.Add(totalRow); root.Controls.Add(table); }