示例#1
0
        /// <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)
		{
			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");
            }
        }
示例#5
0
        public FlowDocument CreateFlowDocument(ReportData data, Action <int, int> PageGeneratedCallBack = null)
        {
            MemoryStream ms   = new MemoryStream();
            Package      pkg  = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
            string       pack = String.Format("pack://report{0}.xps", this.ReportName);

            PackageStore.RemovePackage(new Uri(pack));
            PackageStore.AddPackage(new Uri(pack), pkg);
            XpsDocument             doc  = new XpsDocument(pkg, CompressionOption.NotCompressed, pack);
            XpsSerializationManager rsm  = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);
            var             flowDocument = this.CreateFlowDocument();
            ReportPaginator rp           = new ReportPaginator(this, data, PageGeneratedCallBack, flowDocument);

            return(flowDocument);
        }
        /// <summary>
        /// Helper method to create page header or footer from flow document template
        /// </summary>
        /// <param name="data">report data</param>
        /// <returns></returns>
        public XpsDocument CreateXpsDocument(ReportData data)
        {
            MemoryStream ms   = new MemoryStream();
            Package      pkg  = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
            string       pack = "pack://report.xps";

            PackageStore.RemovePackage(new Uri(pack));
            PackageStore.AddPackage(new Uri(pack), pkg);
            XpsDocument             doc = new XpsDocument(pkg, CompressionOption.NotCompressed, pack);
            XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);

            ReportPaginator rp = new ReportPaginator(this, data);

            rsm.SaveAsXaml(rp);
            return(doc);
        }
        /// <summary>
        /// Helper method to create page header or footer from flow document template
        /// </summary>
        /// <param name="data">report data</param>
        /// <param name="fileName">file to save XPS to</param>
        /// <returns></returns>
        public XpsDocument CreateXpsDocument(ReportData data, string fileName)
        {
            Package pkg  = Package.Open(fileName, FileMode.Create, FileAccess.ReadWrite);
            string  pack = "pack://report.xps";

            PackageStore.RemovePackage(new Uri(pack));
            PackageStore.AddPackage(new Uri(pack), pkg);
            XpsDocument             doc = new XpsDocument(pkg, _xpsCompressionOption, pack);
            XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);

            ReportPaginator rp = new ReportPaginator(this, data);

            rsm.SaveAsXaml(rp);
            rsm.Commit();
            pkg.Close();
            return(new XpsDocument(fileName, FileAccess.Read));
        }
示例#8
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);
        }
示例#11
0
        /// <summary>
        /// Helper method to create page header or footer from flow document template
        /// </summary>
        /// <param name="data">report data</param>
        /// <returns></returns>
        public XpsDocument CreateXpsDocument(ReportData data, Action <int, int> PageGeneratedCallBack = null)
        {
            MemoryStream ms   = new MemoryStream();
            Package      pkg  = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
            string       pack = String.Format("pack://report{0}.xps", this.ReportName);

            PackageStore.RemovePackage(new Uri(pack));
            PackageStore.AddPackage(new Uri(pack), pkg);
            XpsDocument             doc = new XpsDocument(pkg, CompressionOption.NotCompressed, pack);
            XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);
            //DocumentPaginator paginator = ((IDocumentPaginatorSource)CreateFlowDocument()).DocumentPaginator;

            ReportPaginator rp = new ReportPaginator(this, data, PageGeneratedCallBack);

            rsm.SaveAsXaml(rp);

            rsm.Commit();
            //pkg.Close();

            return(doc);
        }
        public FlowDocument CreateFlowDocument(ReportData data, Action<int, int> PageGeneratedCallBack = null)
        {
            MemoryStream ms = new MemoryStream();
            Package pkg = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
            string pack = String.Format("pack://report{0}.xps", this.ReportName);
            PackageStore.RemovePackage(new Uri(pack));
            PackageStore.AddPackage(new Uri(pack), pkg);
            XpsDocument doc = new XpsDocument(pkg, CompressionOption.NotCompressed, pack);
            XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);
            var flowDocument = this.CreateFlowDocument();
            ReportPaginator rp = new ReportPaginator(this, data, PageGeneratedCallBack, flowDocument);

            return flowDocument;
        }
