This commit is contained in:
2023-09-26 09:00:14 +02:00
3 changed files with 130 additions and 6 deletions

View File

@@ -415,9 +415,10 @@ Public Class frmEssensbestellungen
End If End If
Next Next
Dim bestellung As New cEssensbestellung(dgvBestellungen.SelectedRows(0).Cells("eb_kw").Value, dgvBestellungen.SelectedRows(0).Cells("eb_mitid").Value)
txtAnzahlMenu.Text = countMenus.ToString() txtAnzahlMenu.Text = countMenus.ToString()
txtAnzahlLaCart.Text = countlaCarte.ToString txtAnzahlLaCart.Text = countlaCarte.ToString
txtPreis.Text = (CDbl(countlaCarte) + CDbl(countMenus)) * preisProMahlzeit txtPreis.Text = (CDbl(countlaCarte) + CDbl(countMenus)) * preisProMahlzeit 'IIf(bestellung.eb_storniert, preisProMahlzeit * 0, preisProMahlzeit * 1)
End Sub End Sub

View File

@@ -1332,7 +1332,7 @@ Public Class cFormularManager
Public Shared Function getPDFViaSpirePDF_FromURL(URL As String, Optional targetPath As String = "") As String Public Shared Function getPDFViaSpirePDF_FromURL(URL As String, Optional targetPath As String = "", Optional openFileAfterDownload As Boolean = False) As String
Try Try
If targetPath = "" Then targetPath = getTMPPath_PDF() If targetPath = "" Then targetPath = getTMPPath_PDF()
@@ -1479,6 +1479,9 @@ Public Class cFormularManager
Return "" Return ""
End Function End Function
Public Shared Sub PrintViaSpirePDF(task As Task(Of List(Of String)))
Throw New NotImplementedException()
End Sub
End Class End Class

View File

@@ -1,6 +1,7 @@
Imports System.Data.SqlClient Imports System.Data.SqlClient
Imports System.Net Imports System.Net
Imports System.Reflection Imports System.Reflection
Imports System.ServiceModel.Security
Imports System.Threading Imports System.Threading
Imports System.Web.Routing Imports System.Web.Routing
Imports System.Windows.Forms Imports System.Windows.Forms
@@ -8,6 +9,107 @@ Imports System.Windows.Forms.VisualStyles.VisualStyleElement
Imports Chilkat Imports Chilkat
Imports Newtonsoft.Json.Linq Imports Newtonsoft.Json.Linq
Public Class cATEZ_NCTS_Sessions
Public Property session_Id As Integer
Public Property token As String
Public Property datetime As DateTime = Now()
Public Property refresh_token As String
Public Property token_validuntil As DateTime
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
Public hasEntry As Boolean
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("session_Id", session_Id, , True, True))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("token", token))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("datetime", datetime))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("refresh_token", refresh_token))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("token_validuntil", token_validuntil))
Return list
End Function
Sub New()
LOAD()
End Sub
Sub New(token As String, refreshtoken As String, timestamp As DateTime)
Me.token = token
Me.refresh_token = refreshtoken
token_validuntil = timestamp
SAVE()
End Sub
Public Function SAVE(Optional errHinweis = "") As Boolean
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim sqlstr = " BEGIN TRAN " & getInsertCmd() &
" commit tran "
Dim IdTMP = session_Id
IdTMP = SQL.doSQLVarListID(IdTMP, sqlstr, "FMZOLL", , list, , errHinweis)
If session_Id <= 0 Then session_Id = IdTMP
Return session_Id > 0
End Function
Public Function getInsertCmd() As String
Try
Dim list As List(Of VERAG_PROG_ALLGEMEIN.SQLVariable) = getParameterList()
Dim str As String = ""
Dim values As String = ""
For Each i In list
If Not i.isPrimaryParam Then
str &= "[" & i.Text & "],"
values &= "@" & i.Scalarvariable & "," '.Replace("-", "").Replace(" ", "") & ","
End If
Next
str = str.Substring(0, str.Length - 1) 'wg. ','
values = values.Substring(0, values.Length - 1) 'wg. ','
Return (" INSERT INTO tblATEZ_NCTS_Sessions (" & str & ") VALUES(" & values & ") ")
Catch ex As Exception
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
Return ""
End Function
Public Sub LOAD()
Try
hasEntry = False
Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL()
Using cmd As New SqlCommand("SELECT TOP(1) * FROM tblATEZ_NCTS_Sessions where token_validuntil >= dateadd(minute,-10,getdate()) order by datetime desc ", conn)
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
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
End Try
End Sub
End Class
Public Class cATEZ_NCTS_DATA Public Class cATEZ_NCTS_DATA
Public Property Id As Integer Public Property Id As Integer
@@ -41,6 +143,7 @@ Public Class cATEZ_NCTS_DATA
Public Property selectedDocuments As String Public Property selectedDocuments As String
Public Property fehlerbeschreibung As String Public Property fehlerbeschreibung As String
Public Property json As String Public Property json As String
Public Property sessionId As Integer
Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
@@ -78,6 +181,7 @@ Public Class cATEZ_NCTS_DATA
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dakosy_ref", dakosy_ref)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("dakosy_ref", dakosy_ref))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("selectedDocuments", selectedDocuments)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("selectedDocuments", selectedDocuments))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fehlerbeschreibung", fehlerbeschreibung)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fehlerbeschreibung", fehlerbeschreibung))
list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sessionId", sessionId))
Return list Return list
End Function End Function
@@ -507,13 +611,25 @@ Public Class cATEZ_NCTS_IN
'PROD 'PROD
Shared API_STRING As String = "https://transcom.singlewindow.io" Shared API_STRING As String = "https://transcom.singlewindow.io"
Shared token As String = "" Shared token As String = ""
Shared refresh_token As String = ""
Public dataTable As New DataTable() Public dataTable As New DataTable()
Shared jsonData As New Chilkat.JsonObject Shared jsonData As New Chilkat.JsonObject
Public Shared sessionID As Integer = -1
Shared Function SendRequestAuthentificationToken(ByVal myuri As String, ByVal contentType As String, ByVal method As String, ByRef Itoken As String) As String Shared Function SendRequestAuthentificationToken(ByVal myuri As String, ByVal contentType As String, ByVal method As String, ByRef Itoken As String) As String
Try Try
If Itoken <> "" Then Return "200"
Dim session = New cATEZ_NCTS_Sessions()
If Not IsDBNull(session.token) AndAlso session.token IsNot Nothing Then
Itoken = session.token
token = Itoken
sessionID = session.session_Id
Return "200"
End If
VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat() VERAG_PROG_ALLGEMEIN.cChilkat_Helper.UnlockCilkat()
@@ -556,9 +672,13 @@ Public Class cATEZ_NCTS_IN
Dim jsonResp = New Chilkat.JsonObject() Dim jsonResp = New Chilkat.JsonObject()
jsonResp.LoadSb(sbResponseBody) jsonResp.LoadSb(sbResponseBody)
Itoken = jsonResp.StringOf("access_token")
token = jsonResp.StringOf("access_token") token = Itoken
Itoken = token refresh_token = jsonResp.StringOf("refresh_token")
Dim now As DateTime = DateTime.Now()
now = now.AddSeconds(jsonResp.IntOf("expires_in"))
session = New cATEZ_NCTS_Sessions(Itoken, refresh_token, now.ToString("yyyy-MM-dd HH:mm:ss"))
sessionID = session.session_Id
Return rest.ResponseStatusCode Return rest.ResponseStatusCode
Catch ex As WebException Catch ex As WebException