This commit is contained in:
2024-06-07 13:34:29 +02:00
parent 45969993fb
commit b8f878be4c
6 changed files with 94 additions and 60 deletions

View File

@@ -134,10 +134,10 @@
<Compile Include="cOREGONWorker.vb" />
<Compile Include="cMAVIWorker.vb" />
<Compile Include="cUTA.vb" />
<Compile Include="frmRMCNachrichtenVerarbeitung.Designer.vb">
<DependentUpon>frmRMCNachrichtenVerarbeitung.vb</DependentUpon>
<Compile Include="frmNachrichtenVerarbeitung_MDM_divers.Designer.vb">
<DependentUpon>frmNachrichtenVerarbeitung_MDM_divers.vb</DependentUpon>
</Compile>
<Compile Include="frmRMCNachrichtenVerarbeitung.vb">
<Compile Include="frmNachrichtenVerarbeitung_MDM_divers.vb">
<SubType>Form</SubType>
</Compile>
<Compile Include="frmDatenarchivarchiv.Designer.vb">
@@ -229,8 +229,8 @@
</Compile>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="frmRMCNachrichtenVerarbeitung.resx">
<DependentUpon>frmRMCNachrichtenVerarbeitung.vb</DependentUpon>
<EmbeddedResource Include="frmNachrichtenVerarbeitung_MDM_divers.resx">
<DependentUpon>frmNachrichtenVerarbeitung_MDM_divers.vb</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="frmDatenarchivarchiv.resx">
<DependentUpon>frmDatenarchivarchiv.vb</DependentUpon>

View File

