This commit is contained in:
2022-09-30 22:18:26 +02:00
parent 1e7312208e
commit 265cfe1f18
9 changed files with 596 additions and 104 deletions

View File

@@ -357,7 +357,7 @@ Public Class frmMDMNachrichtenVerarbeitung
Exit Sub
End If
For i = 1 To 3
For i = 1 To 5
For Each d In System.IO.Directory.GetFiles(VERARBEITUNGS_PFAD)
Try
@@ -371,59 +371,94 @@ Public Class frmMDMNachrichtenVerarbeitung
' If fi.Extension = ".edi" Then
Dim alreadyMoved = False
If fi.Extension.ToLower = ".csv" Then
'------------------------------------------------------------------------------------------------------------------------------
' PLOSE
'------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------
' PLOSE
'------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------
'------------------ DETAIL ------------------
'------------------------------------------
Select Case i
Case 1
'TC: Versandbestätigung
Select Case i
Case 1
'------------------------------------------
'------------------ DETAIL ------------------
'------------------------------------------
If fi.Extension.ToLower = ".csv" Then
If Not found And cGetMsgType.isPLOSE_Detail(d) Then
If readPLOSE_Detail(d) <> "" Then found = True
' If bezugsNr <> "" Then addDGVEinarbeitung("NCTS: Versandbestätigung", bezugsNr) : found = True
End If
If found Then cntDatenEingelesen += 1
Case 2
'TC: Versandbestätigung
End If
Case 2
'------------------------------------------
'------------------ HEADER ------------------
'------------------------------------------
If fi.Extension.ToLower = ".csv" Then
If Not found And cGetMsgType.isPLOSE_Header(d) Then
If readPLOSE_Header(d) <> "" Then found = True
' If bezugsNr <> "" Then addDGVEinarbeitung("NCTS: Versandbestätigung", bezugsNr) : found = True
End If
If found Then cntDatenEingelesen += 1
Case 3
frmStartOptions.moveFile_DateBack(d, ERROR_PFAD)
End If
Case 3
'------------------------------------------
'------------------ PLOSE_INVData: neues CSV --> Rechnungen + PDF-Link ------------------
'------------------------------------------
If fi.Extension.ToLower = ".csv" Then
If Not found And cGetMsgType.isPLOSE_INVData(d) Then
If readPLOSE_INVData(d) <> "" Then found = True
' ' If bezugsNr <> "" Then addDGVEinarbeitung("NCTS: Versandbestätigung", bezugsNr) : found = True
End If
If found Then cntDatenEingelesen += 1
End If
Case 4
'------------------------------------------
'------------------ PDF ------------------
'------------------------------------------
If fi.Extension.ToLower = ".pdf" Then
found = False
If Not IO.Directory.Exists(ZIEL_PFAD & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then IO.Directory.CreateDirectory(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
'File in Datenarchiv sichern:
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_DATEN", "PLOSE", Now.Year, Now.ToString("yyyyMMdd"), frmStartOptions.getFileName(d))
DS.uploadDataToDATENSERVER(d)
'DatenArchiv-Id in tblPLOSE_Inv_Data Tabelle eintragen (über PDF-Name) :
SQL.doSQL("Update [tblPLOSE_Inv_Data] SET [plInv_daId]='" & DS.da_id & "' where [plInv_PdfFileName] = '" & DS.da_name & "' and [plInv_Einlesedatum] > DATEADD(DAY,-4,getdate()) ", "FMZOLL")
frmStartOptions.moveFile_DateBack(d, ZIEL_PFAD & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
'frmStartOptions.copyFile_DateBack(d, ZIEL_PFAD & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
addDGVEinarbeitung("PDF", DS.da_name)
dgvEinarbeitung.Refresh()
'Eintrag
End If
Case 5
frmStartOptions.moveFile_DateBack(d, ERROR_PFAD)
dsNichtErkannt += 1
End Select
End If
If fi.Extension.ToLower = ".pdf" Then
found = False
If Not IO.Directory.Exists(ZIEL_PFAD & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then IO.Directory.CreateDirectory(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
frmStartOptions.moveFile_DateBack(d, ZIEL_PFAD & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
End If
If True Then
If Not alreadyMoved Then
If found Then
If Not IO.Directory.Exists(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then IO.Directory.CreateDirectory(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
frmStartOptions.moveFile_DateBack(d, ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
End If
If True Then
If Not alreadyMoved Then
If found Then
If Not IO.Directory.Exists(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then IO.Directory.CreateDirectory(ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
frmStartOptions.moveFile_DateBack(d, ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
End If
End If
Me.Refresh()
End If
Me.Refresh()
End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & "Datei: " & Dateiname, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
@@ -723,6 +758,100 @@ Public Class frmMDMNachrichtenVerarbeitung
End Function
Function readPLOSE_INVData(d As String) As String
Try
Dim cnt = 0
readPLOSE_INVData = ""
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(d, Encoding.UTF8)
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(";")
Dim currentRow As String()
Dim fi As FileInfo = New FileInfo(d)
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
If currentRow(0) <> "PloseCode" Then ' Header
If currentRow.Length >= 15 Then
Dim PLOSE_INV As New MDM_Worker.cPLOSE_Inv_Data
PLOSE_INV.plInv_SupplierRechnungsDatum = SQL.isleernothingDateFormatstring(currentRow(7))
PLOSE_INV.plInv_SupplierRechnungsNr = SQL.isleernothing(currentRow(8))
PLOSE_INV.plInv_SupplierCountry = SQL.isleernothing(currentRow(6))
PLOSE_INV.plInv_Lieferant = SQL.isleernothing(currentRow(4))
PLOSE_INV.plInv_LieferantCode = SQL.isleernothing(currentRow(3))
PLOSE_INV.plInv_LieferantUID = SQL.isleernothing(currentRow(5))
'PLOSE_INV.plInv_RechnungsJahr = SQL.isleernothing(currentRow(7)) --> JAHR
PLOSE_INV.plInv_PdfFileName = SQL.isleernothing(currentRow(14))
PLOSE_INV.plInv_Einlesedatum = Now.ToShortDateString
PLOSE_INV.plInv_Datensatztyp = "PDF"
PLOSE_INV.plInv_PLOSEKundennummer = SQL.isleernothing(currentRow(0))
PLOSE_INV.plInv_Firmenname = SQL.isleernothing(currentRow(1))
' PLOSE_INV.plInv_DatumTransaktion = SQL.isleernothing(currentRow(0))
' PLOSE_INV.plInv_Produktbeschreibung = SQL.isleernothing(currentRow(0))
PLOSE_INV.plInv_Services = SQL.isleernothing(currentRow(13))
PLOSE_INV.plInv_Nettobetrag = CDbl(CDbl(SQL.isNullReturnValue(currentRow(9), 0).replace(".", ",")) + CDbl(SQL.isNullReturnValue(currentRow(11), 0).replace(".", ",")))
PLOSE_INV.plInv_MWSTBetrag = CDbl(SQL.isNullReturnValue(currentRow(10), 0).replace(".", ","))
PLOSE_INV.plInv_Bruttobetrag = CDbl(SQL.isNullReturnValue(currentRow(12), 0).replace(".", ","))
' [plInv_daId]
PLOSE_INV.plInv_Dateiname = fi.Name
''''''''''''
If PLOSE_INV.SAVE() Then
' UPDATE tblPLOSE_Details:
SQL.doSQL("UPDATE [tblPLOSE_Details] SET [plose_plInvId] ='" & PLOSE_INV.plInv_Id & "' where plose_SupplierRechnungsNr='" & PLOSE_INV.plInv_SupplierRechnungsNr & "' AND plose_SupplierRechnungsDatum='" & PLOSE_INV.plInv_SupplierRechnungsDatum & "'", "FMZOLL")
End If
End If
End If
cnt += 1
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & "Datei: " & Dateiname, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End While
readPLOSE_INVData = "Zeilen: " & cnt
End Using
Try
' System.IO.File.Delete(p)
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & "Datei: " & Dateiname, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
addDGVEinarbeitung("PLOSE: INV_DATA (" & cnt & ")", readPLOSE_INVData)
' End Using
'End If
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & "Datei: " & Dateiname, System.Reflection.MethodInfo.GetCurrentMethod.Name)
MsgBox(ex.StackTrace & ex.Message)
readPLOSE_INVData = ""
End Try
End Function
Private Sub dgvEinarbeitung_SelectionChanged(sender As Object, e As EventArgs) Handles dgvEinarbeitung.SelectionChanged
dgvEinarbeitung.ClearSelection()