Export report to Directory

This commit is contained in:
Jonathan Jenne 2021-11-30 12:17:26 +01:00
parent ad7e6a9c84
commit 436293cbb7
16 changed files with 166 additions and 161 deletions

View File

@ -9,7 +9,7 @@ Public Class GridLoader
Inherits BaseClass
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig, pLogConfig.GetLogger())
MyBase.New(pLogConfig)
End Sub
Public Function GetGridFromElement(pGrid As GridControl, pTable As Templates.Template.Table) As GridControl

View File

@ -1,4 +1,5 @@
Imports MultiTool.Shared.Templates
Imports MultiTool.Shared
Namespace My
<HideModuleName()>
@ -7,5 +8,7 @@ Namespace My
Friend Property MappingConfiguration As MappingConfig
Friend Property MandatorConfiguration As MandatorConfig
Friend Property GeneralConfiguration As GeneralConfig
Public Property Helpers As Helpers
End Module
End Namespace

View File

@ -66,8 +66,10 @@ Partial Public Class OrderReport
Me.tableCell31 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell13 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell33 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell15 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell34 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell35 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell17 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell36 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell7 = New DevExpress.XtraReports.UI.XRTableCell()
Me.Detail1 = New DevExpress.XtraReports.UI.DetailBand()
@ -79,17 +81,15 @@ Partial Public Class OrderReport
Me.tableCell41 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell14 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell43 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell16 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell44 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell45 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell18 = New DevExpress.XtraReports.UI.XRTableCell()
Me.tableCell46 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell8 = New DevExpress.XtraReports.UI.XRTableCell()
Me.GroupFooter1 = New DevExpress.XtraReports.UI.GroupFooterBand()
Me.label2 = New DevExpress.XtraReports.UI.XRLabel()
Me.ObjectDataSource1 = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource(Me.components)
Me.XrTableCell15 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell16 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell17 = New DevExpress.XtraReports.UI.XRTableCell()
Me.XrTableCell18 = New DevExpress.XtraReports.UI.XRTableCell()
CType(Me.XrTable2, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.XrTable1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.table3, System.ComponentModel.ISupportInitialize).BeginInit()
@ -257,11 +257,11 @@ Partial Public Class OrderReport
'
Me.XrLabel4.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Head].[Filename]")})
Me.XrLabel4.Font = New System.Drawing.Font("Arial", 9.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.XrLabel4.LocationFloat = New DevExpress.Utils.PointFloat(652.6498!, 10.00001!)
Me.XrLabel4.LocationFloat = New DevExpress.Utils.PointFloat(448.4831!, 10.00001!)
Me.XrLabel4.Multiline = True
Me.XrLabel4.Name = "XrLabel4"
Me.XrLabel4.Padding = New DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100.0!)
Me.XrLabel4.SizeF = New System.Drawing.SizeF(417.3502!, 23.0!)
Me.XrLabel4.SizeF = New System.Drawing.SizeF(621.517!, 23.0!)
Me.XrLabel4.StylePriority.UseFont = False
Me.XrLabel4.StylePriority.UseTextAlignment = False
Me.XrLabel4.Text = "XrLabel1"
@ -507,6 +507,14 @@ Partial Public Class OrderReport
Me.tableCell33.Text = "Lager" & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "stand"
Me.tableCell33.Weight = 0.085275647971440827R
'
'XrTableCell15
'
Me.XrTableCell15.Multiline = True
Me.XrTableCell15.Name = "XrTableCell15"
Me.XrTableCell15.StyleName = "DetailCaption2"
Me.XrTableCell15.Text = "Menge " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "bestellt"
Me.XrTableCell15.Weight = 0.082007817175517708R
'
'tableCell34
'
Me.tableCell34.Multiline = True
@ -522,6 +530,14 @@ Partial Public Class OrderReport
Me.tableCell35.Text = "Colli"
Me.tableCell35.Weight = 0.089275021139650343R
'
'XrTableCell17
'
Me.XrTableCell17.Multiline = True
Me.XrTableCell17.Name = "XrTableCell17"
Me.XrTableCell17.StyleName = "DetailCaption2"
Me.XrTableCell17.Text = "Einh/Pal"
Me.XrTableCell17.Weight = 0.089275021139650343R
'
'tableCell36
'
Me.tableCell36.Name = "tableCell36"
@ -611,6 +627,17 @@ Partial Public Class OrderReport
Me.tableCell43.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight
Me.tableCell43.Weight = 0.085275553474624122R
'
'XrTableCell16
'
Me.XrTableCell16.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Text4]")})
Me.XrTableCell16.Multiline = True
Me.XrTableCell16.Name = "XrTableCell16"
Me.XrTableCell16.StyleName = "DetailData2"
Me.XrTableCell16.StylePriority.UseTextAlignment = False
Me.XrTableCell16.Text = "XrTableCell16"
Me.XrTableCell16.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight
Me.XrTableCell16.Weight = 0.082007801747328815R
'
'tableCell44
'
Me.tableCell44.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Text5]")})
@ -629,6 +656,17 @@ Partial Public Class OrderReport
Me.tableCell45.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight
Me.tableCell45.Weight = 0.08927502299934123R
'
'XrTableCell18
'
Me.XrTableCell18.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Text9]")})
Me.XrTableCell18.Multiline = True
Me.XrTableCell18.Name = "XrTableCell18"
Me.XrTableCell18.StyleName = "DetailData2"
Me.XrTableCell18.StylePriority.UseTextAlignment = False
Me.XrTableCell18.Text = "XrTableCell18"
Me.XrTableCell18.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight
Me.XrTableCell18.Weight = 0.08927502299934123R
'
'tableCell46
'
Me.tableCell46.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Text7]")})
@ -671,44 +709,6 @@ Partial Public Class OrderReport
Me.ObjectDataSource1.DataSource = GetType(MultiTool.[Shared].Report.ReportSource)
Me.ObjectDataSource1.Name = "ObjectDataSource1"
'
'XrTableCell15
'
Me.XrTableCell15.Multiline = True
Me.XrTableCell15.Name = "XrTableCell15"
Me.XrTableCell15.StyleName = "DetailCaption2"
Me.XrTableCell15.Text = "Menge " & Global.Microsoft.VisualBasic.ChrW(13) & Global.Microsoft.VisualBasic.ChrW(10) & "bestellt"
Me.XrTableCell15.Weight = 0.082007817175517708R
'
'XrTableCell16
'
Me.XrTableCell16.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Text4]")})
Me.XrTableCell16.Multiline = True
Me.XrTableCell16.Name = "XrTableCell16"
Me.XrTableCell16.StyleName = "DetailData2"
Me.XrTableCell16.StylePriority.UseTextAlignment = False
Me.XrTableCell16.Text = "XrTableCell16"
Me.XrTableCell16.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight
Me.XrTableCell16.Weight = 0.082007801747328815R
'
'XrTableCell17
'
Me.XrTableCell17.Multiline = True
Me.XrTableCell17.Name = "XrTableCell17"
Me.XrTableCell17.StyleName = "DetailCaption2"
Me.XrTableCell17.Text = "Einh/Pal"
Me.XrTableCell17.Weight = 0.089275021139650343R
'
'XrTableCell18
'
Me.XrTableCell18.ExpressionBindings.AddRange(New DevExpress.XtraReports.UI.ExpressionBinding() {New DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[Text9]")})
Me.XrTableCell18.Multiline = True
Me.XrTableCell18.Name = "XrTableCell18"
Me.XrTableCell18.StyleName = "DetailData2"
Me.XrTableCell18.StylePriority.UseTextAlignment = False
Me.XrTableCell18.Text = "XrTableCell18"
Me.XrTableCell18.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight
Me.XrTableCell18.Weight = 0.08927502299934123R
'
'OrderReport
'
Me.Bands.AddRange(New DevExpress.XtraReports.UI.Band() {Me.TopMargin, Me.BottomMargin, Me.ReportHeader, Me.Detail, Me.DetailReport})

View File

@ -66,6 +66,7 @@ Partial Class frmImportMain
Me.RibbonPageGroup7 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPage2 = New DevExpress.XtraBars.Ribbon.RibbonPage()
Me.RibbonPageGroup5 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RibbonPageGroup2 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.RepositoryItemComboBox1 = New DevExpress.XtraEditors.Repository.RepositoryItemComboBox()
Me.RepositoryItemProgressBar1 = New DevExpress.XtraEditors.Repository.RepositoryItemProgressBar()
Me.RibbonStatusBar = New DevExpress.XtraBars.Ribbon.RibbonStatusBar()
@ -88,8 +89,6 @@ Partial Class frmImportMain
Me.GridView4 = New DevExpress.XtraGrid.Views.Grid.GridView()
Me.BehaviorManager = New DevExpress.Utils.Behaviors.BehaviorManager(Me.components)
Me.SplashScreenManager = New DevExpress.XtraSplashScreen.SplashScreenManager(Me, GetType(Global.MultiTool.Form.frmWaitForm), True, True)
Me.RibbonPageGroup2 = New DevExpress.XtraBars.Ribbon.RibbonPageGroup()
Me.BarButtonItem2 = New DevExpress.XtraBars.BarButtonItem()
CType(Me.SplitContainerMain, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SplitContainerMain.SuspendLayout()
CType(Me.GridControlFiles, System.ComponentModel.ISupportInitialize).BeginInit()
@ -217,9 +216,9 @@ Partial Class frmImportMain
'RibbonControl
'
Me.RibbonControl.ExpandCollapseItem.Id = 0
Me.RibbonControl.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl.ExpandCollapseItem, Me.RibbonControl.SearchEditItem, Me.txtVersion, Me.txtFilesLoaded, Me.btnLoadFiles, Me.btnTransferFile, Me.btnOpenInputDirectory, Me.btnOpenOutputDirectory, Me.btnOpenSchemaDirectory, Me.btnReloadFile, Me.btnTransferAllFiles, Me.btnOpenReport, Me.btnShowXml, Me.btnOpenLogDirectory, Me.btnOpenConfigDirectory, Me.txtCurrentFile, Me.btnConfig, Me.txtCulture, Me.btnRemoveRow, Me.BarWorkspaceMenuItem1, Me.btnTestTransferFile, Me.BarButtonItem1, Me.BarButtonItem2})
Me.RibbonControl.Items.AddRange(New DevExpress.XtraBars.BarItem() {Me.RibbonControl.ExpandCollapseItem, Me.RibbonControl.SearchEditItem, Me.txtVersion, Me.txtFilesLoaded, Me.btnLoadFiles, Me.btnTransferFile, Me.btnOpenInputDirectory, Me.btnOpenOutputDirectory, Me.btnOpenSchemaDirectory, Me.btnReloadFile, Me.btnTransferAllFiles, Me.btnOpenReport, Me.btnShowXml, Me.btnOpenLogDirectory, Me.btnOpenConfigDirectory, Me.txtCurrentFile, Me.btnConfig, Me.txtCulture, Me.btnRemoveRow, Me.BarWorkspaceMenuItem1, Me.btnTestTransferFile, Me.BarButtonItem1})
resources.ApplyResources(Me.RibbonControl, "RibbonControl")
Me.RibbonControl.MaxItemId = 32
Me.RibbonControl.MaxItemId = 33
Me.RibbonControl.Name = "RibbonControl"
Me.RibbonControl.PageHeaderItemLinks.Add(Me.BarWorkspaceMenuItem1)
Me.RibbonControl.Pages.AddRange(New DevExpress.XtraBars.Ribbon.RibbonPage() {Me.RibbonPage1, Me.RibbonPage2})
@ -405,7 +404,6 @@ Partial Class frmImportMain
'RibbonPageGroup4
'
Me.RibbonPageGroup4.ItemLinks.Add(Me.btnOpenReport)
Me.RibbonPageGroup4.ItemLinks.Add(Me.btnShowXml)
Me.RibbonPageGroup4.Name = "RibbonPageGroup4"
resources.ApplyResources(Me.RibbonPageGroup4, "RibbonPageGroup4")
'
@ -438,6 +436,12 @@ Partial Class frmImportMain
Me.RibbonPageGroup5.Name = "RibbonPageGroup5"
resources.ApplyResources(Me.RibbonPageGroup5, "RibbonPageGroup5")
'
'RibbonPageGroup2
'
Me.RibbonPageGroup2.ItemLinks.Add(Me.btnShowXml)
Me.RibbonPageGroup2.Name = "RibbonPageGroup2"
resources.ApplyResources(Me.RibbonPageGroup2, "RibbonPageGroup2")
'
'RepositoryItemComboBox1
'
resources.ApplyResources(Me.RepositoryItemComboBox1, "RepositoryItemComboBox1")
@ -587,18 +591,6 @@ Partial Class frmImportMain
'
Me.SplashScreenManager.ClosingDelay = 500
'
'RibbonPageGroup2
'
Me.RibbonPageGroup2.ItemLinks.Add(Me.BarButtonItem2)
Me.RibbonPageGroup2.Name = "RibbonPageGroup2"
resources.ApplyResources(Me.RibbonPageGroup2, "RibbonPageGroup2")
'
'BarButtonItem2
'
resources.ApplyResources(Me.BarButtonItem2, "BarButtonItem2")
Me.BarButtonItem2.Id = 31
Me.BarButtonItem2.Name = "BarButtonItem2"
'
'frmImportMain
'
resources.ApplyResources(Me, "$this")
@ -706,6 +698,5 @@ Partial Class frmImportMain
Friend WithEvents gridBand1 As DevExpress.XtraGrid.Views.BandedGrid.GridBand
Friend WithEvents GridBand2 As DevExpress.XtraGrid.Views.BandedGrid.GridBand
Friend WithEvents BarButtonItem1 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents BarButtonItem2 As DevExpress.XtraBars.BarButtonItem
Friend WithEvents RibbonPageGroup2 As DevExpress.XtraBars.Ribbon.RibbonPageGroup
End Class

View File

@ -536,6 +536,12 @@
<data name="&gt;&gt;RibbonPageGroup5.Type" xml:space="preserve">
<value>DevExpress.XtraBars.Ribbon.RibbonPageGroup, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;RibbonPageGroup2.Name" xml:space="preserve">
<value>RibbonPageGroup2</value>
</data>
<data name="&gt;&gt;RibbonPageGroup2.Type" xml:space="preserve">
<value>DevExpress.XtraBars.Ribbon.RibbonPageGroup, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;RepositoryItemComboBox1.Name" xml:space="preserve">
<value>RepositoryItemComboBox1</value>
</data>
@ -602,18 +608,6 @@
<data name="&gt;&gt;SplashScreenManager.Type" xml:space="preserve">
<value>DevExpress.XtraSplashScreen.SplashScreenManager, DevExpress.XtraEditors.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;RibbonPageGroup2.Name" xml:space="preserve">
<value>RibbonPageGroup2</value>
</data>
<data name="&gt;&gt;RibbonPageGroup2.Type" xml:space="preserve">
<value>DevExpress.XtraBars.Ribbon.RibbonPageGroup, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;BarButtonItem2.Name" xml:space="preserve">
<value>BarButtonItem2</value>
</data>
<data name="&gt;&gt;BarButtonItem2.Type" xml:space="preserve">
<value>DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a</value>
</data>
<data name="&gt;&gt;$this.Name" xml:space="preserve">
<value>frmImportMain</value>
</data>
@ -626,9 +620,6 @@
<data name="BarButtonItem1.Caption" xml:space="preserve">
<value>BarButtonItem1</value>
</data>
<data name="BarButtonItem2.Caption" xml:space="preserve">
<value>BarButtonItem2</value>
</data>
<data name="RibbonControl.Location" type="System.Drawing.Point, System.Drawing">
<value>0, 0</value>
</data>

View File

@ -78,7 +78,7 @@ Public Class frmImportMain
FileEx = New DigitalData.Modules.Filesystem.File(LogConfig)
Winline = New WinlineData(LogConfig, Database, My.GeneralConfiguration, My.MappingConfiguration, My.MandatorConfiguration)
WebService = New WebServiceData(LogConfig, My.GeneralConfiguration.Webservice, Application.UserAppDataPath)
WebService = New WebServiceData(LogConfig, My.GeneralConfiguration.Webservice, My.GeneralConfiguration.OutputWebserviceDirectory)
AddHandler WebService.WebServiceProgress, AddressOf WebService_Progress
Catch ex As Exception
@ -409,6 +409,12 @@ Public Class frmImportMain
SplitContainerGrids.Enabled = False
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)
Await WebService.TransferDocumentToWinline(oDocument, lookupMandator.EditValue)
MsgBox(My.Resources.frmImportMainExtra.Datei_erfolgreich_in_die_WinLine_übertragen, MsgBoxStyle.Information, Text)
@ -436,8 +442,7 @@ Public Class frmImportMain
End Sub
Private Sub btnOpenOutputDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenOutputDirectory.ItemClick
Dim oOutputDirectory = Path.Combine(Application.UserAppDataPath, "WebService")
TryOpenDirectory(oOutputDirectory, My.Resources.frmImportMainExtra.Ausgabeverzeichnis)
TryOpenDirectory(My.GeneralConfiguration.OutputDirectory, My.Resources.frmImportMainExtra.Ausgabeverzeichnis)
End Sub
Private Sub btnOpenSchemaDirectory_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles btnOpenSchemaDirectory.ItemClick
@ -511,7 +516,9 @@ Public Class frmImportMain
SplitContainerGrids.Enabled = False
Dim oDocument As Document = GridViewFiles.GetRow(GridViewFiles.FocusedRowHandle)
Dim oPrintTool As ReportPrintTool = GenerateReport(oDocument)
Dim oReport = GenerateReport(Of OrderReport)(oDocument)
Dim oPrintTool As New ReportPrintTool(oReport)
oPrintTool.Report.CreateDocument(False)
oPrintTool.ShowPreview()
SplitContainerGrids.Enabled = True
@ -528,8 +535,7 @@ Public Class frmImportMain
End Try
End Sub
Private Function GenerateReport(pDocument As Document) As ReportPrintTool
Dim oPrintTool As ReportPrintTool = Nothing
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 {
@ -552,7 +558,6 @@ Public Class frmImportMain
{"Lagerstand", "Text10"}
})
Dim oSQLConfig = My.TemplateConfiguration.Items.
Where(Function(item) item.Function.Name = "SQL").
ToList()
@ -589,17 +594,14 @@ Public Class frmImportMain
.Positions = oReportPositions
}
Dim oReport As New OrderReport
Dim oReport = Activator.CreateInstance(GetType(TReport))
Dim oDataSource = New DevExpress.DataAccess.ObjectBinding.ObjectDataSource With {
.DataSource = oReportSource
}
oDataSource.Fill()
oReport.DataSource = oDataSource
oPrintTool = New ReportPrintTool(oReport)
oPrintTool.Report.CreateDocument(False)
Return oPrintTool
Return oReport
End Function
Private Sub FillFieldValuesFromSQL(pDocument As Document, oSQLConfig As List(Of TemplateConfigItem))

