/// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">multiple report data</param> /// <exception cref="ArgumentException">Need at least two ReportData objects</exception> public MultipleReportPaginator(ReportDocument report, IEnumerable<ReportData> data) { if (data == null) throw new ArgumentException("Need at least two ReportData objects"); // create a list of report paginators and compute page counts _pageCount = 0; int dataCount = 0; int totalPages = 0; foreach (ReportData rd in data) { if (rd == null) continue; ReportPaginator temp = new ReportPaginator(report, rd); DocumentPage dp = temp.GetPage(0); totalPages += temp.PageCount; } foreach (ReportData rd in data) { if (rd == null) continue; ReportPaginator paginator = new ReportPaginator(report, rd); _reportPaginators.Add(paginator); paginator.PageShift = _pageCount; paginator.TotalPageCount = totalPages; DocumentPage dp = paginator.GetPage(0); if ((dp != DocumentPage.Missing) && (dp.Size != Size.Empty)) _pageSize = paginator.PageSize; _pageCount += paginator.PageCount; dataCount++; } if (_reportPaginators.Count <= 0) throw new ArgumentException("Need at least two ReportData objects"); }
/// <summary> /// Gets a document page of the appropriate generated report /// </summary> /// <param name="pageNumber">page number</param> /// <returns>parsed DocumentPage</returns> public override DocumentPage GetPage(int pageNumber) { // find the appropriate paginator for the page int currentPage = 0; ReportPaginator pagePaginator = null; foreach (ReportPaginator paginator in _reportPaginators) { int pageCount = paginator.PageCount; if (pageNumber >= currentPage + pageCount) { currentPage += pageCount; continue; } pagePaginator = paginator; break; } if (pagePaginator == null) { return(DocumentPage.Missing); } pagePaginator.PageShift = currentPage; pagePaginator.TotalPageCount = PageCount; DocumentPage dp = pagePaginator.GetPage(pageNumber - currentPage); if (dp == DocumentPage.Missing) { return(DocumentPage.Missing); } //_pageSize = dp.Size; return(dp); }
/// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">multiple report data</param> /// <exception cref="ArgumentException">Need at least two ReportData objects</exception> public MultipleReportPaginator(ReportDocument report, IEnumerable <ReportData> data) { if (data == null) { throw new ArgumentException("Need at least two ReportData objects"); } // create a list of report paginators and compute page counts _pageCount = 0; int dataCount = 0; foreach (ReportData rd in data) { if (rd == null) { continue; } ReportPaginator paginator = new ReportPaginator(report, rd); _reportPaginators.Add(paginator); DocumentPage dp = paginator.GetPage(0); if ((dp != DocumentPage.Missing) && (dp.Size != Size.Empty)) { _pageSize = paginator.PageSize; } _firstPages.Add(dp); // just cache the generated first page _pageCount += paginator.PageCount; dataCount++; } if ((_reportPaginators.Count <= 0) || (dataCount < 2)) { throw new ArgumentException("Need at least two ReportData objects"); } }
/// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">multiple report data</param> /// <exception cref="ArgumentException">Need at least two ReportData objects</exception> public MultipleReportPaginator(ReportDocument report, IEnumerable<ReportData> data) { using (var counter = new TimeCounter("\tMultipleReportPaginator Total: {0}", true, true)) { if (data == null) throw new ArgumentException("Need at least two ReportData objects"); // create a list of report paginators and compute page counts _pageCount = 0; foreach (ReportData rd in data) { if (rd == null) continue; ReportPaginator paginator = new ReportPaginator(report, rd); _reportPaginators.Add(paginator); paginator.PageShift = _pageCount; paginator.TotalPageCount = _pageCount; counter.ShowTick("\tMultipleReportPaginator Paginator: {0}"); DocumentPage dp = paginator.GetPage(0); if ((dp != DocumentPage.Missing) && (dp.Size != Size.Empty)) _pageSize = paginator.PageSize; _pageCount += paginator.PageCount; counter.ShowTick("\tMultipleReportPaginator PageCount: {0}"); } counter.ShowTick("\tMultipleReportPaginator Paginators: {0}"); foreach (ReportPaginator paginator in _reportPaginators) paginator.TotalPageCount = _pageCount; if (_reportPaginators.Count <= 0) throw new ArgumentException("Need at least two ReportData objects"); counter.ShowTick("\tMultipleReportPaginator PageCount: {0}"); } }
/// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">multiple report data</param> /// <exception cref="ArgumentException">Need at least two ReportData objects</exception> public MultipleReportPaginator(ReportDocument report, IEnumerable <ReportData> data) { if (data == null) { throw new ArgumentException("Need at least two ReportData objects"); } // create a list of report paginators and compute page counts _pageCount = 0; int dataCount = 0; int totalPages = 0; foreach (ReportData rd in data) { if (rd == null) { continue; } ReportPaginator temp = new ReportPaginator(report, rd); DocumentPage dp = temp.GetPage(0); totalPages += temp.PageCount; } foreach (ReportData rd in data) { if (rd == null) { continue; } ReportPaginator paginator = new ReportPaginator(report, rd); _reportPaginators.Add(paginator); paginator.PageShift = _pageCount; paginator.TotalPageCount = totalPages; DocumentPage dp = paginator.GetPage(0); if ((dp != DocumentPage.Missing) && (dp.Size != Size.Empty)) { _pageSize = paginator.PageSize; } _pageCount += paginator.PageCount; dataCount++; } if (_reportPaginators.Count <= 0) { throw new ArgumentException("Need at least two ReportData objects"); } }
/// <summary> /// Constructor /// </summary> /// <param name="report">report document</param> /// <param name="data">multiple report data</param> /// <exception cref="ArgumentException">Need at least two ReportData objects</exception> public MultipleReportPaginator(ReportDocument report, IEnumerable<ReportData> data) { if (data == null) throw new ArgumentException("Need at least two ReportData objects"); // create a list of report paginators and compute page counts _pageCount = 0; int dataCount = 0; foreach (ReportData rd in data) { if (rd == null) continue; ReportPaginator paginator = new ReportPaginator(report, rd); _reportPaginators.Add(paginator); DocumentPage dp = paginator.GetPage(0); if ((dp != DocumentPage.Missing) && (dp.Size != Size.Empty)) _pageSize = paginator.PageSize; _firstPages.Add(dp); // just cache the generated first page _pageCount += paginator.PageCount; dataCount++; } if ((_reportPaginators.Count <= 0) || (dataCount < 2)) throw new ArgumentException("Need at least two ReportData objects"); }
/// <summary> /// Gets a document page of the appropriate generated report /// </summary> /// <param name="pageNumber">page number</param> /// <returns>parsed DocumentPage</returns> public override DocumentPage GetPage(int pageNumber) { // find the appropriate paginator for the page int currentPage = 0; int paginatorIndex = 0; ReportPaginator pagePaginator = null; foreach (ReportPaginator paginator in _reportPaginators) { int pageCount = paginator.PageCount; if (pageNumber >= currentPage + pageCount) { currentPage += pageCount; paginatorIndex++; continue; } pagePaginator = paginator; break; } if (pagePaginator == null) { return(DocumentPage.Missing); } DocumentPage dp = null; if (pageNumber == 0) { dp = _firstPages[paginatorIndex]; } else { dp = pagePaginator.GetPage(pageNumber - currentPage); } if (dp == DocumentPage.Missing) { return(DocumentPage.Missing); } _pageSize = dp.Size; return(dp); }