Merge branch 'newMaster2024' of https://git.it.verag.ag/edv/SDL into newMaster2024

This commit is contained in:
2025-12-03 16:53:00 +01:00
20 changed files with 283 additions and 127 deletions

View File

@@ -48,7 +48,7 @@
Public Shared Function genBuchungenBeginn(Geschaeftsjahr As Integer) As String
Return "100,""AR "",4,""" & Now.ToString("ddMMyyyy") & """," & Now.AddDays(-1).Month & ",0"
Return "100,""AR "",4,""" & Now.ToString("ddMMyyyy") & """," & Now.Month & ",0"
End Function

View File

@@ -1,4 +1,5 @@
Imports System.ServiceModel.Configuration
Imports com
Imports Therefore.API
Public Class cTherefore
@@ -146,6 +147,109 @@ Public Class cTherefore
' 8. Close Therefore™ document object
doc.Close()
Return True
Catch ex As Exception
MsgBox(ex.Message & ex.StackTrace)
End Try
Return False
End Function
Shared Function getFileFromFolderCat(Category As String, Optional Category2 As String = "", Optional UpdateExistingVertraege As Boolean = False)
Try
If Category2 = "" Then Category2 = Category
Dim SQL As New SQL
' 1. Connect to the Therefore™ Server
Dim server As New TheServer
server.Connect(TheClientType.CustomApplication)
' 2. Create a new Therefore™ Document
Dim TableName = ""
If IsNumeric(Category) Then
TableName = "TheCat" & Category
If SQL.getValueTxtBySql("SELECT count(*) FROM [TheCategory] WHERE TableName='" & TableName & "'", "SCANCANON",,, "") = 0 Then
MsgBox("Therefore: Tabelle nicht gefunden: " & TableName)
Return False
End If
Else
TableName = SQL.getValueTxtBySql("SELECT [TableName] FROM [TheCategory] WHERE Title='" & Category & "'", "SCANCANON",,, "")
End If
Dim docs As DataTable = SQL.loadDgvBySql("SELECT isnull([DocNo],-1) as DocNo,[String],[Eingabedatum] FROM " & TableName & " where isNUmeric(left(string,6)) = 1", "SCANCANON")
If Not vbYes = MsgBox("Möchten Sie die " & docs.Rows.Count & " Dokumente aus Therefore als Unternehmensbescheinigung hochladen?" & vbNewLine & "Existierende Datenarchiv-Einträge werden " & IIf(UpdateExistingVertraege, "-ÜBERSCHRIEBEN-", "-ÜBERSPRUNGEN-") & "!", vbYesNoCancel) Then Return False
For Each TFdoc As DataRow In docs.Rows
Dim filename As String = ""
If TFdoc.Item("DocNo") > 0 Then
If Not IsDBNull(TFdoc("String")) AndAlso TFdoc("String").ToString() <> "" AndAlso TFdoc.Item("String").ToString.Length > 6 AndAlso IsNumeric(TFdoc.Item("String").ToString.Substring(0, 6)) Then
Dim kdNr = TFdoc.Item("String").ToString.Substring(0, 6)
Dim Kunde As New cKunde(kdNr)
If Kunde IsNot Nothing Then
Dim EingabeDatum As Date
If Not IsDBNull(TFdoc("Eingabedatum")) AndAlso TFdoc("Eingabedatum").ToString() <> "" AndAlso IsDate(TFdoc.Item("Eingabedatum").ToString) Then
EingabeDatum = CDate(TFdoc("Eingabedatum"))
Else
EingabeDatum = Now()
End If
Dim KV As New VERAG_PROG_ALLGEMEIN.cKundenVertraege(Kunde.KundenNr, EingabeDatum, 7)
If KV.hasEntry AndAlso KV.kv_datenarchivId IsNot Nothing AndAlso KV.kv_datenarchivId > 0 AndAlso Not UpdateExistingVertraege Then Continue For 'dann nicht aktualisieren!
Dim extractDir As String = System.IO.Path.GetTempPath() & Kunde.KundenNr & "\"
If Not System.IO.Directory.Exists(extractDir) Then
System.IO.Directory.CreateDirectory(extractDir)
End If
Dim doc As New TheDocument()
Dim folder = ""
Dim VerionNo As Integer
filename = doc.Retrieve(TFdoc.Item("DocNo"), VerionNo, folder, server, False)
' 4. Extract all file streams to the specified directory
Dim i As Integer
Dim DSID As Integer = -1
Dim multiFiles As Boolean = (doc.StreamCount > 1)
Dim DS As New VERAG_PROG_ALLGEMEIN.cDATENSERVER("DOKUMENTE", "UM-BESCHEINIGUNG", Now.ToString("ddMMyy_HHmmss.ffff"), "", "", "UM-Bescheinigung", Kunde.KundenNr, multiFiles)
For i = 0 To doc.StreamCount - 1 'Step i + 1
Dim extractFile As String = doc.ExtractStream(i, extractDir)
If Not DS.uploadDataToDATENSERVER(extractFile) Then
MsgBox("Fehler beim Hochladen!")
End If
Next
KV.kv_Info = "aus TF importiert"
KV.kv_datenarchivId = DS.da_id
KV.SAVE()
doc.Close()
End If
End If
End If
Next
Return True
Catch ex As Exception
MsgBox(ex.Message & ex.StackTrace)