Add year combobox, fix filenames

This commit is contained in:
Jonathan Jenne 2022-03-22 16:27:12 +01:00
parent ce78dea8cb
commit f289a1d34c
5 changed files with 85 additions and 38 deletions

View File

@ -13,7 +13,7 @@ Imports System.Runtime.InteropServices
<Assembly: AssemblyCompany("Digital Data")>
<Assembly: AssemblyProduct("WebService Multitool")>
<Assembly: AssemblyCopyright("Copyright © 2022")>
<Assembly: AssemblyTrademark("1.2.5.0")>
<Assembly: AssemblyTrademark("1.2.6.0")>
<Assembly: ComVisible(False)>
@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices
' indem Sie "*" wie unten gezeigt eingeben:
' <Assembly: AssemblyVersion("1.0.*")>
<Assembly: AssemblyVersion("1.2.5.0")>
<Assembly: AssemblyVersion("1.2.6.0")>
<Assembly: AssemblyFileVersion("1.0.0.0")>

View File

@ -86,6 +86,8 @@ Partial Class frmExportMain
Me.colName2 = New DevExpress.XtraGrid.Columns.GridColumn()
Me.colId2 = New DevExpress.XtraGrid.Columns.GridColumn()
Me.SplashScreenManager = New DevExpress.XtraSplashScreen.SplashScreenManager(Me, GetType(Global.MultiTool.Form.frmWaitForm), True, True)
Me.comboYear = New DevExpress.XtraEditors.ComboBoxEdit()
Me.LayoutControlItem4 = New DevExpress.XtraLayout.LayoutControlItem()
CType(Me.RibbonControl1, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.GridControlDocuments, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.GridViewDocuments, System.ComponentModel.ISupportInitialize).BeginInit()
@ -126,6 +128,8 @@ Partial Class frmExportMain
CType(Me.LayoutControlItem8, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.LayoutControlItem10, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.LayoutControlItem9, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.comboYear.Properties, System.ComponentModel.ISupportInitialize).BeginInit()
CType(Me.LayoutControlItem4, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'RibbonControl1
@ -412,6 +416,7 @@ Partial Class frmExportMain
Me.LayoutControl1.Controls.Add(Me.dateDocDateTo)
Me.LayoutControl1.Controls.Add(Me.comboDocumentType)
Me.LayoutControl1.Controls.Add(Me.comboDocumentKind)
Me.LayoutControl1.Controls.Add(Me.comboYear)
Me.LayoutControl1.Dock = System.Windows.Forms.DockStyle.Fill
Me.LayoutControl1.Location = New System.Drawing.Point(0, 0)
Me.LayoutControl1.Name = "LayoutControl1"
@ -460,7 +465,7 @@ Partial Class frmExportMain
'dateDocDateFrom
'
Me.dateDocDateFrom.EditValue = Nothing
Me.dateDocDateFrom.Location = New System.Drawing.Point(112, 195)
Me.dateDocDateFrom.Location = New System.Drawing.Point(112, 225)
Me.dateDocDateFrom.MenuManager = Me.RibbonControl1
Me.dateDocDateFrom.Name = "dateDocDateFrom"
Me.dateDocDateFrom.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
@ -473,7 +478,7 @@ Partial Class frmExportMain
'
'lookupAccount
'
Me.lookupAccount.Location = New System.Drawing.Point(112, 105)
Me.lookupAccount.Location = New System.Drawing.Point(112, 135)
Me.lookupAccount.MenuManager = Me.RibbonControl1
Me.lookupAccount.Name = "lookupAccount"
Me.lookupAccount.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo), New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Clear)})
@ -510,7 +515,7 @@ Partial Class frmExportMain
'
'chkShowExported
'
Me.chkShowExported.Location = New System.Drawing.Point(12, 252)
Me.chkShowExported.Location = New System.Drawing.Point(12, 282)
Me.chkShowExported.MenuManager = Me.RibbonControl1
Me.chkShowExported.Name = "chkShowExported"
Me.chkShowExported.Properties.Caption = "Bereits exportierte Belege anzeigen"
@ -520,7 +525,7 @@ Partial Class frmExportMain
'
'txtDocumentFrom
'
Me.txtDocumentFrom.Location = New System.Drawing.Point(112, 135)
Me.txtDocumentFrom.Location = New System.Drawing.Point(112, 165)
Me.txtDocumentFrom.MenuManager = Me.RibbonControl1
Me.txtDocumentFrom.Name = "txtDocumentFrom"
Me.txtDocumentFrom.Size = New System.Drawing.Size(171, 20)
@ -529,7 +534,7 @@ Partial Class frmExportMain
'
'txtDocumentTo
'
Me.txtDocumentTo.Location = New System.Drawing.Point(112, 165)
Me.txtDocumentTo.Location = New System.Drawing.Point(112, 195)
Me.txtDocumentTo.MenuManager = Me.RibbonControl1
Me.txtDocumentTo.Name = "txtDocumentTo"
Me.txtDocumentTo.Size = New System.Drawing.Size(171, 20)
@ -539,7 +544,7 @@ Partial Class frmExportMain
'dateDocDateTo
'
Me.dateDocDateTo.EditValue = Nothing
Me.dateDocDateTo.Location = New System.Drawing.Point(112, 225)
Me.dateDocDateTo.Location = New System.Drawing.Point(112, 255)
Me.dateDocDateTo.MenuManager = Me.RibbonControl1
Me.dateDocDateTo.Name = "dateDocDateTo"
Me.dateDocDateTo.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
@ -550,7 +555,7 @@ Partial Class frmExportMain
'
'comboDocumentType
'
Me.comboDocumentType.Location = New System.Drawing.Point(112, 45)
Me.comboDocumentType.Location = New System.Drawing.Point(112, 75)
Me.comboDocumentType.MenuManager = Me.RibbonControl1
Me.comboDocumentType.Name = "comboDocumentType"
Me.comboDocumentType.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
@ -570,7 +575,7 @@ Partial Class frmExportMain
'
'comboDocumentKind
'
Me.comboDocumentKind.Location = New System.Drawing.Point(112, 75)
Me.comboDocumentKind.Location = New System.Drawing.Point(112, 105)
Me.comboDocumentKind.MenuManager = Me.RibbonControl1
Me.comboDocumentKind.Name = "comboDocumentKind"
Me.comboDocumentKind.Properties.AllowMultiSelect = True
@ -583,7 +588,7 @@ Partial Class frmExportMain
'
Me.Root.EnableIndentsWithoutBorders = DevExpress.Utils.DefaultBoolean.[True]
Me.Root.GroupBordersVisible = False
Me.Root.Items.AddRange(New DevExpress.XtraLayout.BaseLayoutItem() {Me.LayoutControlItem1, Me.EmptySpaceItem1, Me.LayoutControlItem3, Me.LayoutControlItem2, Me.LayoutControlItem5, Me.LayoutControlItem6, Me.LayoutControlItem7, Me.LayoutControlItem8, Me.LayoutControlItem10, Me.LayoutControlItem9})
Me.Root.Items.AddRange(New DevExpress.XtraLayout.BaseLayoutItem() {Me.LayoutControlItem1, Me.EmptySpaceItem1, Me.LayoutControlItem3, Me.LayoutControlItem2, Me.LayoutControlItem5, Me.LayoutControlItem6, Me.LayoutControlItem7, Me.LayoutControlItem8, Me.LayoutControlItem10, Me.LayoutControlItem9, Me.LayoutControlItem4})
Me.Root.Name = "Root"
Me.Root.Size = New System.Drawing.Size(298, 538)
Me.Root.TextVisible = False
@ -601,15 +606,15 @@ Partial Class frmExportMain
'EmptySpaceItem1
'
Me.EmptySpaceItem1.AllowHotTrack = False
Me.EmptySpaceItem1.Location = New System.Drawing.Point(0, 264)
Me.EmptySpaceItem1.Location = New System.Drawing.Point(0, 294)
Me.EmptySpaceItem1.Name = "EmptySpaceItem1"
Me.EmptySpaceItem1.Size = New System.Drawing.Size(278, 254)
Me.EmptySpaceItem1.Size = New System.Drawing.Size(278, 224)
Me.EmptySpaceItem1.TextSize = New System.Drawing.Size(0, 0)
'
'LayoutControlItem3
'
Me.LayoutControlItem3.Control = Me.lookupAccount
Me.LayoutControlItem3.Location = New System.Drawing.Point(0, 90)
Me.LayoutControlItem3.Location = New System.Drawing.Point(0, 120)
Me.LayoutControlItem3.Name = "LayoutControlItem3"
Me.LayoutControlItem3.Padding = New DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5)
Me.LayoutControlItem3.Size = New System.Drawing.Size(278, 30)
@ -619,7 +624,7 @@ Partial Class frmExportMain
'LayoutControlItem2
'
Me.LayoutControlItem2.Control = Me.dateDocDateFrom
Me.LayoutControlItem2.Location = New System.Drawing.Point(0, 180)
Me.LayoutControlItem2.Location = New System.Drawing.Point(0, 210)
Me.LayoutControlItem2.Name = "LayoutControlItem2"
Me.LayoutControlItem2.Padding = New DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5)
Me.LayoutControlItem2.Size = New System.Drawing.Size(278, 30)
@ -629,7 +634,7 @@ Partial Class frmExportMain
'LayoutControlItem5
'
Me.LayoutControlItem5.Control = Me.chkShowExported
Me.LayoutControlItem5.Location = New System.Drawing.Point(0, 240)
Me.LayoutControlItem5.Location = New System.Drawing.Point(0, 270)
Me.LayoutControlItem5.Name = "LayoutControlItem5"
Me.LayoutControlItem5.Size = New System.Drawing.Size(278, 24)
Me.LayoutControlItem5.TextSize = New System.Drawing.Size(0, 0)
@ -638,7 +643,7 @@ Partial Class frmExportMain
'LayoutControlItem6
'
Me.LayoutControlItem6.Control = Me.txtDocumentFrom
Me.LayoutControlItem6.Location = New System.Drawing.Point(0, 120)
Me.LayoutControlItem6.Location = New System.Drawing.Point(0, 150)
Me.LayoutControlItem6.Name = "LayoutControlItem6"
Me.LayoutControlItem6.Padding = New DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5)
Me.LayoutControlItem6.Size = New System.Drawing.Size(278, 30)
@ -648,7 +653,7 @@ Partial Class frmExportMain
'LayoutControlItem7
'
Me.LayoutControlItem7.Control = Me.txtDocumentTo
Me.LayoutControlItem7.Location = New System.Drawing.Point(0, 150)
Me.LayoutControlItem7.Location = New System.Drawing.Point(0, 180)
Me.LayoutControlItem7.Name = "LayoutControlItem7"
Me.LayoutControlItem7.Padding = New DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5)
Me.LayoutControlItem7.Size = New System.Drawing.Size(278, 30)
@ -658,7 +663,7 @@ Partial Class frmExportMain
'LayoutControlItem8
'
Me.LayoutControlItem8.Control = Me.dateDocDateTo
Me.LayoutControlItem8.Location = New System.Drawing.Point(0, 210)
Me.LayoutControlItem8.Location = New System.Drawing.Point(0, 240)
Me.LayoutControlItem8.Name = "LayoutControlItem8"
Me.LayoutControlItem8.Padding = New DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5)
Me.LayoutControlItem8.Size = New System.Drawing.Size(278, 30)
@ -668,7 +673,7 @@ Partial Class frmExportMain
'LayoutControlItem10
'
Me.LayoutControlItem10.Control = Me.comboDocumentKind
Me.LayoutControlItem10.Location = New System.Drawing.Point(0, 60)
Me.LayoutControlItem10.Location = New System.Drawing.Point(0, 90)
Me.LayoutControlItem10.Name = "LayoutControlItem10"
Me.LayoutControlItem10.Padding = New DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5)
Me.LayoutControlItem10.Size = New System.Drawing.Size(278, 30)
@ -678,7 +683,7 @@ Partial Class frmExportMain
'LayoutControlItem9
'
Me.LayoutControlItem9.Control = Me.comboDocumentType
Me.LayoutControlItem9.Location = New System.Drawing.Point(0, 30)
Me.LayoutControlItem9.Location = New System.Drawing.Point(0, 60)
Me.LayoutControlItem9.Name = "LayoutControlItem9"
Me.LayoutControlItem9.Padding = New DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5)
Me.LayoutControlItem9.Size = New System.Drawing.Size(278, 30)
@ -717,6 +722,26 @@ Partial Class frmExportMain
'
Me.SplashScreenManager.ClosingDelay = 500
'
'comboYear
'
Me.comboYear.Location = New System.Drawing.Point(112, 45)
Me.comboYear.MenuManager = Me.RibbonControl1
Me.comboYear.Name = "comboYear"
Me.comboYear.Properties.Buttons.AddRange(New DevExpress.XtraEditors.Controls.EditorButton() {New DevExpress.XtraEditors.Controls.EditorButton(DevExpress.XtraEditors.Controls.ButtonPredefines.Combo)})
Me.comboYear.Size = New System.Drawing.Size(171, 20)
Me.comboYear.StyleController = Me.LayoutControl1
Me.comboYear.TabIndex = 15
'
'LayoutControlItem4
'
Me.LayoutControlItem4.Control = Me.comboYear
Me.LayoutControlItem4.Location = New System.Drawing.Point(0, 30)
Me.LayoutControlItem4.Name = "LayoutControlItem4"
Me.LayoutControlItem4.Padding = New DevExpress.XtraLayout.Utils.Padding(5, 5, 5, 5)
Me.LayoutControlItem4.Size = New System.Drawing.Size(278, 30)
Me.LayoutControlItem4.Text = "Wirtschaftsjahr"
Me.LayoutControlItem4.TextSize = New System.Drawing.Size(85, 13)
'
'frmExportMain
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
@ -772,6 +797,8 @@ Partial Class frmExportMain
CType(Me.LayoutControlItem8, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.LayoutControlItem10, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.LayoutControlItem9, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.comboYear.Properties, System.ComponentModel.ISupportInitialize).EndInit()
CType(Me.LayoutControlItem4, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
Me.PerformLayout()
@ -840,4 +867,6 @@ Partial Class frmExportMain
Friend WithEvents colDocumentKind As DevExpress.XtraGrid.Columns.GridColumn
Friend WithEvents comboDocumentKind As DevExpress.XtraEditors.CheckedComboBoxEdit
Friend WithEvents LayoutControlItem10 As DevExpress.XtraLayout.LayoutControlItem
Friend WithEvents comboYear As DevExpress.XtraEditors.ComboBoxEdit
Friend WithEvents LayoutControlItem4 As DevExpress.XtraLayout.LayoutControlItem
End Class

View File

@ -81,6 +81,8 @@ Public Class frmExportMain
comboDocumentKind.Properties.EditValueType = Repository.EditValueTypeCollection.List
comboDocumentKind.EditValue = New List(Of Object)
comboYear.Properties.Items.AddRange(Winline.Years)
comboDocumentType.Properties.DisplayMember = "Key"
comboDocumentType.Properties.ValueMember = "Value"
comboDocumentType.Properties.DataSource = [Enum].
@ -189,6 +191,7 @@ Public Class frmExportMain
dateDocDateTo.DoValidate()
Dim oMandator = lookupMandator.EditValue
Dim oYear = Utils.NotNull(comboYear.EditValue, 0)
Dim oAccount = lookupAccount.EditValue
Dim oKindsAsObjects As List(Of Object) = comboDocumentKind.EditValue
Dim oKinds As List(Of DocumentKind) = oKindsAsObjects.Cast(Of DocumentKind).ToList()
@ -214,7 +217,8 @@ Public Class frmExportMain
.DateTo = oDateTo,
.ShowExported = oShowExported,
.DocNumberFrom = oDocNumberFrom,
.DocNumberTo = oDocNumberTo
.DocNumberTo = oDocNumberTo,
.Year = oYear
})
GridControlDocuments.DataSource = oDocuments