View File

@ -65,6 +65,7 @@ Public Class frmMain
My.TemplateConfiguration = TemplateLoader.TemplateConfiguration
My.MandatorConfiguration = TemplateLoader.MandatorConfiguration
My.GeneralConfiguration = TemplateLoader.GeneralConfiguration
My.Helpers = New [Shared].Helpers(LogConfig)
Dim oBindingSource = New BindingList(Of Template)
For Each oTemplate As Template In TemplateLoader.TemplateList

View File

@ -54,17 +54,22 @@ Public Class frmRowEditor
_DocumentRow = pDocumentRow
_Table = pTable
' TODO: Show text similar to NullText when account number is not in the list/datasource
AccountPicker.DataSource = _Accounts
AccountPicker.DisplayMember = "Name"
AccountPicker.ValueMember = "Id"
'AccountPicker.NullText = "[Kein Konto gefunden]"
ArticlePicker.DataSource = _Articles
ArticlePicker.DisplayMember = "Description"
ArticlePicker.ValueMember = "Id"
'ArticlePicker.NullText = "[Kein Artikel gefunden]"
DocumentKindPicker.DataSource = _DocumentKinds
DocumentKindPicker.ValueMember = "Id"
DocumentKindPicker.DisplayMember = "Name"
'DocumentKindPicker.NullText = "[Keine Belegart gefunden]"
ReadOnlyEditor.ReadOnly = True

