64 lines
2.5 KiB
VB.net
64 lines
2.5 KiB
VB.net
Imports DigitalData.Modules.Logging
|
|
Imports DigitalData.Modules.Database
|
|
Imports DigitalData.Modules.Config
|
|
Imports DigitalData.Modules.Base
|
|
Imports EnvelopeGenerator.CommonServices
|
|
|
|
Public Class frmReportViewer
|
|
Private LogConfig As LogConfig
|
|
Private Logger As Logger
|
|
Private ConfigManager As ConfigManager(Of Config)
|
|
Private Database As MSSQLServer
|
|
|
|
Private EnvelopeModel As EnvelopeModel
|
|
|
|
Private Async Sub frmReportViewer_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
|
LogConfig = New LogConfig(LogConfig.PathType.CustomPath, Application.StartupPath, CompanyName:="Digital Data", ProductName:="EnvelopeGenerator")
|
|
Logger = LogConfig.GetLogger()
|
|
ConfigManager = New ConfigManager(Of Config)(LogConfig, "C:\Users\JenneJ\AppData\Roaming\Digital Data\Envelope Generator\1.0.0.0")
|
|
Database = New MSSQLServer(LogConfig, MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString))
|
|
|
|
Dim oTable As DataTable = Database.GetDatatable("SELECT * FROM VWSIG_ENVELOPE_REPORT ORDER BY POS_WHEN DESC")
|
|
Dim oItems = GetReportSource(oTable)
|
|
|
|
If oItems.Count = 0 Then
|
|
Exit Sub
|
|
End If
|
|
|
|
'Dim oEnvelopeId = oItems.First().EnvelopeId
|
|
Dim oEnvelopeId = 20
|
|
|
|
Dim oState As New State() With {
|
|
.Database = Database,
|
|
.LogConfig = LogConfig
|
|
}
|
|
EnvelopeModel = New EnvelopeModel(oState)
|
|
Dim oEnvelope = EnvelopeModel.GetById(oEnvelopeId)
|
|
|
|
Dim oCreator As New ReportCreator(LogConfig, oState)
|
|
Dim oBuffer = oCreator.CreateReport(oEnvelope)
|
|
|
|
Using oStream As New IO.MemoryStream(oBuffer)
|
|
PdfViewer1.LoadDocument(oStream)
|
|
End Using
|
|
End Sub
|
|
|
|
Private Function GetReportSource(pDataTable As DataTable) As List(Of ReportItem)
|
|
Return pDataTable.Rows.
|
|
Cast(Of DataRow).
|
|
Select(AddressOf ToReportItem).
|
|
OrderByDescending(Function(r) r.ItemDate).
|
|
ToList()
|
|
End Function
|
|
|
|
Private Function ToReportItem(pRow As DataRow) As ReportItem
|
|
Return New ReportItem() With {
|
|
.EnvelopeId = pRow.Item("ENVELOPE_ID"),
|
|
.EnvelopeTitle = pRow.ItemEx("HEAD_TITLE", String.Empty),
|
|
.EnvelopeSubject = pRow.ItemEx("HEAD_SUBJECT", String.Empty),
|
|
.ItemDate = pRow.ItemEx(Of Date)("POS_WHEN", Nothing),
|
|
.ItemStatus = pRow.ItemEx("POS_STATUS", 0),
|
|
.ItemUserReference = pRow.ItemEx("POS_WHO", "")
|
|
}
|
|
End Function
|
|
End Class |