@@ -3,6 +3,9 @@ Imports System.Globalization
Imports System.IO
Imports System.Reflection
Imports System.Text.RegularExpressions
Imports DocumentFormat.OpenXml.Bibliography
Imports DocumentFormat.OpenXml.EMMA
Imports DocumentFormat.OpenXml.VariantTypes
Imports VERAG_PROG_ALLGEMEIN
Public Class cUTA
@@ -11,9 +14,20 @@ Public Class cUTA
Public Function clearimporttable() As Boolean
If Not SQL.doSQL("DELETE tblUTAImport.* FROM tblUTAImport") Then Return False
Return SQL.doSQL("DELETE FROM tblUTAImport", "FMZOLL")
End Function
Public Function importUTALeistungen() As Boolean
'Einträge in tblUTALeistungen machen, wenn Fakturierwarenart und Lieferland noch nicht in der Tabelle enthalten sind.
Dim query = "INSERT INTO tblUTALeistungen (Fakturierwarenart, Lieferland, VERAG_OffertenNr, VERAG_LeistungsNr )
Select Case tblUTAImport.Fakturierwarenart, tblUTAImport.Lieferland, tblUTAFakturierwarenarten.VERAG_OffertenNr, tblUTAFakturierwarenarten.VERAG_LeistungsNr
From tblUTAImport INNER Join tblUTAFakturierwarenarten On tblUTAImport.Fakturierwarenart = tblUTAFakturierwarenarten.Fakturierwarenart
Group By tblUTAImport.Fakturierwarenart, tblUTAImport.Lieferland, tblUTAFakturierwarenarten.VERAG_OffertenNr, tblUTAFakturierwarenarten.VERAG_LeistungsNr
HAVING((((SELECT tblUTALeistungen.Fakturierwarenart FROM tblUTALeistungen WHERE tblUTALeistungen.Fakturierwarenart=tblUTAImport.Fakturierwarenart And tblUTALeistungen.Lieferland=tblUTAImport.Lieferland)) Is Null))"
Return SQL.doSQL(query, "FMZOLL")
End Function
@@ -219,7 +233,7 @@ Public Class cUTA
Property Akzeptanz_Medium As String
Property Steuerkategorie As String
Property UTA_Beleg_ID As String
Property UTA_Normalbeleg_ID As Integer
Property UTA_Normalbeleg_ID As String
Property Gebühren_Bescheinigung_von As DateTime
Property Gebühren_Bescheinigung_bis As DateTime
Property Herausgeber_Nutzer_Nummer As String
@@ -290,7 +304,6 @@ Public Class cUTA
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Informationsbeleg", Informationsbeleg))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Belegherkunft", Belegherkunft))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Filler_Feld_46", Filler_Feld_46))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Darstellwährung_ISO", Darstellwährung_ISO))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Einzelpreis_Brutto_in_Lieferlandwährung_mit_4_Nachkommastellen", Einzelpreis_Brutto_in_Lieferlandwährung_mit_4_Nachkommastellen))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Einzelpreis_Netto_in_Lieferlandwährung_mit_4_Nachkommastellen", Einzelpreis_Netto_in_Lieferlandwährung_mit_4_Nachkommastellen))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Rechnungsdatum", Rechnungsdatum))
@@ -418,10 +431,6 @@ Public Class cUTA
Return ""
End Function
End Class
Public Class UTAArchiv
@@ -502,8 +511,8 @@ Public Class cUTA
Property Filler_Feld_72 As String
Property Akzeptanz_Medium As String
Property Steuerkategorie As String
Property UTA_Beleg_ID As Integer
Property UTA_Normalbeleg_ID As Integer
Property UTA_Beleg_ID As String
Property UTA_Normalbeleg_ID As String
Property Gebühren_Bescheinigung_von As DateTime
Property Gebühren_Bescheinigung_bis As DateTime
Property Herausgeber_Nutzer_Nummer As String
@@ -513,16 +522,16 @@ Public Class cUTA
Property Steuerliches_Lieferland As String
Property Steuerliche_Produktgruppe As String
Property Leistungsort_verlagerbar As Char
Property UStVAn_ID As Integer
Property UStVAn_ID As String
Public hasEntry = False
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Sub New(Belegdatum, UStVAn_ID)
Sub New(Belegdatum, UTA_Beleg_ID)
Me.Belegdatum = Belegdatum
Me.UStVAn_ID = UStVAn_ID
Me.UTA_Beleg_ID = UTA_Beleg_ID
LOAD()
End Sub
Function getParameterList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
@@ -574,7 +583,6 @@ Public Class cUTA
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Informationsbeleg", Informationsbeleg))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Belegherkunft", Belegherkunft))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Filler_Feld_46", Filler_Feld_46))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Darstellwährung_ISO", Darstellwährung_ISO))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Einzelpreis_Brutto_in_Lieferlandwährung_mit_4_Nachkommastellen", Einzelpreis_Brutto_in_Lieferlandwährung_mit_4_Nachkommastellen))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Einzelpreis_Netto_in_Lieferlandwährung_mit_4_Nachkommastellen", Einzelpreis_Netto_in_Lieferlandwährung_mit_4_Nachkommastellen))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("Rechnungsdatum", Rechnungsdatum))
@@ -623,7 +631,7 @@ Public Class cUTA
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
'Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM CLFArchiv WHERE PKFileName=@PKFileName AND OBUID = @OBUID) " &
Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM tblUTAArchiv WHERE UStVAn_ID = @UStVAn_ID AND Belegdatum = @Belegdatum) " &
Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM tblUTAArchiv WHERE UTA_Beleg_ID = @UTA_Beleg_ID AND Belegdatum = @Belegdatum) " &
" BEGIN " & getUpdateCmd() & " End " &
" Else " &
" BEGIN " & getInsertCmd() & " End " &
@@ -636,8 +644,8 @@ Public Class cUTA
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("Select * FROM tblUTAArchiv WHERE UStVAn_ID = @UStVAn_ID AND Belegdatum = @Belegdatum ", conn)
cmd.Parameters.AddWithValue("@UStVAn_ID", UStVAn_ID)
Using cmd As New SqlCommand("Select * FROM tblUTAArchiv WHERE UTA_Beleg_ID = @UTA_Beleg_ID AND Belegdatum = @Belegdatum ", conn)
cmd.Parameters.AddWithValue("@UTA_Beleg_ID", UTA_Beleg_ID)
cmd.Parameters.AddWithValue("@Belegdatum", Belegdatum)
Dim dr = cmd.ExecuteReader()
If dr.Read Then
@@ -674,7 +682,7 @@ Public Class cUTA
End If
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
Return (" UPDATE [tblUTAArchiv] SET " & str & " WHERE UStVAn_ID = @UStVAn_ID AND Belegdatum = @Belegdatum")
Return (" UPDATE [tblUTAArchiv] SET " & str & " WHERE UTA_Beleg_ID = @UTA_Beleg_ID AND Belegdatum = @Belegdatum")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
@@ -737,20 +745,20 @@ Public Class cUTA
Public Function SAVE() As Boolean
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM CLFTrailer WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit) " &
Dim sqlstr = " BEGIN TRAN If EXISTS(Select * FROM tblUTATrailer WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit) " &
" BEGIN " & getUpdateCmd() & " End " &
" Else " &
" BEGIN " & getInsertCmd() & " End " &
" commit tran "
Return SQL.doSQLVarList(sqlstr, "FMZoll", , list)
Return SQL.doSQLVarList(sqlstr, "FMZOLL", , list)
End Function
Public Sub LOAD()
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("Select * FROM CLFTrailer WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit", conn)
Using cmd As New SqlCommand("Select * FROM tblUTATrailer WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit", conn)
cmd.Parameters.AddWithValue("@Übertragungsnummer", Übertragungsnummer)
cmd.Parameters.AddWithValue("@ErstellDatumUhrzeit", ErstellDatumUhrzeit)
Dim dr = cmd.ExecuteReader()
@@ -788,7 +796,7 @@ Public Class cUTA
End If
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
Return (" UPDATE [UTATrailer] SET " & str & " WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit")
Return (" UPDATE [tblUTATrailer] SET " & str & " WHERE Übertragungsnummer=@Übertragungsnummer AND ErstellDatumUhrzeit=@ErstellDatumUhrzeit")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
@@ -810,7 +818,7 @@ Public Class cUTA
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
values = values.Substring(0, values.Length - 1) 'wg. ','
Return (" INSERT INTO CLFTrailer (" & str & ") VALUES(" & values & ") ")
Return (" INSERT INTO tblUTATrailer (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodBase.GetCurrentMethod.Name)
End Try
@@ -831,17 +839,17 @@ Public Class cUTA
SERVERPath = Me.FTP_PFAD
Dim catchedFiles As Boolean = False
For Each f In io.Directory.GetFiles(SERVERPath)
Dim fi As New io.FileInfo(f)
For Each f In IO.Directory.GetFiles(SERVERPath)
Dim fi As New IO.FileInfo(f)
If fi.Name.ToUpper.Contains(fileType) Then
If Not fi.Name.StartsWith(".") Then
Dim zielPfad = VERARBEITUNG_PFAD & "\" & fi.Name
While io.File.Exists(zielPfad)
While IO.File.Exists(zielPfad)
zielPfad = VERARBEITUNG_PFAD & "\" & "DOPPELT" & "\" & fi.Name.Replace(fi.Extension, "") & fi.Extension & Now.ToString("_yyyyMMdd_HHmmss")
End While
io.File.Copy(f, zielPfad)
If io.File.Exists(zielPfad) Then
io.File.Delete(f)
IO.File.Copy(f, zielPfad)
If IO.File.Exists(zielPfad) Then
IO.File.Delete(f)
catchedFiles = True
End If
@@ -1181,13 +1189,12 @@ Public Class cUTA
Case "90"
If curChecksumme < 0 Then
curChecksumme = 0 - curChecksumme
End If
If Trim(Mid(strZeile, 16, 18) / 100) <> curChecksumme Then
MsgBox("Checksumme: " & Trim(Mid(strZeile, 16, 18) / 100) & vbCrLf & "Prüfsumme: " & curChecksumme & vbCrLf & "Datei kann wegen Prüfsummenfehler nicht verarbeitet werden")
Return False
'Return False
End If
@@ -1210,12 +1217,10 @@ Public Class cUTA
Loop
objFileRead.Close()
Return True
End Function
Public VERARBEITUNG_PFAD
Public ARCHIV_PFAD
Public ERROR_PFAD

View File

@@ -1,5 +1,5 @@
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()>
Partial Class frmRMCNachrichtenVerarbeitung
Partial Class frmNachrichtenVerarbeitung_MDM_divers
Inherits System.Windows.Forms.Form
'Das Formular überschreibt den Löschvorgang, um die Komponentenliste zu bereinigen.
@@ -23,7 +23,7 @@ Partial Class frmRMCNachrichtenVerarbeitung
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmRMCNachrichtenVerarbeitung))
Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmNachrichtenVerarbeitung_MDM_divers))
Me.btn = New System.Windows.Forms.Button()
Me.pnl = New System.Windows.Forms.Panel()
Me.lblFTP = New System.Windows.Forms.Label()