View File

@ -4,8 +4,8 @@ Public Class BaseClass
Public ReadOnly LogConfig As LogConfig
Public ReadOnly Logger As Logger
Public Sub New(pLogConfig As LogConfig, pLogger As Logger)
Public Sub New(pLogConfig As LogConfig)
LogConfig = pLogConfig
Logger = pLogger
Logger = LogConfig.GetLogger()
End Sub
End Class

View File

@ -23,7 +23,7 @@ Namespace Documents
End Structure
Public Sub New(pLogConfig As LogConfig, pWinline As WinlineData, pMappingConfig As MappingConfig, pTemplateConfig As TemplateConfig)
MyBase.New(pLogConfig, pLogConfig.GetLogger())
MyBase.New(pLogConfig)
Winline = pWinline
MappingConfig = pMappingConfig
TemplateConfig = pTemplateConfig
@ -203,7 +203,8 @@ Namespace Documents
oFields.Add(oColumn.Name, New DocumentRow.FieldValue With {
.DataType = oColumn.Type,
.IsRequired = oColumn.IsRequired,
.SortKey = oColumn.OrderKey
.SortKey = oColumn.OrderKey,
.IsVirtual = True
})
Next

View File

@ -1,2 +1,36 @@
Friend Class Helpers
Imports DigitalData.Modules.Logging
Public Class Helpers
Inherits BaseClass
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig)
End Sub
Public Function GetDateDirectory(pBaseDirectory As String)
Dim oDateDirectory = GetDateString()
Dim oFinalDirectory As String = IO.Path.Combine(pBaseDirectory, oDateDirectory)
If IO.Directory.Exists(oFinalDirectory) = False Then
Try
IO.Directory.CreateDirectory(oFinalDirectory)
Catch ex As Exception
Logger.Error(ex)
End Try
End If
Return oFinalDirectory
End Function
Public Function GetDateString() As String
Return $"{Now:yyyy\\MM\\dd}"
End Function
Public Function GetDateTimeString() As String
Return $"{Now:yyyy-MM-dd_hh-mm-ffff}"
End Function
Public Function GetFilenameWithSuffix(pBaseString As String, pSuffix As String, pExtension As String)
Return $"{pBaseString}-{pSuffix}.{pExtension}"
End Function
End Class

