This commit is contained in:
2021-03-04 15:47:27 +01:00
parent 8431ce57eb
commit 569991b011
22 changed files with 14399 additions and 116 deletions

View File

@@ -269,7 +269,7 @@ Public Class frmMDMNachrichtenVerarbeitung
If True Then
' Temp.DownloadPfad
Dim destFilenameTMP = VERARBEITUNGS_PFAD + "." & If(IO.File.Exists(VERARBEITUNGS_PFAD & "." & name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & name
Dim destFilenameTMP = VERARBEITUNGS_PFAD & "." & If(IO.File.Exists(VERARBEITUNGS_PFAD & "." & name), name.Replace(".csv", "_") & Now.ToString("yyMMdd_HHmmss.fff") & ".csv", name)
Dim downloadRequest As FtpWebRequest = WebRequest.Create(fileUrl)
downloadRequest.Method = WebRequestMethods.Ftp.DownloadFile
@@ -291,7 +291,7 @@ Public Class frmMDMNachrichtenVerarbeitung
targetStream.Dispose()
downloadResponse.Dispose()
Dim destFilename = VERARBEITUNGS_PFAD & If(IO.File.Exists(VERARBEITUNGS_PFAD & name), Now.ToString("yyMMdd_HHmmss.fff_"), "") & name
Dim destFilename = VERARBEITUNGS_PFAD & "." & If(IO.File.Exists(VERARBEITUNGS_PFAD & "." & name), name.Replace(".csv", "_") & Now.ToString("yyMMdd_HHmmss.fff") & ".csv", name)
IO.File.Move(destFilenameTMP, destFilename) 'Datei umbenennen
@@ -442,77 +442,70 @@ Public Class frmMDMNachrichtenVerarbeitung
Exit Sub
End If
For Each d In System.IO.Directory.GetFiles(VERARBEITUNGS_PFAD)
Try
Dateiname = d
cWorker_NCTS.Dateiname = d
If IO.File.Exists(d) Then
Dim found = False
Dim fi As FileInfo = New FileInfo(d)
For i = 1 To 3
' EDIFACT
' If fi.Extension = ".edi" Then
Dim alreadyMoved = False
If fi.Extension.ToLower = ".xml" Then
Dim xmlWriterSettings As XmlWriterSettings = New XmlWriterSettings With {.Encoding = System.Text.Encoding.UTF8, .CheckCharacters = True}
For Each d In System.IO.Directory.GetFiles(VERARBEITUNGS_PFAD)
Try
Dateiname = d
cWorker_NCTS.Dateiname = d
If IO.File.Exists(d) Then
Dim found = False
Dim fi As FileInfo = New FileInfo(d)
Dim doc As New XmlDocument()
Dim XML_Code = System.IO.File.ReadAllText(d, System.Text.UTF8Encoding.Default)
' EDIFACT
' If fi.Extension = ".edi" Then
Dim alreadyMoved = False
doc.LoadXml(SanitizeXmlString(XML_Code))
Dim VERSION As String = ""
If fi.Extension.ToLower = ".csv" Then
'------------------------------------------------------------------------------------------------------------------------------
' PLOSE
'------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------------------------------------------------------------------------------------------
' eZOLL
'------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------
'------------------ DETAIL ------------------
'------------------------------------------
Select Case i
Case 1
'TC: Versandbestätigung
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
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)
dsNichtErkannt += 1
End Select
'------------------------------------------
'------------------ Anmeldung ------------------
'------------------------------------------
'TC: Versandbestätigung
'If Not found And cGetMsgType.isTC_Anmeldung(doc) Then
' If readTC_Anmeldung(doc, d) <> "" Then found = True
' ' If bezugsNr <> "" Then addDGVEinarbeitung("NCTS: Versandbestätigung", bezugsNr) : found = True
'End If
ElseIf fi.Extension.ToLower = ".csv" Then
'------------------------------------------------------------------------------------------------------------------------------
' PLOSE
'------------------------------------------------------------------------------------------------------------------------------
'------------------------------------------
'------------------ DETAIL ------------------
'------------------------------------------
'TC: Versandbestätigung
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
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(d, ZIEL_PFAD & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
Else
frmStartOptions.moveFile(d, ERROR_PFAD)
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
End If
End If
Me.Refresh()
Me.Refresh()
If found Then cntDatenEingelesen += 1 Else dsNichtErkannt += 1
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
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
Next
Next
End Sub
@@ -572,55 +565,62 @@ Public Class frmMDMNachrichtenVerarbeitung
Try
currentRow = MyReader.ReadFields()
Dim fi As FileInfo = New FileInfo(d)
If fi.Name.Length > 8 Then
Dim plose_RechnungsNr = fi.Name.Substring(0, 8)
If currentRow.Length > 24 AndAlso currentRow(12) <> "839160" Then 'KDNR <> VERAG --> Die Kosten bleiben uns
Dim PLOSE As New MDM_Worker.cPLOSE
PLOSE.plose_Datensatztyp = SQL.isleernothing(currentRow(0))
PLOSE.plose_KodexMautTankstelle = SQL.isleernothing(currentRow(1))
PLOSE.plose_BeschreibungMautTankstelle = SQL.isleernothing(currentRow(2))
PLOSE.plose_KodexEinfahrt = SQL.isleernothing(currentRow(3))
PLOSE.plose_BeschreibungEinfahrt = SQL.isleernothing(currentRow(4))
PLOSE.plose_KodexAusfahrt = SQL.isleernothing(currentRow(5))
PLOSE.plose_BeschreibungAusfahrt = SQL.isleernothing(currentRow(6))
PLOSE.plose_Kartenkodex = SQL.isleernothing(currentRow(7))
PLOSE.plose_Kontonummer = SQL.isleernothing(currentRow(8))
PLOSE.plose_NummerKarteGeraet = SQL.isleernothing(currentRow(9))
PLOSE.plose_Kennzeichen = SQL.isleernothing(currentRow(10))
PLOSE.plose_InterneNrFahrzeug = SQL.isleernothing(currentRow(11))
PLOSE.plose_POLSEKundennummer = SQL.isleernothing(currentRow(12))
PLOSE.plose_Firmenname = SQL.isleernothing(currentRow(13))
PLOSE.plose_DatumTransaktion = SQL.isleernothingDateFormatstring(currentRow(14))
PLOSE.plose_Produktbeschreibung = SQL.isleernothing(currentRow(15))
PLOSE.plose_Menge = SQL.isNullNothingDbl(currentRow(16))
PLOSE.plose_Preis = SQL.isNullNothingDbl(currentRow(17))
PLOSE.Einheitsrabatt = SQL.isleernothing(currentRow(18))
PLOSE.plose_NettobetragTransaktion = SQL.isNullNothingDbl(currentRow(19))
PLOSE.plose_MWSTBetrag = SQL.isNullNothingDbl(currentRow(20))
PLOSE.plose_BruttobetragTransaktion = SQL.isNullNothingDbl(currentRow(21))
PLOSE.plose_NettobetragWaehrungAbbuchung = SQL.isNullNothingDbl(currentRow(22))
PLOSE.plose_MWSTBetragWaehrungAbbuchung = SQL.isNullNothingDbl(currentRow(23))
PLOSE.plose_BruttobetragWaehrungAbbuchung = SQL.isNullNothingDbl(currentRow(24))
PLOSE.plose_WaehrungLandDiesntleistung = SQL.isleernothing(currentRow(25))
PLOSE.plose_WaehrungAbbuchung = SQL.isleernothing(currentRow(26))
PLOSE.plose_DokumentNrQuittungUhrzeit = SQL.isleernothing(currentRow(27))
PLOSE.plose_ArtTransaktion = SQL.isleernothing(currentRow(28))
PLOSE.plose_Fahrzeugklasse = SQL.isleernothing(currentRow(29))
PLOSE.plose_KlassenidentifikationEURO = SQL.isleernothing(currentRow(30))
PLOSE.plose_ProduktbeschreibungShort = SQL.isleernothing(currentRow(31))
PLOSE.plose_DokumentNrQuittungUhrzeit = SQL.isleernothing(currentRow(32))
PLOSE.plose_Geraetetyp = SQL.isleernothing(currentRow(33))
PLOSE.plose_ProduktCode = SQL.isleernothing(currentRow(34))
PLOSE.plose_ReferenzenBuchungMaut = SQL.isleernothing(currentRow(35))
If currentRow.Length > 24 AndAlso currentRow(12) <> "839160" Then 'KDNR <> VERAG --> Die Kosten bleiben uns
Dim PLOSE As New MDM_Worker.cPLOSE
''''''''''''
If PLOSE.SAVE() Then
PLOSE.plose_Dateiname = fi.Name
PLOSE.plose_RechnungsNr = plose_RechnungsNr
PLOSE.plose_Datensatztyp = SQL.isleernothing(currentRow(0))
PLOSE.plose_KodexMautTankstelle = SQL.isleernothing(currentRow(1))
PLOSE.plose_BeschreibungMautTankstelle = SQL.isleernothing(currentRow(2))
PLOSE.plose_KodexEinfahrt = SQL.isleernothing(currentRow(3))
PLOSE.plose_BeschreibungEinfahrt = SQL.isleernothing(currentRow(4))
PLOSE.plose_KodexAusfahrt = SQL.isleernothing(currentRow(5))
PLOSE.plose_BeschreibungAusfahrt = SQL.isleernothing(currentRow(6))
PLOSE.plose_Kartenkodex = SQL.isleernothing(currentRow(7))
PLOSE.plose_Kontonummer = SQL.isleernothing(currentRow(8))
PLOSE.plose_NummerKarteGeraet = SQL.isleernothing(currentRow(9))
PLOSE.plose_Kennzeichen = SQL.isleernothing(currentRow(10))
PLOSE.plose_InterneNrFahrzeug = SQL.isleernothing(currentRow(11))
PLOSE.plose_POLSEKundennummer = SQL.isleernothing(currentRow(12))
PLOSE.plose_Firmenname = SQL.isleernothing(currentRow(13))
PLOSE.plose_DatumTransaktion = SQL.isleernothingDateFormatstring(currentRow(14))
PLOSE.plose_Produktbeschreibung = SQL.isleernothing(currentRow(15))
PLOSE.plose_Menge = SQL.isNullNothingDbl(currentRow(16))
PLOSE.plose_Preis = SQL.isNullNothingDbl(currentRow(17))
PLOSE.Einheitsrabatt = SQL.isleernothing(currentRow(18))
PLOSE.plose_NettobetragTransaktion = SQL.isNullNothingDbl(currentRow(19))
PLOSE.plose_MWSTBetrag = SQL.isNullNothingDbl(currentRow(20))
PLOSE.plose_BruttobetragTransaktion = SQL.isNullNothingDbl(currentRow(21))
PLOSE.plose_NettobetragWaehrungAbbuchung = SQL.isNullNothingDbl(currentRow(22))
PLOSE.plose_MWSTBetragWaehrungAbbuchung = SQL.isNullNothingDbl(currentRow(23))
PLOSE.plose_BruttobetragWaehrungAbbuchung = SQL.isNullNothingDbl(currentRow(24))
PLOSE.plose_WaehrungLandDiesntleistung = SQL.isleernothing(currentRow(25))
PLOSE.plose_WaehrungAbbuchung = SQL.isleernothing(currentRow(26))
PLOSE.plose_DokumentNrQuittungUhrzeit = SQL.isleernothing(currentRow(27))
PLOSE.plose_ArtTransaktion = SQL.isleernothing(currentRow(28))
PLOSE.plose_Fahrzeugklasse = SQL.isleernothing(currentRow(29))
PLOSE.plose_KlassenidentifikationEURO = SQL.isleernothing(currentRow(30))
PLOSE.plose_ProduktbeschreibungShort = SQL.isleernothing(currentRow(31))
PLOSE.plose_DokumentNrQuittungUhrzeit = SQL.isleernothing(currentRow(32))
PLOSE.plose_Geraetetyp = SQL.isleernothing(currentRow(33))
PLOSE.plose_ProduktCode = SQL.isleernothing(currentRow(34))
PLOSE.plose_ReferenzenBuchungMaut = SQL.isleernothing(currentRow(35))
''''''''''''
If PLOSE.SAVE() Then
End If
End If
cnt += 1
End If
cnt += 1
'For Each currentField In currentRow
'Next
@@ -661,6 +661,77 @@ Public Class frmMDMNachrichtenVerarbeitung
End Function
Function readPLOSE_Header(d As String) As String
Try
readPLOSE_Header = ""
Dim KdnR = ""
Using MyReader As New Microsoft.VisualBasic.FileIO.TextFieldParser(d, Encoding.UTF8)
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(";")
Dim currentRow As String()
Dim cnt = 0
If True Then
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
Dim fi As FileInfo = New FileInfo(d)
If fi.Name.Length > 8 Then
Dim plose_RechnungsNr = fi.Name.Substring(0, 8)
If IsNumeric(plose_RechnungsNr) AndAlso IsNumeric(currentRow(12)) Then
If currentRow.Length > 24 AndAlso currentRow(12) <> "839160" Then 'KDNR <> VERAG --> Die Kosten bleiben uns
Dim plose_RechnungsDatum = SQL.isleernothingDateFormatstring(currentRow(14))
If plose_RechnungsDatum IsNot Nothing AndAlso IsDate(plose_RechnungsDatum) Then
MDM_Worker.cPLOSE.UPDATE_RGDatum(plose_RechnungsDatum, plose_RechnungsNr, currentRow(12))
cnt += 1
End If
End If
End If
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
End While
'Label30.Text = (cnt + 1) & " / " & LineCount
'Label31.Visible = True
readPLOSE_Header = "Zeilen: " & cnt
Else
MsgBox("FEHLER beim Löschen der vorhandenen OP-Liste.")
End If
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: Header" & KdnR, readPLOSE_Header)
' 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_Header = ""
End Try
End Function
Private Sub dgvEinarbeitung_SelectionChanged(sender As Object, e As EventArgs) Handles dgvEinarbeitung.SelectionChanged
dgvEinarbeitung.ClearSelection()