From 436293cbb7c5ebca197b7d14201bbeabd96ccdbf Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 30 Nov 2021 12:17:26 +0100 Subject: [PATCH] Export report to Directory --- MultiTool.Form/GridLoader.vb | 2 +- MultiTool.Form/MyApplication.vb | 3 + .../Reports/OrderReport.Designer.vb | 88 +++++++++---------- MultiTool.Form/frmImportMain.Designer.vb | 27 ++---- MultiTool.Form/frmImportMain.resx | 21 ++--- MultiTool.Form/frmImportMain.vb | 26 +++--- MultiTool.Form/frmMain.vb | 1 + MultiTool.Form/frmRowEditor.vb | 5 ++ MultiTool.Shared/BaseClass.vb | 4 +- MultiTool.Shared/Documents/DocumentLoader.vb | 5 +- MultiTool.Shared/Helpers.vb | 36 +++++++- MultiTool.Shared/Serializer.vb | 2 +- MultiTool.Shared/Templates/GeneralConfig.vb | 12 +++ MultiTool.Shared/Templates/TemplateLoader.vb | 2 +- MultiTool.Shared/Winline/WebServiceData.vb | 70 ++++----------- MultiTool.Shared/Winline/WinlineData.vb | 23 +++-- 16 files changed, 166 insertions(+), 161 deletions(-) diff --git a/MultiTool.Form/GridLoader.vb b/MultiTool.Form/GridLoader.vb index ca92cad..4487c08 100644 --- a/MultiTool.Form/GridLoader.vb +++ b/MultiTool.Form/GridLoader.vb @@ -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 diff --git a/MultiTool.Form/MyApplication.vb b/MultiTool.Form/MyApplication.vb index 10ddee5..8e5a51c 100644 --- a/MultiTool.Form/MyApplication.vb +++ b/MultiTool.Form/MyApplication.vb @@ -1,4 +1,5 @@ Imports MultiTool.Shared.Templates +Imports MultiTool.Shared Namespace My @@ -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 diff --git a/MultiTool.Form/Reports/OrderReport.Designer.vb b/MultiTool.Form/Reports/OrderReport.Designer.vb index d2b671a..8eed455 100644 --- a/MultiTool.Form/Reports/OrderReport.Designer.vb +++ b/MultiTool.Form/Reports/OrderReport.Designer.vb @@ -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}) diff --git a/MultiTool.Form/frmImportMain.Designer.vb b/MultiTool.Form/frmImportMain.Designer.vb index 18785cd..cbe2265 100644 --- a/MultiTool.Form/frmImportMain.Designer.vb +++ b/MultiTool.Form/frmImportMain.Designer.vb @@ -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 diff --git a/MultiTool.Form/frmImportMain.resx b/MultiTool.Form/frmImportMain.resx index a8d7ab9..2790466 100644 --- a/MultiTool.Form/frmImportMain.resx +++ b/MultiTool.Form/frmImportMain.resx @@ -536,6 +536,12 @@ DevExpress.XtraBars.Ribbon.RibbonPageGroup, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + + RibbonPageGroup2 + + + DevExpress.XtraBars.Ribbon.RibbonPageGroup, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a + RepositoryItemComboBox1 @@ -602,18 +608,6 @@ DevExpress.XtraSplashScreen.SplashScreenManager, DevExpress.XtraEditors.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a - - RibbonPageGroup2 - - - DevExpress.XtraBars.Ribbon.RibbonPageGroup, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a - - - BarButtonItem2 - - - DevExpress.XtraBars.BarButtonItem, DevExpress.XtraBars.v19.2, Version=19.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a - frmImportMain @@ -626,9 +620,6 @@ BarButtonItem1 - - BarButtonItem2 - 0, 0 diff --git a/MultiTool.Form/frmImportMain.vb b/MultiTool.Form/frmImportMain.vb index ff0b63a..10d1b4c 100644 --- a/MultiTool.Form/frmImportMain.vb +++ b/MultiTool.Form/frmImportMain.vb @@ -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)) diff --git a/MultiTool.Form/frmMain.vb b/MultiTool.Form/frmMain.vb index 09592b1..9b9a342 100644 --- a/MultiTool.Form/frmMain.vb +++ b/MultiTool.Form/frmMain.vb @@ -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 diff --git a/MultiTool.Form/frmRowEditor.vb b/MultiTool.Form/frmRowEditor.vb index f136f8e..4671b55 100644 --- a/MultiTool.Form/frmRowEditor.vb +++ b/MultiTool.Form/frmRowEditor.vb @@ -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 diff --git a/MultiTool.Shared/BaseClass.vb b/MultiTool.Shared/BaseClass.vb index 61d97ae..0ecd333 100644 --- a/MultiTool.Shared/BaseClass.vb +++ b/MultiTool.Shared/BaseClass.vb @@ -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 diff --git a/MultiTool.Shared/Documents/DocumentLoader.vb b/MultiTool.Shared/Documents/DocumentLoader.vb index 86c9e58..4b01700 100644 --- a/MultiTool.Shared/Documents/DocumentLoader.vb +++ b/MultiTool.Shared/Documents/DocumentLoader.vb @@ -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 diff --git a/MultiTool.Shared/Helpers.vb b/MultiTool.Shared/Helpers.vb index a3496ab..8718f31 100644 --- a/MultiTool.Shared/Helpers.vb +++ b/MultiTool.Shared/Helpers.vb @@ -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 diff --git a/MultiTool.Shared/Serializer.vb b/MultiTool.Shared/Serializer.vb index 260b14c..5ae176e 100644 --- a/MultiTool.Shared/Serializer.vb +++ b/MultiTool.Shared/Serializer.vb @@ -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 diff --git a/MultiTool.Shared/Templates/GeneralConfig.vb b/MultiTool.Shared/Templates/GeneralConfig.vb index 4cf0d01..e787864 100644 --- a/MultiTool.Shared/Templates/GeneralConfig.vb +++ b/MultiTool.Shared/Templates/GeneralConfig.vb @@ -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 diff --git a/MultiTool.Shared/Templates/TemplateLoader.vb b/MultiTool.Shared/Templates/TemplateLoader.vb index 1e4004a..fb92759 100644 --- a/MultiTool.Shared/Templates/TemplateLoader.vb +++ b/MultiTool.Shared/Templates/TemplateLoader.vb @@ -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 diff --git a/MultiTool.Shared/Winline/WebServiceData.vb b/MultiTool.Shared/Winline/WebServiceData.vb index d721ece..dc8e509 100644 --- a/MultiTool.Shared/Winline/WebServiceData.vb +++ b/MultiTool.Shared/Winline/WebServiceData.vb @@ -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 \ No newline at end of file diff --git a/MultiTool.Shared/Winline/WinlineData.vb b/MultiTool.Shared/Winline/WinlineData.vb index 6823dd7..d1a1faa 100644 --- a/MultiTool.Shared/Winline/WinlineData.vb +++ b/MultiTool.Shared/Winline/WinlineData.vb @@ -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