View File

@@ -3,6 +3,7 @@ Imports System.Net
Imports System.Runtime.Remoting
Imports System.Text
Imports System.Text.RegularExpressions
Imports System.Web
Imports System.Xml
Imports DocumentFormat.OpenXml.Bibliography
Imports DocumentFormat.OpenXml.Office2010.Excel
@@ -10,7 +11,7 @@ Imports Renci.SshNet
Imports Renci.SshNet.Sftp
Imports VERAG_PROG_ALLGEMEIN
Public Class frmRMCNachrichtenVerarbeitung
Public Class frmNachrichtenVerarbeitung_MDM_divers
Dim cntDatenEingelesen As Integer = 0
Dim dsNichtErkannt As Integer = 0
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
@@ -102,6 +103,8 @@ Public Class frmRMCNachrichtenVerarbeitung
DownloadFtpDirectory(rmc.API_STRING & "/", New NetworkCredential(rmc.API.Rows(0).Item("api_user").ToString, rmc.API.Rows(0).Item("api_password").ToString), "", cnt, False)
ElseIf programName.Contains("UTA") Then
DownloadSFtpDirectory(uta.API_STRING, New NetworkCredential(uta.API.Rows(0).Item("api_user").ToString, uta.API.Rows(0).Item("api_password").ToString), "", cnt, False, "/TRX/" & Now.Year)
ElseIf programName.Contains("IDS") Then
'DownloadSFtpDirectory(uta.API_STRING, New NetworkCredential(uta.API.Rows(0).Item("api_user").ToString, uta.API.Rows(0).Item("api_password").ToString), "", cnt, False, "/TRX/" & Now.Year)
End If
@@ -140,7 +143,7 @@ Public Class frmRMCNachrichtenVerarbeitung
For Each line As String In lines
Dim tokens As String() =
line.Split(New Char() {" "}, 9, StringSplitOptions.RemoveEmptyEntries)
Dim name As String = tokens(8)
Dim name As String = HttpUtility.UrlEncode(tokens(8)) 'tokens(8) 'handle special characters within filename!
Dim permissions As String = tokens(0)
Dim localFilePath As String = Path.Combine(localPath, name)
@@ -154,7 +157,6 @@ Public Class frmRMCNachrichtenVerarbeitung
downloadRequest.Credentials = credentials
' Dim fileDateTmp As Date = ServerDateFile(credentials, fileUrl)
'name = name.Replace(".csv", "_RGDAT_" & Now.ToShortDateString & ".csv")
Dim destFilenameTMP = verarbeitungspfad
@@ -234,14 +236,14 @@ Public Class frmRMCNachrichtenVerarbeitung
client.DownloadFile(Path + remoteFileName, downloadedFile)
If IO.File.Exists(filePath) AndAlso deleteAfterDownload Then client.DeleteFile(Path + remoteFileName) 'Datei nach erfolgreichem Herunterladen vom Server löschen
downloadedFile.Dispose()
Dim fi As FileInfo = New FileInfo(filePath)
ListBox3.Items.Add(frmStartOptions.cut_file(fi.Name)) 'zur Liste hinzufügen
cnt += 1
'TODO: nach erfolgreichen verschieben, von FTP löschen!
downloadedFile.Close()
End If
Next
@@ -281,6 +283,7 @@ Public Class frmRMCNachrichtenVerarbeitung
Exit Sub
End If
Dim deleteTable As Boolean = False
Dim verarbeitungspfad, zielpfad
If programName.Contains("RMC") Then
verarbeitungspfad = rmc.VERARBEITUNG_PFAD
@@ -304,6 +307,7 @@ Public Class frmRMCNachrichtenVerarbeitung
If programName.Contains("RMC") Then
Select Case i
Case 1
'------------------------------------------
'------------------ CSV ------------------
@@ -327,7 +331,7 @@ Public Class frmRMCNachrichtenVerarbeitung
If Not IO.Directory.Exists(zielpfad & "Invoice_PDF\" & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\") Then IO.Directory.CreateDirectory(zielpfad & Now.Year & "\" & Now.ToString("yyyyMMdd") & "\")
'File in Datenarchiv sichern:
If fi.Name.ToString.StartsWith("invoice_") Then 'aktuell nur die RMC-Dateien! (später, wenn CSV vollständig, dann alle PDS importieren! d.breimaier: 2024-06-05
If fi.Name.ToString.StartsWith("invoice_") Then 'aktuell nur die RMC-Dateien! (später, wenn CSV vollständig, dann alle PDFs importieren! d.breimaier: 2024-06-05
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("MDM", "MDM_DATEN", "RMC", Now.Year, Now.ToString("yyyyMMdd"), frmStartOptions.getFileName(d))
@@ -344,25 +348,46 @@ Public Class frmRMCNachrichtenVerarbeitung
End If
End Select
ElseIf programName.Contains("UTA") Then
'------------------------------------------
'------------------ .UTA ------------------
'------------------------------------------
Select Case i
Case 1
'------------------------------------------
'------------------ .UTA ------------------
'------------------------------------------
If fi.Extension.ToLower = ".uta" Then
If Not deleteTable Then
deleteTable = uta.clearimporttable()
End If
If Not found Then
uta.clearimporttable()
If readUTA(d) <> "" Then found = True
End If
If found Then cntDatenEingelesen += 1
End If
If fi.Extension.ToLower = ".uta" Then
If Not found Then
If readUTA(d) <> "" Then found = True
End If
If found Then cntDatenEingelesen += 1
End If
Case 2
'------------------------------------------
'------------------ .PDF ------------------
'------------------------------------------
'AKTUELL NOCH KEINE PDFs -> HIER LOGIK FÜR UTA_PDFs
dgvEinarbeitung.Refresh()
End Select
End If
If True Then
If Not alreadyMoved Then
If found Then
@@ -375,11 +400,15 @@ Public Class frmRMCNachrichtenVerarbeitung
Me.Refresh()
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
If programName.Contains("UTA") Then uta.importUTALeistungen()
End Sub
@@ -461,7 +490,7 @@ Public Class frmRMCNachrichtenVerarbeitung
If filepath <> "" Then
Dim anhenge As New List(Of String)
anhenge.Add(filepath)
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail("d.breimaier@verag.ag", "Wölfl-UIDNr", "Im Anhang die zu prüfenden Kunden von WÖLFL " & vbNewLine & vbNewLine & "*Automatic generated e-mail*",,,,, "d.breimaier@verag.ag", anhenge)
VERAG_PROG_ALLGEMEIN.cProgramFunctions.sendMail("juricevic@verag.ag", "Wölfl-UIDNr", "Im Anhang die zu prüfenden Kunden von WÖLFL " & vbNewLine & vbNewLine & "*Automatic generated e-mail*",,,,, "d.breimaier@verag.ag", anhenge)
End If
End If

View File

@@ -4377,7 +4377,7 @@ Public Class frmStartOptions
Me.Visible = False
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cbxTestsystem.Checked
If cbxRMC._value = "" Then Exit Sub
Dim f As New frmRMCNachrichtenVerarbeitung(cbxRMC._value)
Dim f As New frmNachrichtenVerarbeitung_MDM_divers(cbxRMC._value)
f.ShowDialog()
Me.Visible = True
End Sub
@@ -4385,7 +4385,7 @@ Public Class frmStartOptions
Private Sub LinkLabel53_LinkClicked(sender As Object, e As LinkLabelLinkClickedEventArgs) Handles LinkLabel53.LinkClicked
Me.Visible = False
VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cbxTestsystem.Checked
Dim f As New frmRMCNachrichtenVerarbeitung("UTA")
Dim f As New frmNachrichtenVerarbeitung_MDM_divers("UTA")
f.ShowDialog()
Me.Visible = True
End Sub