View File

@ -4,7 +4,7 @@ Imports DigitalData.Modules.Logging
Public Class Serializer
Inherits BaseClass
Public Sub New(pLogConfig As LogConfig)
MyBase.New(pLogConfig, pLogConfig.GetLogger())
MyBase.New(pLogConfig)
End Sub
Public Function GetSerializer(pSchemaType As Type) As XmlSerializer

View File

@ -4,6 +4,18 @@
Public Property OutputDirectory As String = ""
Public Property TemplateDirectory As String = ""
Public ReadOnly Property OutputReportDirectory
Get
Return IO.Path.Combine(OutputDirectory, "Reports")
End Get
End Property
Public ReadOnly Property OutputWebserviceDirectory
Get
Return IO.Path.Combine(OutputDirectory, "WebService")
End Get
End Property
Public Property Webservice As New WebServiceConfig()
Public Property DefaultYearOverride As Integer = 0

View File

@ -23,7 +23,7 @@ Namespace Templates
Private Const SQL_TBEDI_XML_TEMPLATES = "SELECT * FROM [DD_ECM].[dbo].[TBEDI_XML_TEMPLATES]"
Public Sub New(pLogConfig As LogConfig, pMSSQL As MSSQLServer)
MyBase.New(pLogConfig, pLogConfig.GetLogger)
MyBase.New(pLogConfig)
Database = pMSSQL
End Sub

