标签:过滤 大于 rgb ESS one string request 条件查询 amp
一、举例:在物流币点击记录里面查询出 同一IP,同一条线路,同一页面,四小时内点击次数
思路:1、根据当前查询的时间将时间回退到四小时前,然后将四小时前的时间转换为时间戳,然后组合其它条件查询 出大于对应时间戳的所有记录数。
string TheTimeStamp = TimeHelper.GetTimeStamp(requestTime.AddHours(-4));
2、构建查询过滤器
var filterBuilder = Builders<PageColllection>.Filter; var filter = filterBuilder.Eq(p => p.PXID, wid) & filterBuilder.Eq(p => p.ip, ip) & filterBuilder.Gte(p => p.unixTime, unixtemp) & filterBuilder.Eq(p => p.state, 1) & filterBuilder.Eq(p => p.URL, url);
方法如下所示:
public long AntiEvilclickRuleOne(string ip, int wid, DateTime requestTime, string url) { try { long result = 0; long unixtemp = 0; string TheTimeStamp = TimeHelper.GetTimeStamp(requestTime.AddHours(-4)); if (!long.TryParse(TheTimeStamp, out unixtemp)) { return 0; } var filterBuilder = Builders<PageColllection>.Filter; var filter = filterBuilder.Eq(p => p.PXID, wid) & filterBuilder.Eq(p => p.ip, ip) & filterBuilder.Gte(p => p.unixTime, unixtemp) & filterBuilder.Eq(p => p.state, 1) & filterBuilder.Eq(p => p.URL, url);
result = MongoDbHelper.GetDb().GetCollection<PageColllection>("PageColllection").Find(filter).CountDocuments(); return result; } catch (Exception ex) { AddLog.addLog_db("PageColllectionBLL.CheckRecordsByMemberIDLineID异常", ex.Message); return 0; } }
标签:过滤 大于 rgb ESS one string request 条件查询 amp
原文地址:https://www.cnblogs.com/Learnall/p/14343445.html