View File

@ -55,7 +55,7 @@ Namespace Winline
' --- Build all teh filenamez and pathz
Dim oBaseFileName As String = FileEx.GetDateTimeString()
Dim oFileName = FileEx.GetFilenameWithPrefix(oBaseFileName, pTemplate.Name, "xml")
Dim oFileName = $"{pTemplate.Name}-{oBaseFileName}-Request.xml"
' --- Get and create path for request/response files
Dim oOutputDirectory = FileEx.CreateDateDirectory(pTemplate.OutputWebserviceDirectory)
@ -124,18 +124,18 @@ Namespace Winline
End Try
End Function
Private Async Function HandleImportResponse(pResponse As HttpResponseMessage, pTemplate As Template, pBaseFileNAme As String) As Task
Private Async Function HandleImportResponse(pResponse As HttpResponseMessage, pTemplate As Template, pBaseFileName As String) As Task
pResponse.EnsureSuccessStatusCode()
Dim oResponseBody As String = Await pResponse.Content.ReadAsStringAsync()
Dim oContentType = pResponse.Content.Headers.ContentType.MediaType
Dim oSerializer = Serializer.GetSerializer(GetType(Templates.Entities.MESOWebServiceResult))
Dim oOutputDirectory = FileEx.CreateDateDirectory(pTemplate.OutputWebserviceDirectory)
RaiseEvent WebServiceProgress(Me, "Antwort verarbeiten")
Select Case oContentType
Case "text/xml"
Dim oOutputDirectory = FileEx.CreateDateDirectory(pTemplate.OutputWebserviceDirectory)
WriteResponseFileWithSuffix(oOutputDirectory, pBaseFileNAme, oResponseBody, "xml", $"{pTemplate.Name}-Response")
WriteResponseFile(oOutputDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}-Response.xml")
Dim oBytes As Byte() = Encoding.UTF8.GetBytes(oResponseBody)
Using oStream As New IO.MemoryStream(oBytes)
@ -164,7 +164,7 @@ Namespace Winline
End Using
Case "text/html"
WriteResponseFileWithSuffix(pTemplate.OutputWebserviceDirectory, pBaseFileNAme, oResponseBody, "txt", $"{pTemplate.Name}-Response")
WriteResponseFile(oOutputDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}-Response.xml")
Throw New WebServiceException(oResponseBody)
@ -221,15 +221,12 @@ Namespace Winline
' --- Build all teh filenamez and pathz
Dim oBaseFileName As String = FileEx.GetDateTimeString()
Dim oFileName = FileEx.GetFilenameWithPrefix(oBaseFileName, pTemplate.Name, "xml")
Dim oFileName = $"{pTemplate.Name}-{oBaseFileName}.xml"
'Dim oFileName = FileEx.GetFilenameWithPrefix(oBaseFileName, pTemplate.Name, "xml")
' Save the filename to the document
pDocument.FilenameExport = oFileName
' Absolute Path to copy Request file
Dim oImportAbsolutePath = IO.Path.Combine(oWS.ImportBasePath, oWS.ImportRelativePath)
Dim oImportAbsoluteFilePath = IO.Path.Combine(FileEx.GetDateDirectory(oImportAbsolutePath), oFileName)
RaiseEvent WebServiceProgress(Me, "Dateien schreiben")
' --- Prepare URL and HTTP Client
@ -282,14 +279,14 @@ Namespace Winline
Select Case oContentType
Case "text/xml"
' Webservice
WriteResponseFileWithSuffix(pTemplate.OutputWebserviceDirectory, pBaseFileName, oResponseBody, "xml", pTemplate.Name)
WriteResponseFile(pTemplate.OutputWebserviceDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}-Response.xml")
' XML
WriteResponseFileWithSuffix(pTemplate.OutputXmlFileDirectory, pBaseFileName, oResponseBody, "xml", pTemplate.Name)
WriteResponseFile(pTemplate.OutputXmlFileDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}.xml")
' Archive
WriteResponseFileWithSuffix(FileEx.CreateDateDirectory(pTemplate.ArchiveDirectory), pBaseFileName, oResponseBody, "xml", pTemplate.Name)
WriteResponseFile(FileEx.CreateDateDirectory(pTemplate.ArchiveDirectory), oResponseBody, $"{pTemplate.Name}-{pBaseFileName}.xml")
Case "text/html"
WriteResponseFileWithSuffix(pTemplate.OutputWebserviceDirectory, pBaseFileName, oResponseBody, "txt", pTemplate.Name)
WriteResponseFile(pTemplate.OutputWebserviceDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}-Response.txt")
Throw New ApplicationException(oResponseBody)
@ -388,6 +385,18 @@ Namespace Winline
Return False
End Try
End Function
Private Function WriteResponseFile(pPath As String, pResponseBody As String, pFileName As String) As Boolean
Try
Dim oFilePath As String = IO.Path.Combine(pPath, pFileName)
IO.File.WriteAllText(oFilePath, pResponseBody)
Return True
Catch ex As Exception
Logger.Error(ex)
Return False
End Try
End Function
End Class
End Namespace

View File

@ -20,7 +20,7 @@ Namespace Winline
Public Property Mandators As New List(Of Mandator)
Public Property DocumentKinds As New List(Of DocumentKind)
Public Years As List(Of Integer)
Public Property 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, pDatabase)
@ -50,6 +50,7 @@ Namespace Winline
Public Property DocNumberFrom As String
Public Property DocNumberTo As String
Public Property ShowExported As Boolean
Public Property Year As Integer
End Class
@ -594,12 +595,16 @@ Namespace Winline
Try
Dim oYear As Integer = Config.GetWinLineYear()
If pOptions.Year > 0 Then
oYear = Config.GetWinLineYear(pOptions.Year)
End If
Dim oTypeConstraint
Select Case pDocumentType
Case DocumentType.OutgoingOffer
oTypeConstraint = $"T.c137 = 2 AND c139 = 1 AND "
Case DocumentType.OutgoingOffer
Case DocumentType.OutgoingOrder
oTypeConstraint = $"T.c137 = 2 AND c139 = 2 AND "
Case DocumentType.OutgoingDeliveryNote