View File

@ -1,6 +1,6 @@
Imports System.Xml
Imports System.Net.Http
Imports System.Text
Imports System.Net.Http
Imports System.Xml
Imports DigitalData.Modules.Logging
Imports MultiTool.Shared.Documents
Imports MultiTool.Shared.Templates.GeneralConfig
@ -12,15 +12,17 @@ Namespace Winline
Private ReadOnly Config As WebServiceConfig
Private ReadOnly Serializer As Serializer
Private ReadOnly AppDataPath As String
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, pAppDataPath As String)
MyBase.New(pLogConfig, pLogConfig.GetLogger())
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
AppDataPath = pAppDataPath
OutputDirectory = pOutputDirectoryPath
End Sub
Public Async Function TransferDocumentToWinline(pDocument As Document, pMandator As Mandator, Optional pIsTest As Boolean = False) As Task(Of Boolean)
@ -28,31 +30,27 @@ Namespace Winline
Dim oWS = Config
' --- Get and create path for request/response files
Dim oPath As String = GetBaseWebServicePath()
If IO.Directory.Exists(oPath) = False Then
IO.Directory.CreateDirectory(oPath)
End If
Dim oOutputDirectory = Helpers.GetDateDirectory(OutputDirectory)
RaiseEvent WebServiceProgress(Me, "Einstellungen laden")
' --- Build all teh filenamez and pathz
Dim oBaseFileName As String = GetBaseFilenameForRequest()
Dim oFileName = GetXmlFilenameWithSuffix(oBaseFileName, "Request", "xml")
Dim oBaseFileName As String = Helpers.GetDateTimeString()
Dim oFileName = Helpers.GetFilenameWithSuffix(oBaseFileName, "Request", "xml")
' Relative Path for Webservice Call
Dim oImportRelativeFilePath = IO.Path.Combine(GetDateSubDirectoryPath(oWS.ImportRelativePath), oFileName)
Dim oImportRelativeFilePath = IO.Path.Combine(Helpers.GetDateDirectory(oWS.ImportRelativePath), oFileName)
' Absolute Path to copy Request file
Dim oImportAbsolutePath = IO.Path.Combine(oWS.ImportBasePath, oWS.ImportRelativePath)
Dim oImportAbsoluteFilePath = IO.Path.Combine(GetDateSubDirectoryPath(oImportAbsolutePath), oFileName)
Dim oImportAbsoluteFilePath = IO.Path.Combine(Helpers.GetDateDirectory(oImportAbsolutePath), oFileName)
' --- Serialize Data into XML string
RaiseEvent WebServiceProgress(Me, "Dateien schreiben")
Dim oOutputFilePath = IO.Path.Combine(GetBaseWebServicePath(), oFileName)
Dim oOutputFilePath = IO.Path.Combine(oOutputDirectory, oFileName)
IO.File.WriteAllBytes(oOutputFilePath, oBytes)
' --- Copy file to Winline Import Directory
@ -91,7 +89,7 @@ Namespace Winline
' --- Bring the action!
Try
Dim oResponse As HttpResponseMessage = Await oClient.GetAsync(oURL)
Await HandleResponse(oResponse, oPath, oBaseFileName)
Await HandleResponse(oResponse, oOutputDirectory, oBaseFileName)
Return True
Catch ex As Exception
@ -102,7 +100,7 @@ Namespace Winline
End Try
End Function
Private Async Function HandleResponse(pResponse As HttpResponseMessage, pPath As String, pBaseFileNAme As String) As Task
Private Async Function HandleResponse(pResponse As HttpResponseMessage, pOutputPath As String, pBaseFileNAme As String) As Task
pResponse.EnsureSuccessStatusCode()
Dim oResponseBody As String = Await pResponse.Content.ReadAsStringAsync()
Dim oContentType = pResponse.Content.Headers.ContentType.MediaType
@ -112,7 +110,7 @@ Namespace Winline
Select Case oContentType
Case "text/xml"
WriteResponseFile(pPath, pBaseFileNAme, oResponseBody, "xml")
WriteResponseFile(pOutputPath, pBaseFileNAme, oResponseBody, "xml")
Dim oBytes As Byte() = Encoding.UTF8.GetBytes(oResponseBody)
Using oStream As New IO.MemoryStream(oBytes)
@ -139,7 +137,7 @@ Namespace Winline
End Using
Case "text/html"
WriteResponseFile(pPath, pBaseFileNAme, oResponseBody, "txt")
WriteResponseFile(pOutputPath, pBaseFileNAme, oResponseBody, "txt")
Throw New ApplicationException(oResponseBody)
@ -150,7 +148,7 @@ Namespace Winline
Private Function WriteResponseFile(pPath As String, pBaseFileName As String, pResponseBody As String, pExtension As String)
Try
Dim oRequestFileName As String = GetXmlFilenameWithSuffix(pBaseFileName, "Response", pExtension)
Dim oRequestFileName As String = Helpers.GetFilenameWithSuffix(pBaseFileName, "Response", pExtension)
Dim oFilePath As String = IO.Path.Combine(pPath, oRequestFileName)
IO.File.WriteAllText(oFilePath, pResponseBody)
@ -200,36 +198,6 @@ Namespace Winline
Return oStream.ToArray()
End Using
End Function
Private Function GetBaseWebServicePath() As String
Return IO.Path.Combine(AppDataPath, "WebService")
End Function
Private Function GetBaseFilenameForRequest() As String
Return $"{Now:yyyy-MM-dd_hh-mm-ffff}"
End Function
Private Function GetXmlFilenameWithSuffix(pBaseString As String, pSuffix As String, pExtension As String)
Return $"{pBaseString}-{pSuffix}.{pExtension}"
End Function
Private Function GetDateSubDirectoryPath(pBasePath As String)
Dim oDirectoryPath As String = Now.ToString("yyyy\\MM\\dd")
Dim oFullPath As String = IO.Path.Combine(pBasePath, oDirectoryPath)
If IO.Directory.Exists(oFullPath) = False Then
Try
IO.Directory.CreateDirectory(oFullPath)
Return oFullPath
Catch ex As Exception
Logger.Error(ex)
Return Nothing
End Try
Else
Return oFullPath
End If
End Function
End Class
End Namespace

