private void CreateActiveReportZoneTesting(ZoneEntity zone, DateTime date) { string title = date.ToString("MM/dd/yyyy HH"); string zoneId = zone.ZoneId; var list = ActionReportBusiness.GetListByTitle(title); if (list != null && list.Count(a => a.ZoneId == zoneId) > 0) { //如果本时段的数据已经存在则不必重复生成 return; } //24个小时,取第一分钟的数据 List <List <CloudflareLog> > cloudflareLogs = new List <List <CloudflareLog> >(); for (int i = 0; i < oneDayCount; i++) { double sample = 1; DateTime startTime = Convert.ToDateTime(date.ToString(string.Format("yyyy-MM-dd HH:{0}:00", i.ToString("00")))); DateTime endTime = Convert.ToDateTime(date.ToString(string.Format("yyyy-MM-dd HH:{0}:00", (i + 1).ToString("00")))); string authEmail = zone.AuthEmail; string authKey = zone.AuthKey; string key = string.Format("{0}-{1}-{2}-{3}", startTime.ToString("yyyyMMddHHmmss"), endTime.ToString("yyyyMMddHHmmss"), sample, zoneId); List <CloudflareLog> logs = new List <CloudflareLog>(); ICloudflareLogHandleSercie cloudflareLogHandleSercie = new CloudflareLogHandleSercie(zoneId, authEmail, authKey, sample, startTime, endTime, true); cloudflareLogHandleSercie.TaskStart(); logs = cloudflareLogHandleSercie.GetCloudflareLogs(key) .Where(a => !IfInSuffixList(a.ClientRequestURI)).ToList(); if (logs == null || logs.Count == 0) { logs = new List <CloudflareLog> { new CloudflareLog { ClientRequestHost = "www.comm100.com", ClientIP = "203.177.237.253", ClientRequestURI = "/visitor.ashx?siteId=1000325&visitorGuid=LKsJf9nGBk6RX2Ogk6bW1A" }, new CloudflareLog { ClientRequestHost = "www.comm100.com", ClientIP = "203.177.237.253", ClientRequestURI = "/VISITOR.ashx?siteId=1000325&visitorGuid=LKsJf9nGBk6RX2Ogk6bW1A" }, }; } cloudflareLogs.Add(logs); logService.Debug(key); } //为了防止异常导致之前已经存储进去的数据重复,先删除对应的数据 ActionReportBusiness.Delete(zoneId, title); GeneratedActiveReport(title, zone, cloudflareLogs); GeneratedWhiteListReport(title, zone, cloudflareLogs); }
private void CreateActiveReportZoneProduction(ZoneEntity zone, DateTime date) { string title = date.ToString("MM/dd/yyyy"); string zoneId = zone.ZoneId; var list = ActionReportBusiness.GetListByTitle(title); if (list != null && list.Count(a => a.ZoneId == zoneId) > 0) { //如果本时段的数据已经存在则不必重复生成 return; } //24个小时,取第一分钟的数据 List <List <CloudflareLog> > cloudflareLogs = new List <List <CloudflareLog> >(); for (int i = 0; i < oneDayCount; i++) { double sample = 1; DateTime startTime = Convert.ToDateTime(date.ToString(string.Format("yyyy-MM-dd {0}:00:00", i.ToString("00")))); DateTime endTime = Convert.ToDateTime(date.ToString(string.Format("yyyy-MM-dd {0}:01:00", i.ToString("00")))); string authEmail = zone.AuthEmail; string authKey = zone.AuthKey; string key = string.Format("{0}-{1}-{2}-{3}", startTime.ToString("yyyyMMddHHmmss"), endTime.ToString("yyyyMMddHHmmss"), sample, zoneId); List <CloudflareLog> logs = new List <CloudflareLog>(); ICloudflareLogHandleSercie cloudflareLogHandleSercie = new CloudflareLogHandleSercie(zoneId, authEmail, authKey, sample, startTime, endTime, true); cloudflareLogHandleSercie.TaskStart(); logs = cloudflareLogHandleSercie.GetCloudflareLogs(key) .Where(a => !IfInSuffixList(a.ClientRequestURI)).ToList(); cloudflareLogs.Add(logs); logService.Debug(key); cloudflareLogHandleSercie.CleanDicCloudflareLogsToday(); //2020.7.13 清空当前缓存 } //为了防止异常导致之前已经存储进去的数据重复,先删除对应的数据 ActionReportBusiness.Delete(zoneId, title); GeneratedActiveReport(title, zone, cloudflareLogs); GeneratedWhiteListReport(title, zone, cloudflareLogs); }