Beispiel #1
0
 public void SetReportVisitor(ReportVisitor visitor)
 {
     if (visitor != null)
     {
         this.visitor = visitor;
     }
 }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="visitor"></param>
        public void RetrieveData(ReportVisitor visitor)
        {
            reportingContext.TraceLogger.LogInformation("Start Retrieving Data For Report {0}", this.reportType.Name);

            QueryFilter queryFilter = new QueryFilter();

            queryFilter.QueryRange.StartDate = this.reportingContext.FromDateTime;
            queryFilter.QueryRange.EndDate   = this.reportingContext.ToDateTime;
            queryFilter.CustomFilter         = this.reportingContext.DataFilter;

            StreamProgress progress = new StreamProgress(this.progressFilePath, this.streamIdentifier);

            progress = progress.GetProgress();

            DateTime progressTimestamp = progress.TimeStamp;

            if (queryFilter.QueryRange.StartDate < progressTimestamp)
            {
                queryFilter.QueryRange.StartDate = progressTimestamp;
            }

            queryFilter.ExcludeStartItem = progress.ExcludeStartItem;

            int totalCount = RetrieveData(visitor, queryFilter);

            reportingContext.TraceLogger.LogInformation("Retrieve Data Completed. Totally [{0}] of Data Retrieved.", totalCount);
        }
Beispiel #3
0
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="TReport"></typeparam>
        /// <param name="nodes"></param>
        /// <param name="visitor"></param>
        /// <returns></returns>
        private List <ReportObject> VisitXmlNodes(List <XmlNode> nodes, ReportVisitor 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);
        }
Beispiel #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="visitor"></param>
        /// <returns>The count of data returned</returns>
        private int RetrieveData(ReportVisitor 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 = ResultPageSize;
            }

            List <XmlNode> resultNodes = reportProvider.GetResponseXml(this.reportType, filter);

            if (resultNodes.Count >= 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 += ResultPageSize;
                        subResult         = RetrieveData(visitor, filter);
                        totalResultCount += subResult;
                    } while (subResult >= 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);
        }