View File

@ -22,7 +22,7 @@ Namespace Winline
Public Years As List(Of Integer)
Public Sub New(pLogConfig As LogConfig, pDatabase As MSSQLServer, pConfig As GeneralConfig, pMappingConfig As MappingConfig, pMandatorConfig As MandatorConfig)
MyBase.New(pLogConfig, pLogConfig.GetLogger())
MyBase.New(pLogConfig)
Database = pDatabase
Config = pConfig
MandatorConfig = pMandatorConfig
@ -419,14 +419,15 @@ Namespace Winline
Dim oArticleNumber As String = ItemEx(oRow, V21_MAINARTICLENUMBER, String.Empty)
' EAN was found, now we need to check it against the Regex of the current Mandantor, if one exists
Dim oMappingConfigItem = MappingConfig.Items.
Dim oMappingConfigItems = MappingConfig.Items.
Where(Function(item) item.DestinationName = "MANDATOR" And item.DestinationValue = oMandator.Id And item.SourceName = "ARTICLE").
SingleOrDefault()
If oMappingConfigItem IsNot Nothing Then
ToList()
' If not match was found, continune to next mandator.
' For a catch all mandator, a regex like ".+" is needed.
For Each oItem In oMappingConfigItems
Try
Dim oRegex As New Regex(oMappingConfigItem.SourceRegex)
Dim oRegex As New Regex(oItem.SourceRegex)
Dim oMatch = oRegex.Match(oArticleNumber)
' If ArticleNumber matches the regex, we assign it and exit
@ -439,13 +440,9 @@ Namespace Winline
Logger.Error(ex)
Logger.Warn("Regex [{0}] could not be parsed. Skipping.", oMandator.Regex)
End Try
Else
Continue For
End If
Next
Next
Next ' CONFIG ITEM
Next ' MANDATOR
Next ' EAN
Return Nothing
End Function