Compare commits
2 Commits
8ab2842594
...
51c053769e
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
51c053769e | ||
|
|
52ac886c1f |
@@ -30,6 +30,7 @@ Public Class frmImportMain
|
||||
Private FileEx As DigitalData.Modules.Filesystem.File
|
||||
Private WebService As WebServiceData
|
||||
Private DocumentLoader As DocumentLoader
|
||||
Private ReportGenerator As ReportGenerator(Of OrderReport)
|
||||
Private FormHelper As FormHelper
|
||||
|
||||
Private Grids As List(Of GridControl)
|
||||
@@ -119,6 +120,7 @@ Public Class frmImportMain
|
||||
|
||||
DocumentLoader = New DocumentLoader(LogConfig, Winline, My.MappingConfiguration, My.TemplateConfiguration)
|
||||
GridLoader = New GridLoader(LogConfig)
|
||||
ReportGenerator = New ReportGenerator(Of OrderReport)(LogConfig, Database, My.TemplateConfiguration, My.GeneralConfiguration)
|
||||
|
||||
SplashScreenManager.SetWaitFormDescription(My.Resources.frmImportMainExtra.Lade_Vorlagen)
|
||||
|
||||
@@ -411,15 +413,23 @@ Public Class frmImportMain
|
||||
btnLoadFiles.Enabled = False
|
||||
SplitContainerGrids.Enabled = False
|
||||
|
||||
' Get the document
|
||||
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
|
||||
Dim oFinalDirectory = My.Helpers.GetDateDirectory(My.GeneralConfiguration.OutputReportDirectory)
|
||||
Dim oFileName = My.Helpers.GetFilenameWithSuffix(IO.Path.GetFileNameWithoutExtension(oDocument.File.Name), My.Helpers.GetDateTimeString, "pdf")
|
||||
Dim oFilePath As String = IO.Path.Combine(oFinalDirectory, oFileName)
|
||||
Dim oReport = GenerateReport(Of OrderReport)(oDocument)
|
||||
oReport.ExportToPdf(oFilePath)
|
||||
|
||||
' Transfer to winline
|
||||
Await WebService.TransferDocumentToWinline(oDocument, lookupMandator.EditValue)
|
||||
|
||||
WebService.RaiseWebServiceProgress("Bericht erzeugen")
|
||||
|
||||
' Generate the report
|
||||
Dim oReport = ReportGenerator.GenerateReport(oDocument)
|
||||
Dim oFilePath = ReportGenerator.GetReportFilePath(oDocument)
|
||||
|
||||
WebService.RaiseWebServiceProgress("Bericht exportieren")
|
||||
|
||||
' Export it to pdf
|
||||
oReport.ExportToPdf(oFilePath)
|
||||
|
||||
MsgBox(My.Resources.frmImportMainExtra.Datei_erfolgreich_in_die_WinLine_übertragen, MsgBoxStyle.Information, Text)
|
||||
Catch ex As HttpRequestException
|
||||
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Übertragung_zur_WinLine, My.Resources.frmImportMainExtra.Die_Verbindung_zum_WinLine_Server_ist_fehlgeschlagen)
|
||||
@@ -519,7 +529,10 @@ Public Class frmImportMain
|
||||
SplitContainerGrids.Enabled = False
|
||||
|
||||
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
|
||||
Dim oReport = GenerateReport(Of OrderReport)(oDocument)
|
||||
Dim oReportGenerator = New ReportGenerator(Of OrderReport)(LogConfig, Database,
|
||||
My.TemplateConfiguration,
|
||||
My.GeneralConfiguration)
|
||||
Dim oReport As OrderReport = oReportGenerator.GenerateReport(oDocument)
|
||||
Dim oPrintTool As New ReportPrintTool(oReport)
|
||||
oPrintTool.Report.CreateDocument(False)
|
||||
oPrintTool.ShowPreview()
|
||||
@@ -529,135 +542,12 @@ Public Class frmImportMain
|
||||
GridControlFiles.Enabled = True
|
||||
SetDocumentButtonsEnabled(True)
|
||||
SplashScreenManager.CloseWaitForm()
|
||||
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Erstellen_der_Berichtsvorschau)
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Function GenerateReport(Of TReport)(pDocument As Document) As TReport
|
||||
|
||||
Dim oMapperConfig As New Mapper(LogConfig)
|
||||
Dim oHeadMapper = oMapperConfig.GetMapper(Of ReportHead)(New Dictionary(Of String, String) From {
|
||||
{"Fakt_Kontonummer[External]", "Text1"},
|
||||
{"Fakt_Kontonummer[Final]", "Text2"},
|
||||
{"Auftrags-Bestellnummer", "Text3"},
|
||||
{"Datum_Auftrag-Bestellung", "Text4"},
|
||||
{"Bestellt_von", "Text5"}
|
||||
})
|
||||
|
||||
Dim oPositionMapper = oMapperConfig.GetMapper(Of ReportPosition)(New Dictionary(Of String, String) From {
|
||||
{"Artikelnummer", "Text1"},
|
||||
{"Lieferantenartikelnummer", "Text2"},
|
||||
{"Menge_bestellt", "Text4"},
|
||||
{"Menge_geliefert", "Text5"},
|
||||
{"Colli", "Text6"},
|
||||
{"Einzelpreis[Original]", "Text7"},
|
||||
{"Einzelpreis[Final]", "Text8"},
|
||||
{"EinheitProPalette", "Text9"},
|
||||
{"Lagerstand", "Text10"}
|
||||
})
|
||||
|
||||
Dim oSQLConfig = My.TemplateConfiguration.Items.
|
||||
Where(Function(item) item.Function.Name = "SQL").
|
||||
ToList()
|
||||
|
||||
FillFieldValuesFromSQL(pDocument, oSQLConfig)
|
||||
|
||||
Dim oHeadRow = pDocument.Rows.
|
||||
Where(Function(r) r.Name.EndsWith("T025")).
|
||||
Select(Function(r) r.Fields).
|
||||
FirstOrDefault()
|
||||
Dim oPositionRows = pDocument.Rows.
|
||||
Where(Function(r) r.Name.EndsWith("T026")).
|
||||
ToList()
|
||||
|
||||
Dim oReportHead = oHeadMapper.Map(Of Dictionary(Of String, FieldValue), ReportHead)(oHeadRow)
|
||||
oReportHead.Title = "EDI Bestellung (orders)"
|
||||
oReportHead.Subtitle = "Schaum"
|
||||
oReportHead.Filename = pDocument.FileName
|
||||
|
||||
Dim oReportPositions As New List(Of ReportPosition)
|
||||
|
||||
Dim oCounter = 1
|
||||
|
||||
For Each oRow As DocumentRow In oPositionRows
|
||||
Dim oReportPosition As ReportPosition = oPositionMapper.Map(Of Dictionary(Of String, FieldValue), ReportPosition)(oRow.Fields)
|
||||
oReportPosition.Id = oCounter
|
||||
oReportPositions.Add(oReportPosition)
|
||||
|
||||
oCounter += 1
|
||||
Next
|
||||
|
||||
Dim oReportSource As New ReportSource With {
|
||||
.Head = oReportHead,
|
||||
.Positions = oReportPositions
|
||||
}
|
||||
|
||||
Dim oReport = Activator.CreateInstance(GetType(TReport))
|
||||
Dim oDataSource = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource With {
|
||||
.DataSource = oReportSource
|
||||
}
|
||||
oDataSource.Fill()
|
||||
oReport.DataSource = oDataSource
|
||||
|
||||
Return oReport
|
||||
End Function
|
||||
|
||||
Private Sub FillFieldValuesFromSQL(pDocument As Document, oSQLConfig As List(Of TemplateConfigItem))
|
||||
For Each oSQLConfigItem In oSQLConfig
|
||||
' FIeldList is a list of fields that will be changed
|
||||
' Example: Setting SQL for Article StorageLocation will invoke the sql for each row
|
||||
Dim oRowList = pDocument.Rows.
|
||||
Where(Function(row) row.Fields.Any(Function(field) field.Key = oSQLConfigItem.Name)).
|
||||
ToList()
|
||||
|
||||
For Each oRow As DocumentRow In oRowList
|
||||
Dim oField = oRow.Fields.
|
||||
Where(Function(field) field.Key = oSQLConfigItem.Name).
|
||||
SingleOrDefault()
|
||||
|
||||
Dim oRegex = New Regex("{#(\w+)#([\w\s_-]+)}+")
|
||||
Dim oSQL = oSQLConfigItem.Function.Params
|
||||
Dim oMatches As MatchCollection = oRegex.Matches(oSQL)
|
||||
|
||||
For Each oMatch As Match In oMatches
|
||||
Dim oPlaceholderString As String = oMatch.Groups.Item(0)?.Value
|
||||
Dim oPlaceholderType As String = oMatch.Groups.Item(1)?.Value
|
||||
Dim oPlaceholderValue As String = oMatch.Groups.Item(2)?.Value
|
||||
|
||||
Select Case oPlaceholderType.ToUpper
|
||||
Case "FIELD"
|
||||
Dim oFieldName = oPlaceholderValue
|
||||
Dim oTargetField = oRow.Fields.
|
||||
Where(Function(field) field.Key = oFieldName).
|
||||
SingleOrDefault()
|
||||
|
||||
oSQL = oSQL.Replace(oPlaceholderString, oTargetField.Value.Final)
|
||||
|
||||
Case "CONST"
|
||||
Select Case oMatch.Groups.Item(2).Value.ToUpper
|
||||
Case "MESOYEAR"
|
||||
oSQL = oSQL.Replace(oPlaceholderString, My.GeneralConfiguration.GetWinLineYear())
|
||||
|
||||
Case "MESOCOMP"
|
||||
oSQL = oSQL.Replace(oPlaceholderString, pDocument.Mandator.Id)
|
||||
|
||||
End Select
|
||||
End Select
|
||||
Next
|
||||
|
||||
Dim oValue = Database.GetScalarValue(oSQL)
|
||||
|
||||
If oValue IsNot Nothing Then
|
||||
oField.Value.Final = oValue
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
End Sub
|
||||
|
||||
Private Sub GridViewFiles_CustomDrawCell(sender As Object, e As Views.Base.RowCellCustomDrawEventArgs) Handles GridViewFiles.CustomDrawCell
|
||||
Dim oDocument As Document = GridViewFiles.GetRow(e.RowHandle)
|
||||
|
||||
18
MultiTool.Form/frmMain.Designer.vb
generated
18
MultiTool.Form/frmMain.Designer.vb
generated
@@ -28,6 +28,7 @@ Partial Class frmMain
|
||||
Me.BarButtonItem3 = New DevExpress.XtraBars.BarButtonItem()
|
||||
Me.RibbonPage1 = New DevExpress.XtraBars.Ribbon.RibbonPage()
|
||||
Me.RibbonPageGroup1 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
|
||||
Me.RibbonPageGroup3 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
|
||||
Me.RibbonPage3 = New DevExpress.XtraBars.Ribbon.RibbonPage()
|
||||
Me.RibbonPageGroup2 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
|
||||
Me.RibbonStatusBar1 = New DevExpress.XtraBars.Ribbon.RibbonStatusBar()
|
||||
@@ -38,7 +39,7 @@ Partial Class frmMain
|
||||
Me.colName = New DevExpress.XtraGrid.Columns.GridColumn()
|
||||
Me.colDescription = New DevExpress.XtraGrid.Columns.GridColumn()
|
||||
Me.colFileName = New DevExpress.XtraGrid.Columns.GridColumn()
|
||||
Me.RibbonPageGroup3 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
|
||||
Me.SplashScreenManager1 = New DevExpress.XtraSplashScreen.SplashScreenManager(Me, GetType(Global.MultiTool.Form.frmWaitForm), True, True)
|
||||
CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
CType(Me.SvgImageCollection1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
CType(Me.GridControl1, System.ComponentModel.ISupportInitialize).BeginInit()
|
||||
@@ -107,6 +108,13 @@ Partial Class frmMain
|
||||
Me.RibbonPageGroup1.Name = "RibbonPageGroup1"
|
||||
Me.RibbonPageGroup1.Text = "Start"
|
||||
'
|
||||
'RibbonPageGroup3
|
||||
'
|
||||
Me.RibbonPageGroup3.Alignment = DevExpress.XtraBars.Ribbon.RibbonPageGroupAlignment.Far
|
||||
Me.RibbonPageGroup3.ItemLinks.Add(Me.BarButtonItem1)
|
||||
Me.RibbonPageGroup3.Name = "RibbonPageGroup3"
|
||||
Me.RibbonPageGroup3.Text = "RibbonPageGroup3"
|
||||
'
|
||||
'RibbonPage3
|
||||
'
|
||||
Me.RibbonPage3.Groups.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPageGroup() {Me.RibbonPageGroup2})
|
||||
@@ -179,12 +187,9 @@ Partial Class frmMain
|
||||
Me.colFileName.Visible = True
|
||||
Me.colFileName.VisibleIndex = 2
|
||||
'
|
||||
'RibbonPageGroup3
|
||||
'SplashScreenManager1
|
||||
'
|
||||
Me.RibbonPageGroup3.Alignment = DevExpress.XtraBars.Ribbon.RibbonPageGroupAlignment.Far
|
||||
Me.RibbonPageGroup3.ItemLinks.Add(Me.BarButtonItem1)
|
||||
Me.RibbonPageGroup3.Name = "RibbonPageGroup3"
|
||||
Me.RibbonPageGroup3.Text = "RibbonPageGroup3"
|
||||
Me.SplashScreenManager1.ClosingDelay = 500
|
||||
'
|
||||
'frmMain
|
||||
'
|
||||
@@ -226,4 +231,5 @@ Partial Class frmMain
|
||||
Friend WithEvents BarButtonItem2 As DevExpress.XtraBars.BarButtonItem
|
||||
Friend WithEvents BarButtonItem3 As DevExpress.XtraBars.BarButtonItem
|
||||
Friend WithEvents RibbonPageGroup3 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
|
||||
Friend WithEvents SplashScreenManager1 As DevExpress.XtraSplashScreen.SplashScreenManager
|
||||
End Class
|
||||
|
||||
@@ -16,7 +16,7 @@ Public Class frmMain
|
||||
Private GridBuilder As GridBuilder
|
||||
Private FormHelper As FormHelper
|
||||
|
||||
Private Async Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Private Sub frmMain_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Try
|
||||
Text = String.Format(My.Resources.frmShared._0____WebService_Multitool_für_WinLine, My.Resources.frmShared.Auswahl_der_Vorlage)
|
||||
|
||||
@@ -24,6 +24,19 @@ Public Class frmMain
|
||||
LogConfig.Debug = True
|
||||
Logger = LogConfig.GetLogger()
|
||||
Logger.Info("Starting {0}, Version [{1}]", Application.ProductName, Application.ProductVersion)
|
||||
|
||||
Catch ex As Exception
|
||||
FormHelper.ShowError(ex, My.Resources.frmShared.Laden_des_Formulars)
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Async Sub frmMain_Shown(sender As Object, e As EventArgs) Handles Me.Shown
|
||||
SplashScreenManager1.ShowWaitForm()
|
||||
|
||||
Try
|
||||
SplashScreenManager1.SetWaitFormDescription("Initialisierung der Grundfunktionen")
|
||||
|
||||
FormHelper = New FormHelper(LogConfig)
|
||||
ConfigManager = New ConfigManager(Of [Shared].Config)(LogConfig,
|
||||
Application.UserAppDataPath,
|
||||
@@ -48,10 +61,14 @@ Public Class frmMain
|
||||
End If
|
||||
End If
|
||||
|
||||
SplashScreenManager1.SetWaitFormDescription("Initialisierung der Datenbankverbindung")
|
||||
|
||||
' Initialize Database
|
||||
Dim oConnectionString = MSSQLServer.DecryptConnectionString(ConfigManager.Config.ConnectionString)
|
||||
Database = New MSSQLServer(LogConfig, oConnectionString)
|
||||
|
||||
SplashScreenManager1.SetWaitFormDescription("Initialisierung der Vorlagen")
|
||||
|
||||
' Initialize Schemas
|
||||
TemplateLoader = New TemplateLoader(LogConfig, Database)
|
||||
Await TemplateLoader.LoadGeneralConfiguration()
|
||||
@@ -74,7 +91,10 @@ Public Class frmMain
|
||||
|
||||
GridControl1.DataSource = oBindingSource
|
||||
Catch ex As Exception
|
||||
FormHelper.ShowError(ex, My.Resources.frmShared.Laden_des_Formulars)
|
||||
FormHelper.ShowError(ex, My.Resources.frmImportMainExtra.Laden_der_Winline_Daten)
|
||||
|
||||
Finally
|
||||
SplashScreenManager1.CloseWaitForm()
|
||||
|
||||
End Try
|
||||
End Sub
|
||||
@@ -135,4 +155,7 @@ Public Class frmMain
|
||||
Private Sub BarButtonItem3_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem3.ItemClick
|
||||
TryOpenDirectory(LogConfig.LogDirectory, My.Resources.frmImportMainExtra.Logverzeichnis)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
End Class
|
||||
@@ -3,9 +3,11 @@
|
||||
Public Class BaseClass
|
||||
Public ReadOnly LogConfig As LogConfig
|
||||
Public ReadOnly Logger As Logger
|
||||
Public ReadOnly Helpers As Helpers
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
LogConfig = pLogConfig
|
||||
Logger = LogConfig.GetLogger()
|
||||
Helpers = New Helpers(pLogConfig)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Public Class Helpers
|
||||
Inherits BaseClass
|
||||
Private LogConfig As LogConfig
|
||||
Private Logger As Logger
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
LogConfig = pLogConfig
|
||||
Logger = pLogConfig.GetLogger()
|
||||
End Sub
|
||||
|
||||
Public Function GetDateDirectory(pBaseDirectory As String)
|
||||
|
||||
@@ -47,7 +47,9 @@
|
||||
<Reference Include="AutoMapper, Version=10.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\AutoMapper.10.1.1\lib\net461\AutoMapper.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="DevExpress.Data.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" />
|
||||
<Reference Include="DevExpress.DataAccess.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DevExpress.Printing.v19.2.Core, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a, processorArchitecture=MSIL" />
|
||||
<Reference Include="DigitalData.Modules.Config">
|
||||
<HintPath>..\..\DDMonorepo\Modules.Config\bin\Debug\DigitalData.Modules.Config.dll</HintPath>
|
||||
</Reference>
|
||||
@@ -124,6 +126,7 @@
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Report\ReportGenerator.vb" />
|
||||
<Compile Include="Templates\GeneralConfig.vb" />
|
||||
<Compile Include="Templates\MandatorConfig.vb" />
|
||||
<Compile Include="Templates\MandatorConfigItem.vb" />
|
||||
|
||||
151
MultiTool.Shared/Report/ReportGenerator.vb
Normal file
151
MultiTool.Shared/Report/ReportGenerator.vb
Normal file
@@ -0,0 +1,151 @@
|
||||
Imports System.Text.RegularExpressions
|
||||
Imports DevExpress.XtraReports
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports MultiTool.Shared.Documents
|
||||
Imports MultiTool.Shared.Documents.DocumentRow
|
||||
Imports MultiTool.Shared.Report
|
||||
Imports MultiTool.Shared.Templates
|
||||
|
||||
Public Class ReportGenerator(Of TReport As IReport)
|
||||
Inherits BaseClass
|
||||
|
||||
Private ReadOnly Database As MSSQLServer
|
||||
Private ReadOnly TemplateConfig As TemplateConfig
|
||||
Private ReadOnly GeneralConfig As GeneralConfig
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pTemplateConfig As TemplateConfig, pGeneralConfig As GeneralConfig)
|
||||
MyBase.New(pLogConfig)
|
||||
Database = pDatabase
|
||||
GeneralConfig = pGeneralConfig
|
||||
TemplateConfig = pTemplateConfig
|
||||
End Sub
|
||||
|
||||
Public Function GetReportFilePath(pDocument As Document)
|
||||
Dim oFinalDirectory = Helpers.GetDateDirectory(GeneralConfig.OutputReportDirectory)
|
||||
Dim oFileName = Helpers.GetFilenameWithSuffix(IO.Path.GetFileNameWithoutExtension(pDocument.File.Name), Helpers.GetDateTimeString, "pdf")
|
||||
Dim oFilePath As String = IO.Path.Combine(oFinalDirectory, oFileName)
|
||||
Return oFilePath
|
||||
End Function
|
||||
|
||||
Public Function GenerateReport(pDocument As Document) As TReport
|
||||
|
||||
Dim oMapperConfig As New Mapper(LogConfig)
|
||||
Dim oHeadMapper = oMapperConfig.GetMapper(Of ReportHead)(New Dictionary(Of String, String) From {
|
||||
{"Fakt_Kontonummer[External]", "Text1"},
|
||||
{"Fakt_Kontonummer[Final]", "Text2"},
|
||||
{"Auftrags-Bestellnummer", "Text3"},
|
||||
{"Datum_Auftrag-Bestellung", "Text4"},
|
||||
{"Bestellt_von", "Text5"}
|
||||
})
|
||||
|
||||
Dim oPositionMapper = oMapperConfig.GetMapper(Of ReportPosition)(New Dictionary(Of String, String) From {
|
||||
{"Artikelnummer", "Text1"},
|
||||
{"Lieferantenartikelnummer", "Text2"},
|
||||
{"Menge_bestellt", "Text4"},
|
||||
{"Menge_geliefert", "Text5"},
|
||||
{"Colli", "Text6"},
|
||||
{"Einzelpreis[Original]", "Text7"},
|
||||
{"Einzelpreis[Final]", "Text8"},
|
||||
{"EinheitProPalette", "Text9"},
|
||||
{"Lagerstand", "Text10"}
|
||||
})
|
||||
|
||||
Dim oSQLConfig = TemplateConfig.Items.
|
||||
Where(Function(item) item.Function.Name = "SQL").
|
||||
ToList()
|
||||
|
||||
FillFieldValuesFromSQL(pDocument, oSQLConfig)
|
||||
|
||||
Dim oHeadRow = pDocument.Rows.
|
||||
Where(Function(r) r.Name.EndsWith("T025")).
|
||||
Select(Function(r) r.Fields).
|
||||
FirstOrDefault()
|
||||
Dim oPositionRows = pDocument.Rows.
|
||||
Where(Function(r) r.Name.EndsWith("T026")).
|
||||
ToList()
|
||||
|
||||
Dim oReportHead = oHeadMapper.Map(Of Dictionary(Of String, FieldValue), ReportHead)(oHeadRow)
|
||||
oReportHead.Title = "EDI Bestellung (orders)"
|
||||
oReportHead.Subtitle = "Schaum"
|
||||
oReportHead.Filename = pDocument.FileName
|
||||
|
||||
Dim oReportPositions As New List(Of ReportPosition)
|
||||
|
||||
Dim oCounter = 1
|
||||
|
||||
For Each oRow As DocumentRow In oPositionRows
|
||||
Dim oReportPosition As ReportPosition = oPositionMapper.Map(Of Dictionary(Of String, FieldValue), ReportPosition)(oRow.Fields)
|
||||
oReportPosition.Id = oCounter
|
||||
oReportPositions.Add(oReportPosition)
|
||||
|
||||
oCounter += 1
|
||||
Next
|
||||
|
||||
Dim oReportSource As New ReportSource With {
|
||||
.Head = oReportHead,
|
||||
.Positions = oReportPositions
|
||||
}
|
||||
|
||||
Dim oReport = Activator.CreateInstance(GetType(TReport))
|
||||
Dim oDataSource = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource With {
|
||||
.DataSource = oReportSource
|
||||
}
|
||||
oDataSource.Fill()
|
||||
oReport.DataSource = oDataSource
|
||||
|
||||
Return oReport
|
||||
End Function
|
||||
|
||||
Private Sub FillFieldValuesFromSQL(pDocument As Document, oSQLConfig As List(Of TemplateConfigItem))
|
||||
For Each oSQLConfigItem In oSQLConfig
|
||||
' FieldList is a list of fields that will be changed
|
||||
' Example: Setting SQL for Article StorageLocation will invoke the sql for each row
|
||||
Dim oRowList = pDocument.Rows.
|
||||
Where(Function(row) row.Fields.Any(Function(field) field.Key = oSQLConfigItem.Name)).
|
||||
ToList()
|
||||
|
||||
For Each oRow As DocumentRow In oRowList
|
||||
Dim oField = oRow.Fields.
|
||||
Where(Function(field) field.Key = oSQLConfigItem.Name).
|
||||
SingleOrDefault()
|
||||
|
||||
Dim oRegex = New Regex("{#(\w+)#([\w\s_-]+)}+")
|
||||
Dim oSQL = oSQLConfigItem.Function.Params
|
||||
Dim oMatches As MatchCollection = oRegex.Matches(oSQL)
|
||||
|
||||
For Each oMatch As Match In oMatches
|
||||
Dim oPlaceholderString As String = oMatch.Groups.Item(0)?.Value
|
||||
Dim oPlaceholderType As String = oMatch.Groups.Item(1)?.Value
|
||||
Dim oPlaceholderValue As String = oMatch.Groups.Item(2)?.Value
|
||||
|
||||
Select Case oPlaceholderType.ToUpper
|
||||
Case "FIELD"
|
||||
Dim oFieldName = oPlaceholderValue
|
||||
Dim oTargetField = oRow.Fields.
|
||||
Where(Function(field) field.Key = oFieldName).
|
||||
SingleOrDefault()
|
||||
|
||||
oSQL = oSQL.Replace(oPlaceholderString, oTargetField.Value.Final)
|
||||
|
||||
Case "CONST"
|
||||
Select Case oMatch.Groups.Item(2).Value.ToUpper
|
||||
Case "MESOYEAR"
|
||||
oSQL = oSQL.Replace(oPlaceholderString, GeneralConfig.GetWinLineYear())
|
||||
|
||||
Case "MESOCOMP"
|
||||
oSQL = oSQL.Replace(oPlaceholderString, pDocument.Mandator.Id)
|
||||
|
||||
End Select
|
||||
End Select
|
||||
Next
|
||||
|
||||
Dim oValue = Database.GetScalarValue(oSQL)
|
||||
|
||||
If oValue IsNot Nothing Then
|
||||
oField.Value.Final = oValue
|
||||
End If
|
||||
Next
|
||||
Next
|
||||
End Sub
|
||||
End Class
|
||||
@@ -13,18 +13,20 @@ Namespace Winline
|
||||
Private ReadOnly Config As WebServiceConfig
|
||||
Private ReadOnly Serializer As Serializer
|
||||
Private ReadOnly OutputDirectory As String
|
||||
Private ReadOnly Helpers As Helpers
|
||||
|
||||
Public Event WebServiceProgress As EventHandler(Of String)
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pWebserviceConfig As WebServiceConfig, pOutputDirectoryPath As String)
|
||||
MyBase.New(pLogConfig)
|
||||
Helpers = New Helpers(pLogConfig)
|
||||
Serializer = New Serializer(pLogConfig)
|
||||
Config = pWebserviceConfig
|
||||
OutputDirectory = pOutputDirectoryPath
|
||||
End Sub
|
||||
|
||||
Public Sub RaiseWebServiceProgress(pMessage As String)
|
||||
RaiseEvent WebServiceProgress(Me, pMessage)
|
||||
End Sub
|
||||
|
||||
Public Async Function TransferDocumentToWinline(pDocument As Document, pMandator As Mandator, Optional pIsTest As Boolean = False) As Task(Of Boolean)
|
||||
Dim oBytes As Byte() = GetBytesFromDocument(pDocument)
|
||||
Dim oWS = Config
|
||||
|
||||
Reference in New Issue
Block a user