public static List <ResourceCount> MonthlyVisitors(SiteDb sitedb) { var allweeks = sitedb.LogWeekNames(); var lastfour = allweeks.OrderByDescending(o => o).Take(4); List <ResourceCount> monthly = new List <ResourceCount>(); List <VisitorLog> logs = new List <VisitorLog>(); foreach (var item in lastfour) { logs.AddRange(GetLogs(sitedb, item)); } var groupby = logs.GroupBy(o => GetDayString(o.Begin)); foreach (var item in groupby) { ResourceCount resouce = new ResourceCount(); resouce.Name = item.Key; resouce.Count = item.Count(); monthly.Add(resouce); } return(monthly.OrderBy(o => o.Name).ToList()); }
public static List <ResourceCount> TopImages(SiteDb sitedb, string WeekName = null) { List <ResourceCount> imagecounts = new List <ResourceCount>(); var logs = GetImageLogs(sitedb, WeekName); foreach (var item in logs.GroupBy(o => o.Url, StringComparer.OrdinalIgnoreCase)) { string url = item.Key; if (!string.IsNullOrEmpty(url)) { ResourceCount count = new ResourceCount(); count.Name = url; count.Count = item.Count(); count.Size = item.First().Size; imagecounts.Add(count); } } return(imagecounts.OrderByDescending(o => o.Count).ToList()); }
public static List <ResourceCount> TopReferers(SiteDb sitedb, string weekname = null) { var sitebindings = Kooboo.Data.GlobalDb.Bindings.GetByWebSite(sitedb.WebSite.Id); List <string> ownnames = new List <string>(); foreach (var item in sitebindings) { ownnames.Add(item.FullName); } List <string> domainlist = new List <string>(); var logs = GetLogs(sitedb, weekname); foreach (var item in logs) { if (!string.IsNullOrEmpty(item.Referer)) { string host = Kooboo.Lib.Helper.UrlHelper.UriHost(item.Referer, true); if (!string.IsNullOrEmpty(host)) { if (!ownnames.Contains(host, StringComparer.OrdinalIgnoreCase)) { domainlist.Add(item.Referer); } } } } List <ResourceCount> referercount = new List <ResourceCount>(); foreach (var item in domainlist.GroupBy(o => o)) { ResourceCount count = new ResourceCount(); count.Name = item.Key; count.Count = item.Count(); referercount.Add(count); } return(referercount.OrderByDescending(o => o.Count).ToList()); }
public static List <ResourceCount> TopPages(SiteDb sitedb, string WeekName = null) { List <ResourceCount> pagecountes = new List <ResourceCount>(); var logs = GetLogs(sitedb, WeekName); foreach (var item in logs.GroupBy(o => o.ObjectId)) { var objectid = item.Key; var page = sitedb.Pages.Get(objectid, true); if (page != null) { ResourceCount count = new ResourceCount(); var pageurl = ObjectService.GetObjectRelativeUrl(sitedb, objectid, ConstObjectType.Page); count.Name = pageurl; count.Count = item.Count(); count.Size = item.First().Size; pagecountes.Add(count); } } return(pagecountes.OrderByDescending(o => o.Count).ToList()); }