div. Änderungen
This commit is contained in:
@@ -4,7 +4,7 @@ Imports System.Reflection
|
||||
Public Class cFremdwaehrungskurse
|
||||
|
||||
|
||||
Property fw_id As String
|
||||
Property fw_id As Integer
|
||||
Property fw_iso2 As String
|
||||
Property fw_iso3 As String
|
||||
Property fw_land As String
|
||||
@@ -12,6 +12,8 @@ Public Class cFremdwaehrungskurse
|
||||
Property fw_enddatum As Date
|
||||
Property fw_kurswert As Double
|
||||
|
||||
Public hasEntry = False
|
||||
|
||||
|
||||
Dim SQL As New SQL
|
||||
|
||||
@@ -19,10 +21,19 @@ Public Class cFremdwaehrungskurse
|
||||
|
||||
End Sub
|
||||
|
||||
Sub New(fw_iso3 As String)
|
||||
Me.fw_iso3 = fw_iso3
|
||||
LOAD_ByWaehrungscode(fw_iso3)
|
||||
End Sub
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Public Function getParameterList() As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
|
||||
Dim list As New List(Of VERAG_PROG_ALLGEMEIN.SQLVariable)
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fw_id", fw_id))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fw_id", fw_id,, True))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fw_iso2", fw_iso2))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fw_iso3", fw_iso3))
|
||||
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fw_land", fw_land))
|
||||
@@ -50,6 +61,33 @@ Public Class cFremdwaehrungskurse
|
||||
Return SQL.doSQLVarList(sqlstr, "FMZOLL", , list)
|
||||
End Function
|
||||
|
||||
Public Sub LOAD_ByWaehrungscode(fw_iso3 As String)
|
||||
Try
|
||||
hasEntry = False
|
||||
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
|
||||
Using cmd As New SqlCommand("SELECT top(1) * FROM tblZOLL_Wechselkurse WHERE fw_iso3=@fw_iso3 ORDER BY fw_startdatum desc ", conn)
|
||||
cmd.Parameters.AddWithValue("@fw_iso3", fw_iso3)
|
||||
Dim dr = cmd.ExecuteReader()
|
||||
If dr.Read Then
|
||||
For Each li In getParameterList()
|
||||
Dim propInfo As PropertyInfo = Me.GetType.GetProperty(li.Scalarvariable)
|
||||
|
||||
If dr.Item(li.Text) Is DBNull.Value Then
|
||||
propInfo.SetValue(Me, Nothing)
|
||||
Else
|
||||
propInfo.SetValue(Me, dr.Item(li.Text))
|
||||
End If
|
||||
|
||||
Next
|
||||
hasEntry = True
|
||||
End If
|
||||
dr.Close()
|
||||
End Using
|
||||
End Using
|
||||
Catch ex As Exception
|
||||
MsgBox("Fehler in der Funktion '" & System.Reflection.MethodInfo.GetCurrentMethod.Name & "'" & vbNewLine & vbNewLine & ex.Message & vbNewLine & vbNewLine & ex.StackTrace)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function getUpdateCmd() As String
|
||||
@@ -116,6 +154,13 @@ Public Class cFremdwaehrungskurse
|
||||
'End Function
|
||||
|
||||
|
||||
|
||||
Shared Function EXCHANGE_CURTOEUR(betrag As Double, waehrungscode As String, datum As Date) As Double
|
||||
Dim sqlstr = " SELECT TOP 1 [fw_kurswert] FROM [tblZOLL_Wechselkurse] where fw_iso3='" & waehrungscode & "' and fw_startdatum<='" & datum.ToShortDateString & "' order by fw_startdatum desc"
|
||||
Return betrag / (New SQL).getValueTxtBySql(sqlstr, "FMZOLL",,, 0)
|
||||
End Function
|
||||
|
||||
|
||||
End Class
|
||||
|
||||
|
||||
|
||||
@@ -1656,6 +1656,92 @@ Public Class cFormularManager
|
||||
Return ""
|
||||
End Function
|
||||
|
||||
Public Shared Function getFile_FromURLStream_NEW(URL As String, Optional filename As String = "", Optional targetPath As String = "", Optional showError As Boolean = True) As String
|
||||
Try
|
||||
Using webClient As New Net.WebClient()
|
||||
|
||||
' 🟡 Simulate browser (important for protected systems)
|
||||
webClient.Headers.Add("User-Agent", "Mozilla/5.0")
|
||||
webClient.Headers.Add("Accept", "*/*")
|
||||
|
||||
' Download data
|
||||
Dim data() As Byte = webClient.DownloadData(URL)
|
||||
|
||||
' Read Content-Type header safely
|
||||
Dim contentType As String = ""
|
||||
If webClient.ResponseHeaders IsNot Nothing AndAlso webClient.ResponseHeaders("Content-Type") IsNot Nothing Then
|
||||
contentType = webClient.ResponseHeaders("Content-Type").ToLower()
|
||||
End If
|
||||
|
||||
' Try to get filename from headers if not provided
|
||||
If String.IsNullOrEmpty(filename) Then
|
||||
Dim contentDisposition = webClient.ResponseHeaders("Content-Disposition")
|
||||
If contentDisposition IsNot Nothing AndAlso contentDisposition.Contains("filename=") Then
|
||||
filename = contentDisposition.Split("filename=")(1).Replace("""", "").Trim()
|
||||
filename = System.IO.Path.GetFileNameWithoutExtension(filename)
|
||||
Else
|
||||
filename = Guid.NewGuid().ToString()
|
||||
End If
|
||||
End If
|
||||
|
||||
' Determine extension
|
||||
Dim extension As String = ""
|
||||
|
||||
If contentType.Contains("pdf") Then
|
||||
extension = ".pdf"
|
||||
|
||||
ElseIf contentType.Contains("spreadsheetml") Then
|
||||
extension = ".xlsx"
|
||||
|
||||
ElseIf contentType.Contains("ms-excel") Then
|
||||
extension = ".xls"
|
||||
|
||||
ElseIf contentType.Contains("json") Then
|
||||
extension = ".json"
|
||||
|
||||
ElseIf contentType.Contains("html") Then
|
||||
extension = ".html" ' ⚠️ likely login page instead of file
|
||||
End If
|
||||
|
||||
' Fallback: detect PDF by magic number
|
||||
If extension = "" AndAlso data.Length > 4 Then
|
||||
If data(0) = &H25 AndAlso data(1) = &H50 AndAlso data(2) = &H44 AndAlso data(3) = &H46 Then
|
||||
extension = ".pdf"
|
||||
End If
|
||||
End If
|
||||
|
||||
' Default fallback
|
||||
If extension = "" Then extension = ".bin"
|
||||
|
||||
' Build path
|
||||
Dim fullPath As String = System.IO.Path.Combine(System.IO.Path.GetTempPath(), filename & extension)
|
||||
|
||||
' Save file
|
||||
If extension = ".pdf" Then
|
||||
Using stream As New MemoryStream(data)
|
||||
Dim doc As New Spire.Pdf.PdfDocument()
|
||||
doc.LoadFromStream(stream)
|
||||
doc.SaveToFile(fullPath)
|
||||
End Using
|
||||
|
||||
Else
|
||||
System.IO.File.WriteAllBytes(fullPath, data)
|
||||
End If
|
||||
|
||||
targetPath = fullPath
|
||||
Return targetPath
|
||||
|
||||
End Using
|
||||
|
||||
Catch ex As Exception
|
||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace,
|
||||
System.Reflection.MethodInfo.GetCurrentMethod.Name,
|
||||
If(Not showError, "LOG", ""))
|
||||
End Try
|
||||
|
||||
Return ""
|
||||
End Function
|
||||
|
||||
Public Shared Sub PrintViaGS(PDFFile As String, printerName As String)
|
||||
Try
|
||||
Dim assembly = System.Reflection.Assembly.GetExecutingAssembly()
|
||||
|
||||
Reference in New Issue
Block a user