public async Task firstVisit([FromUri] FirstVisitModel model) { AnalysisColect colect = new AnalysisColect() { BColor = model.bColor, BFlash = model.bFlash, BHl = model.bHl, BJava = model.bJava, BOS = model.bOS, BScr = model.bScr, BType = model.bType, BVersion = model.bVersion, City = model.city, Country = model.country, GUID = model.GUID, IP = model.ip, IsFirst = true, KeyWord = model.keyWord, ProjectId = model.id, Province = model.province, ReferrerUrl = model.urr, URP = model.urp, URPV = model.urpv, Stay = model.st }; _app.Insert(colect); }
public async Task Insert(AnalysisColect model) { Task.Run(() => { var date = DateTime.Now; //查询出当天的统计数据 var total = _analysisTotalRepository.FindEntity(a => a.ProjectId == model.ProjectId && a.Day.Year == date.Year && a.Day.Month == date.Month && a.Day.Day == date.Day); if (total != null) { //PV添加1 total.PV += 1; //UV 判断GUID相同 当天有没有记录 var guid = _server.FindEntity(a => a.ProjectId == model.ProjectId && a.Day.Year == date.Year && a.Day.Month == date.Month && a.Day.Day == date.Day && a.GUID == model.GUID); if (guid == null) { total.UV += 1; } //IP 判断IP相同 当天有没有记录 var ip = _server.FindEntity(a => a.ProjectId == model.ProjectId && a.Day.Year == date.Year && a.Day.Month == date.Month && a.Day.Day == date.Day && a.IP == model.IP); if (ip == null) { total.IP += 1; } if (total.PV != 0 && total.UV != 0) { total.CTR = ((double)total.UV * 100 / (double)total.PV).ToDecimal(2); } _analysisTotalRepository.Update(total); } else { //若是没有则插入 _analysisTotalRepository.Insert(new AnalysisTotal() { ProjectId = model.ProjectId, IP = 1, UV = 1, PV = 1 }); } //添加纪录 _server.Insert(model); }); }
public void pageView([FromUri] PageViewModel model) { AnalysisColect colect = new AnalysisColect() { City = model.city, Country = model.country, GUID = model.GUID, IP = model.ip, IsFirst = false, ProjectId = model.id, Province = model.province, ReferrerUrl = model.urr, URP = model.urp, RequestUrl = model.cur, Title = model.title, Stay = model.st }; _app.Insert(colect); }