/// <summary> /// 更新冗余字段 /// </summary> public int FreshSumData(DateTime startTime) { Criteria c = new Criteria(CriteriaType.MoreThanEquals, "VisitDate", startTime); List <PageVisitorHistory> list = GetPageVisitores(c); int count = 0; foreach (PageVisitorHistory s in list) { bool needUpdate = false; if (s.Clicks <= 1) { s.Clicks = GetStatisticsCount(s.ID); if (s.Clicks > 1) { needUpdate = true; } } s.PageView = s.Clicks; if (s.City == "" || s.City == null) { string[] parts = We7Helper.GetCityNameByIP(s.VisitorIP).Split(' '); if (parts.Length > 0) { s.Province = parts[0]; } if (parts.Length > 1) { s.City = parts[1]; } needUpdate = true; } if (s.FromSite == "" || s.FromSite == null) { s.FromSite = We7Helper.GetDomainFromUrl(s.HttpReferer); needUpdate = true; } if (s.VisitDate == s.LogoutDate) { s.LogoutDate = GetLogoutDate(s.ID); s.OnlineTime = s.LogoutDate; needUpdate = true; } if (needUpdate) { try { UpdatePageVisitor(s, new string[] { "City", "Province", "FromSite", "Clicks", "LogoutDate", "OnlineTime" }); } finally { count += 1; } } } return(count); }
public void FreshSumData(DateTime startTime) { Criteria c = new Criteria(CriteriaType.MoreThanEquals, "VisitDate", startTime); List <PageVisitorHistory> list = GetPageVisitors(c); int count = 0; foreach (PageVisitorHistory pvh in list) { bool needUpdate = false; if (pvh.Clicks <= 1) { pvh.Clicks = GetStatisticsCount(pvh.ID); if (pvh.Clicks > 1) { needUpdate = true; } } pvh.PageView = pvh.Clicks; if (string.IsNullOrEmpty(pvh.City)) { string[] parts = We7Helper.GetCityNameByIP(pvh.VisitorIP).Split(' '); if (parts.Length > 0) { pvh.Province = parts[0]; } if (parts.Length > 1) { pvh.City = parts[1]; } needUpdate = true; } if (string.IsNullOrEmpty(pvh.FromSite)) { pvh.FromSite = We7Helper.GetDomainFromUrl(pvh.HttpReferer); needUpdate = true; } if (pvh.VisitDate == pvh.LogoutDate) { pvh.LogoutDate = GetLogoutDate(pvh.ID); pvh.OnlineTime = pvh.LogoutDate; needUpdate = true; } if (needUpdate) { try { UpdatePageVisitor(pvh, new string[] { "City", "Province", "FromSite", "Clicks", "LogoutDate", "OnlineTime" }); } finally { count += 1; } } } }