/// <summary> /// /// </summary> /// <typeparam name="TReport"></typeparam> /// <param name="nodes"></param> /// <param name="visitor"></param> /// <returns></returns> private List <ReportObject> VisitXmlNodes(List <XmlNode> nodes, IReportVisitor visitor) { List <ReportObject> list = new List <ReportObject>(); DateTime lastTimeStamp = DateTime.MinValue; visitor.Reset(); foreach (XmlNode node in nodes) { ReportObject report = (ReportObject)Activator.CreateInstance(this.reportType); report.LoadFromXml(node); list.Add(report); visitor.AddReportToBatch(report); lastTimeStamp = (lastTimeStamp < report.Date) ? report.Date : lastTimeStamp; } visitor.VisitBatchReport(); StreamProgress progress = new StreamProgress(this.progressFilePath, streamIdentifier, lastTimeStamp, true); progress.SaveProgress(); return(list); }
/// <summary> /// /// </summary> /// <param name="visitor"></param> /// <returns>The count of data returned</returns> private int RetrieveData(IReportVisitor visitor, QueryFilter filter) { int totalResultCount = 0; //If the TopCount is 0, then it was not specified, hence we take the constant value if (filter.TopCount == 0) { filter.TopCount = Constants.ResultPageSize; } List <XmlNode> resultNodes = reportProvider.GetResponseXml(this.reportType, filter); if (resultNodes.Count >= Constants.ResultPageSize && filter.SkipCount == 0) { reportingContext.TraceLogger.LogInformation("Result is exceeding limit, dividing the range."); List <QueryRange> subRangeList = filter.QueryRange.GetDividedRanges(); if (subRangeList != null && subRangeList.Count > 0) { foreach (QueryRange range in subRangeList) { filter.QueryRange = range; totalResultCount += RetrieveData(visitor, filter); } } else { VisitXmlNodes(resultNodes, visitor); totalResultCount = resultNodes.Count; reportingContext.TraceLogger.LogInformation(string.Format("Retrieved [{0}] rows of data...", totalResultCount)); reportingContext.TraceLogger.LogInformation("Divided range is null, using Skips."); int subResult; filter.SkipCount = 0; do { filter.SkipCount += Constants.ResultPageSize; subResult = RetrieveData(visitor, filter); totalResultCount += subResult; } while (subResult >= Constants.ResultPageSize); filter.SkipCount = 0; } } else { VisitXmlNodes(resultNodes, visitor); totalResultCount = resultNodes.Count; reportingContext.TraceLogger.LogInformation(string.Format("Retrieved [{0}] rows of data...", resultNodes.Count)); } StreamProgress progress = new StreamProgress(this.progressFilePath, streamIdentifier, filter.QueryRange.EndDate, false); progress.SaveProgress(); return(totalResultCount); }