reportgedöns

This commit is contained in:
Jonathan Jenne 2023-12-01 08:57:19 +01:00
parent ca0c427908
commit 3ca992e043
5 changed files with 118 additions and 58 deletions

View File

@ -2,8 +2,15 @@
Imports DevExpress.XtraPrinting Imports DevExpress.XtraPrinting
Public Class ReportCreator Public Class ReportCreator
Public Shared Async Function CreateReport(pEnvelope As Envelope, pReportItems As List(Of ReportItem)) As Task(Of Byte()) Private Envelope As Envelope
Dim oSource As New ReportSource With {.Items = pReportItems, .Envelope = pEnvelope}
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"} Dim oReport As New rptEnvelopeHistory() With {.DataSource = oSource, .DataMember = "Items"}
Await oReport.CreateDocumentAsync() Await oReport.CreateDocumentAsync()
@ -13,4 +20,11 @@ Public Class ReportCreator
Return oStream.ToArray() Return oStream.ToArray()
End Using End Using
End Function 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 End Class

View File

@ -1,5 +1,6 @@
Public Class ReportItem Public Class ReportItem
Public Property Envelope As Envelope
Public Property EnvelopeId As Integer Public Property EnvelopeId As Integer
Public Property EnvelopeTitle As String Public Property EnvelopeTitle As String
Public Property EnvelopeSubject As String Public Property EnvelopeSubject As String

View File

@ -1,4 +1,3 @@
Public Class ReportSource Public Class ReportSource
Public Property Items As List(Of ReportItem) Public Property Items As List(Of ReportItem)
Public Property Envelope As Envelope
End Class End Class

View File