示例#13
0
		/// <summary>
		/// Helper method to create page header or footer from flow document template
		/// </summary>
		/// <param name="data">report data</param>
		/// <param name="fileName">file to save XPS to</param>
		/// <returns></returns>
		public XpsDocument CreateXpsDocument(ReportData data, string fileName)
		{
			Package pkg = Package.Open(fileName, FileMode.Create, FileAccess.ReadWrite);
			string pack = "pack://report.xps";
			PackageStore.RemovePackage(new Uri(pack));
			PackageStore.AddPackage(new Uri(pack), pkg);
			XpsDocument doc = new XpsDocument(pkg, _xpsCompressionOption, pack);
			XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);
			//DocumentPaginator paginator = ((IDocumentPaginatorSource)CreateFlowDocument()).DocumentPaginator;

			ReportPaginator rp = new ReportPaginator(this, data);
			rsm.SaveAsXaml(rp);
			rsm.Commit();
			pkg.Close();
			return new XpsDocument(fileName, FileAccess.Read);
		}
示例#14
0
		/// <summary>
		/// Helper method to create page header or footer from flow document template
		/// </summary>
		/// <param name="data">report data</param>
		/// <returns></returns>
		public XpsDocument CreateXpsDocument(ReportData data)
		{
			MemoryStream ms = new MemoryStream();
			Package pkg = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
			string pack = "pack://report.xps";
			PackageStore.RemovePackage(new Uri(pack));
			PackageStore.AddPackage(new Uri(pack), pkg);
			XpsDocument doc = new XpsDocument(pkg, CompressionOption.NotCompressed, pack);
			XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);
			//DocumentPaginator paginator = ((IDocumentPaginatorSource)CreateFlowDocument()).DocumentPaginator;

			ReportPaginator rp = new ReportPaginator(this, data);
			rsm.SaveAsXaml(rp);
			return doc;
		}
 /// <summary>
 /// Helper method to create page header or footer from flow document template
 /// </summary>
 /// <param name="data">report data</param>
 /// <returns></returns>
 public ReportPaginator CreatePaginator(ReportData data, Action<int, int> PageGeneratedCallBack = null)
 {
     ReportPaginator rp = new ReportPaginator(this, data, PageGeneratedCallBack);
    
     return rp;
 }
        /// <summary>
        /// Helper method to create page header or footer from flow document template
        /// </summary>
        /// <param name="data">report data</param>
        /// <returns></returns>
        public XpsDocument CreateXpsDocument(ReportData data, Action<int,int> PageGeneratedCallBack = null)
        {
            MemoryStream ms = new MemoryStream();
            Package pkg = Package.Open(ms, FileMode.Create, FileAccess.ReadWrite);
            string pack = String.Format("pack://report{0}.xps", this.ReportName);
            PackageStore.RemovePackage(new Uri(pack));
            PackageStore.AddPackage(new Uri(pack), pkg);
            XpsDocument doc = new XpsDocument(pkg, CompressionOption.NotCompressed, pack);
            XpsSerializationManager rsm = new XpsSerializationManager(new XpsPackagingPolicy(doc), false);
            //DocumentPaginator paginator = ((IDocumentPaginatorSource)CreateFlowDocument()).DocumentPaginator;
            
            ReportPaginator rp = new ReportPaginator(this, data, PageGeneratedCallBack);
            rsm.SaveAsXaml(rp);
            
            rsm.Commit();
            //pkg.Close();

            return doc;
        }
示例#17
0
        /// <summary>
        /// Helper method to create page header or footer from flow document template
        /// </summary>
        /// <param name="data">report data</param>
        /// <returns></returns>
        public ReportPaginator CreatePaginator(ReportData data, Action <int, int> PageGeneratedCallBack = null)
        {
            ReportPaginator rp = new ReportPaginator(this, data, PageGeneratedCallBack);

            return(rp);
        }