2023-12-01 08:57:19 +01:00

31 lines
982 B
VB.net

Imports System.IO
Imports DevExpress.XtraPrinting
Public Class ReportCreator
Private Envelope As Envelope
Public Sub New(pEnvelope As Envelope)
Envelope = pEnvelope
End Sub
Public Async Function CreateReport(pReportItems As List(Of ReportItem)) As Task(Of Byte())
Dim oItems = pReportItems.Select(AddressOf MergeEnvelope).ToList()
Dim oSource As New ReportSource With {.Items = oItems}
Dim oReport As New rptEnvelopeHistory() With {.DataSource = oSource, .DataMember = "Items"}
Await oReport.CreateDocumentAsync()
Using oStream As New MemoryStream()
Await oReport.ExportToPdfAsync(oStream, New PdfExportOptions)
Return oStream.ToArray()
End Using
End Function
Private Function MergeEnvelope(pItem As ReportItem) As ReportItem
If pItem.Envelope Is Nothing Then
pItem.Envelope = Envelope
End If
Return pItem
End Function
End Class