@ -22,17 +22,17 @@ Partial Public Class rptEnvelopeHistory
Me.components = New System.ComponentModel.Container() Me.components = New System.ComponentModel.Container()
Me.TopMargin = New DevExpress.XtraReports.UI.TopMarginBand() Me.TopMargin = New DevExpress.XtraReports.UI.TopMarginBand()
Me.BottomMargin = New DevExpress.XtraReports.UI.BottomMarginBand() Me.BottomMargin = New DevExpress.XtraReports.UI.BottomMarginBand()
Me.ReportHeader = New DevExpress.XtraReports.UI.ReportHeaderBand()
Me.GroupHeader1 = New DevExpress.XtraReports.UI.GroupHeaderBand()
Me.Detail = New DevExpress.XtraReports.UI.DetailBand()
Me.pageInfo1 = New DevExpress.XtraReports.UI.XRPageInfo() Me.pageInfo1 = New DevExpress.XtraReports.UI.XRPageInfo()
Me.pageInfo2 = New DevExpress.XtraReports.UI.XRPageInfo() Me.pageInfo2 = New DevExpress.XtraReports.UI.XRPageInfo()
Me.ReportHeader = New DevExpress.XtraReports.UI.ReportHeaderBand()
Me.label1 = New DevExpress.XtraReports.UI.XRLabel() Me.label1 = New DevExpress.XtraReports.UI.XRLabel()
Me.GroupHeader1 = New DevExpress.XtraReports.UI.GroupHeaderBand()
Me.table1 = New DevExpress.XtraReports.UI.XRTable() Me.table1 = New DevExpress.XtraReports.UI.XRTable()
Me.tableRow1 = New DevExpress.XtraReports.UI.XRTableRow() Me.tableRow1 = New DevExpress.XtraReports.UI.XRTableRow()
Me.tableCell1 = New DevExpress.XtraReports.UI.XRTableCell() Me.tableCell1 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell2 = New DevExpress.XtraReports.UI.XRTableCell() Me.tableCell2 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell3 = New DevExpress.XtraReports.UI.XRTableCell() Me.tableCell3 = New DevExpress.XtraReports.UI.XRTableCell()
Me.Detail = New DevExpress.XtraReports.UI.DetailBand()
Me.table2 = New DevExpress.XtraReports.UI.XRTable() Me.table2 = New DevExpress.XtraReports.UI.XRTable()
Me.tableRow2 = New DevExpress.XtraReports.UI.XRTableRow() Me.tableRow2 = New DevExpress.XtraReports.UI.XRTableRow()
Me.tableCell4 = New DevExpress.XtraReports.UI.XRTableCell() Me.tableCell4 = New DevExpress.XtraReports.UI.XRTableCell()
@ -43,8 +43,11 @@ Partial Public Class rptEnvelopeHistory
Me.DetailData1 = New DevExpress.XtraReports.UI.XRControlStyle() Me.DetailData1 = New DevExpress.XtraReports.UI.XRControlStyle()
Me.DetailData3_Odd = New DevExpress.XtraReports.UI.XRControlStyle() Me.DetailData3_Odd = New DevExpress.XtraReports.UI.XRControlStyle()
Me.PageInfo = New DevExpress.XtraReports.UI.XRControlStyle() Me.PageInfo = New DevExpress.XtraReports.UI.XRControlStyle()
Me.XrLabel1 = New DevExpress.XtraReports.UI.XRLabel() Me.XrLabel2 = New DevExpress.XtraReports.UI.XRLabel()
Me.XrLabel3 = New DevExpress.XtraReports.UI.XRLabel()
Me.ObjectDataSource1 = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource(Me.components) Me.ObjectDataSource1 = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource(Me.components)
Me.XrLabel4 = New DevExpress.XtraReports.UI.XRLabel()
Me.XrLabel1 = New DevExpress.XtraReports.UI.XRLabel()
CType(Me.table1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.table1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.table2, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.table2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.ObjectDataSource1, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.ObjectDataSource1, System.ComponentModel.ISupportInitialize).BeginInit()
@ -57,17 +60,47 @@ Partial Public Class rptEnvelopeHistory
' '
'BottomMargin 'BottomMargin
' '
Me.BottomMargin.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.pageInfo1, Me.pageInfo2}) Me.BottomMargin.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.XrLabel1, Me.pageInfo1, Me.pageInfo2})
Me.BottomMargin.Dpi = 254.0! Me.BottomMargin.Dpi = 254.0!
Me.BottomMargin.Name = "BottomMargin" Me.BottomMargin.Name = "BottomMargin"
' '
'pageInfo1
'
Me.pageInfo1.Dpi = 254.0!
Me.pageInfo1.LocationFloat = New DevExpress.Utils.PointFloat(0!, 0!)
Me.pageInfo1.Name = "pageInfo1"
Me.pageInfo1.PageInfo = DevExpress.XtraPrinting.PageInfo.DateTime
Me.pageInfo1.SizeF = New System.Drawing.SizeF(470.5625!, 58.0!)
Me.pageInfo1.StyleName = "PageInfo"
'
'pageInfo2
'
Me.pageInfo2.Dpi = 254.0!
Me.pageInfo2.LocationFloat = New DevExpress.Utils.PointFloat(1166.417!, 0!)
Me.pageInfo2.Name = "pageInfo2"
Me.pageInfo2.SizeF = New System.Drawing.SizeF(733.5833!, 58.0!)
Me.pageInfo2.StyleName = "PageInfo"
Me.pageInfo2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight
Me.pageInfo2.TextFormatString = "Seite {0} von {1}"
'
'ReportHeader 'ReportHeader
' '
Me.ReportHeader.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.XrLabel1, Me.label1}) Me.ReportHeader.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.XrLabel4, Me.XrLabel3, Me.XrLabel2, Me.label1})
Me.ReportHeader.Dpi = 254.0! Me.ReportHeader.Dpi = 254.0!
Me.ReportHeader.HeightF = 236.0459! Me.ReportHeader.HeightF = 293.2334!
Me.ReportHeader.Name = "ReportHeader" Me.ReportHeader.Name = "ReportHeader"
' '
'label1
'
Me.label1.Dpi = 254.0!
Me.label1.LocationFloat = New DevExpress.Utils.PointFloat(0!, 0!)
Me.label1.Name = "label1"
Me.label1.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 254.0!)
Me.label1.SizeF = New System.Drawing.SizeF(1900.0!, 61.4536!)
Me.label1.StyleName = "Title"
Me.label1.StylePriority.UsePadding = False
Me.label1.Text = "Signierungs Zertifikat"
'
'GroupHeader1 'GroupHeader1
' '
Me.GroupHeader1.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.table1}) Me.GroupHeader1.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.table1})
@ -76,42 +109,6 @@ Partial Public Class rptEnvelopeHistory
Me.GroupHeader1.HeightF = 71.12! Me.GroupHeader1.HeightF = 71.12!
Me.GroupHeader1.Name = "GroupHeader1" Me.GroupHeader1.Name = "GroupHeader1"
' '
'Detail
'
Me.Detail.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.table2})
Me.Detail.Dpi = 254.0!
Me.Detail.HeightF = 63.42!
Me.Detail.HierarchyPrintOptions.Indent = 50.8!
Me.Detail.Name = "Detail"
'
'pageInfo1
'
Me.pageInfo1.Dpi = 254.0!
Me.pageInfo1.LocationFloat = New DevExpress.Utils.PointFloat(0!, 0!)
Me.pageInfo1.Name = "pageInfo1"
Me.pageInfo1.PageInfo = DevExpress.XtraPrinting.PageInfo.DateTime
Me.pageInfo1.SizeF = New System.Drawing.SizeF(796.0!, 58.0!)
Me.pageInfo1.StyleName = "PageInfo"
'
'pageInfo2
'
Me.pageInfo2.Dpi = 254.0!
Me.pageInfo2.LocationFloat = New DevExpress.Utils.PointFloat(796.0!, 0!)
Me.pageInfo2.Name = "pageInfo2"
Me.pageInfo2.SizeF = New System.Drawing.SizeF(1104.0!, 58.0!)
Me.pageInfo2.StyleName = "PageInfo"
Me.pageInfo2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight
Me.pageInfo2.TextFormatString = "Seite {0} von {1}"
'
'label1
'
Me.label1.Dpi = 254.0!
Me.label1.LocationFloat = New DevExpress.Utils.PointFloat(0!, 0!)
Me.label1.Name = "label1"
Me.label1.SizeF = New System.Drawing.SizeF(1900.0!, 61.4536!)
Me.label1.StyleName = "Title"
Me.label1.Text = "Signierungs Zertifikat"
'
'table1 'table1
' '
Me.table1.Dpi = 254.0! Me.table1.Dpi = 254.0!
@ -153,6 +150,14 @@ Partial Public Class rptEnvelopeHistory
Me.tableCell3.Text = "Datum" Me.tableCell3.Text = "Datum"
Me.tableCell3.Weight = 0.25860160582871317R Me.tableCell3.Weight = 0.25860160582871317R
' '
'Detail
'
Me.Detail.Controls.AddRange(New DevExpress.XtraReports.UI.XRControl() {Me.table2})
Me.Detail.Dpi = 254.0!
Me.Detail.HeightF = 63.42!
Me.Detail.HierarchyPrintOptions.Indent = 50.8!
Me.Detail.Name = "Detail"
'
'table2 'table2
' '
Me.table2.Dpi = 254.0! Me.table2.Dpi = 254.0!
@ -248,16 +253,29 @@ Partial Public Class rptEnvelopeHistory
Me.PageInfo.Name = "PageInfo" Me.PageInfo.Name = "PageInfo"
Me.PageInfo.Padding = New DevExpress.XtraPrinting.PaddingInfo(15, 15, 0, 0, 254.0!) Me.PageInfo.Padding = New DevExpress.XtraPrinting.PaddingInfo(15, 15, 0, 0, 254.0!)
' '
'XrLabel1 'XrLabel2
' '
Me.XrLabel1.Dpi = 254.0! Me.XrLabel2.Dpi = 254.0!
Me.XrLabel1.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[EnvelopeSubject]")}) Me.XrLabel2.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Envelope].[User].[FullName]")})
Me.XrLabel1.LocationFloat = New DevExpress.Utils.PointFloat(0!, 159.105!) Me.XrLabel2.LocationFloat = New DevExpress.Utils.PointFloat(0!, 139.8528!)
Me.XrLabel1.Multiline = True Me.XrLabel2.Multiline = True
Me.XrLabel1.Name = "XrLabel1" Me.XrLabel2.Name = "XrLabel2"
Me.XrLabel1.Padding = New DevExpress.XtraPrinting.PaddingInfo(5, 5, 0, 0, 254.0!) Me.XrLabel2.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 254.0!)
Me.XrLabel1.SizeF = New System.Drawing.SizeF(857.25!, 76.94083!) Me.XrLabel2.SizeF = New System.Drawing.SizeF(857.2501!, 51.94089!)
Me.XrLabel1.Text = "XrLabel1" Me.XrLabel2.StylePriority.UsePadding = False
Me.XrLabel2.Text = "XrLabel1"
'
'XrLabel3
'
Me.XrLabel3.Dpi = 254.0!
Me.XrLabel3.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Envelope].[User].[Email]")})
Me.XrLabel3.LocationFloat = New DevExpress.Utils.PointFloat(0!, 191.7937!)
Me.XrLabel3.Multiline = True
Me.XrLabel3.Name = "XrLabel3"
Me.XrLabel3.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 254.0!)
Me.XrLabel3.SizeF = New System.Drawing.SizeF(857.2501!, 51.94089!)
Me.XrLabel3.StylePriority.UsePadding = False
Me.XrLabel3.Text = "XrLabel1"
' '
'ObjectDataSource1 'ObjectDataSource1
' '
@ -265,6 +283,32 @@ Partial Public Class rptEnvelopeHistory
Me.ObjectDataSource1.DataSource = GetType(EnvelopeGenerator.Common.ReportSource) Me.ObjectDataSource1.DataSource = GetType(EnvelopeGenerator.Common.ReportSource)
Me.ObjectDataSource1.Name = "ObjectDataSource1" Me.ObjectDataSource1.Name = "ObjectDataSource1"
' '
'XrLabel4
'
Me.XrLabel4.Dpi = 254.0!
Me.XrLabel4.Font = New System.Drawing.Font("Arial", 9.75!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrLabel4.LocationFloat = New DevExpress.Utils.PointFloat(0!, 87.9119!)
Me.XrLabel4.Name = "XrLabel4"
Me.XrLabel4.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 254.0!)
Me.XrLabel4.SizeF = New System.Drawing.SizeF(426.2708!, 51.94094!)
Me.XrLabel4.StyleName = "Title"
Me.XrLabel4.StylePriority.UseFont = False
Me.XrLabel4.StylePriority.UsePadding = False
Me.XrLabel4.Text = "Ersteller:"
'
'XrLabel1
'
Me.XrLabel1.Dpi = 254.0!
Me.XrLabel1.Font = New System.Drawing.Font("Arial", 8.25!, System.Drawing.FontStyle.Bold)
Me.XrLabel1.LocationFloat = New DevExpress.Utils.PointFloat(470.5626!, 0!)
Me.XrLabel1.Name = "XrLabel1"
Me.XrLabel1.Padding = New DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 254.0!)
Me.XrLabel1.SizeF = New System.Drawing.SizeF(695.8539!, 58.0!)
Me.XrLabel1.StyleName = "Title"
Me.XrLabel1.StylePriority.UseFont = False
Me.XrLabel1.StylePriority.UsePadding = False
Me.XrLabel1.Text = "Erstellt mit SignFlow"
'
'rptEnvelopeHistory 'rptEnvelopeHistory
' '
Me.Bands.AddRange(New DevExpress.XtraReports.UI.Band() {Me.TopMargin, Me.BottomMargin, Me.ReportHeader, Me.GroupHeader1, Me.Detail}) Me.Bands.AddRange(New DevExpress.XtraReports.UI.Band() {Me.TopMargin, Me.BottomMargin, Me.ReportHeader, Me.GroupHeader1, Me.Detail})
@ -311,5 +355,8 @@ Partial Public Class rptEnvelopeHistory
Friend WithEvents DetailData1 As DevExpress.XtraReports.UI.XRControlStyle Friend WithEvents DetailData1 As DevExpress.XtraReports.UI.XRControlStyle
Friend WithEvents DetailData3_Odd As DevExpress.XtraReports.UI.XRControlStyle Friend WithEvents DetailData3_Odd As DevExpress.XtraReports.UI.XRControlStyle
Friend WithEvents PageInfo As DevExpress.XtraReports.UI.XRControlStyle Friend WithEvents PageInfo As DevExpress.XtraReports.UI.XRControlStyle
Friend WithEvents XrLabel3 As DevExpress.XtraReports.UI.XRLabel
Friend WithEvents XrLabel2 As DevExpress.XtraReports.UI.XRLabel
Friend WithEvents XrLabel4 As DevExpress.XtraReports.UI.XRLabel
Friend WithEvents XrLabel1 As DevExpress.XtraReports.UI.XRLabel Friend WithEvents XrLabel1 As DevExpress.XtraReports.UI.XRLabel
End Class End Class

View File

@ -34,9 +34,8 @@ Public Class frmReportViewer
EnvelopeModel = New EnvelopeModel(oState) EnvelopeModel = New EnvelopeModel(oState)
Dim oEnvelope = EnvelopeModel.GetById(oEnvelopeId) Dim oEnvelope = EnvelopeModel.GetById(oEnvelopeId)
Dim oCreator As New ReportCreator(oEnvelope)
Dim oBuffer = Await oCreator.CreateReport(oItems)
Dim oBuffer = Await ReportCreator.CreateReport(oEnvelope, oItems)
Using oStream As New IO.MemoryStream(oBuffer) Using oStream As New IO.MemoryStream(oBuffer)
PdfViewer1.LoadDocument(oStream) PdfViewer1.LoadDocument(oStream)