From 2de1e68a43caae87477716895af00b2f4a07e1e5 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Mon, 25 Sep 2023 16:13:01 +0200 Subject: [PATCH 1/2] Messenger, Essensbestellungen, cDatenserver, ATEZ --- SDL/frmEssensbestellungen.vb | 3 +- .../DATENSERVER/cDATENSERVER.vb | 5 +- .../Messenger/frmMessenger.Designer.vb | 13 +- .../ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb | 128 +++++++++++++++++- 4 files changed, 136 insertions(+), 13 deletions(-) diff --git a/SDL/frmEssensbestellungen.vb b/SDL/frmEssensbestellungen.vb index d500547e..9b69f64a 100644 --- a/SDL/frmEssensbestellungen.vb +++ b/SDL/frmEssensbestellungen.vb @@ -415,9 +415,10 @@ Public Class frmEssensbestellungen End If Next + Dim bestellung As New cEssensbestellung(dgvBestellungen.SelectedRows(0).Cells("eb_kw").Value, dgvBestellungen.SelectedRows(0).Cells("eb_mitid").Value) txtAnzahlMenu.Text = countMenus.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 diff --git a/VERAG_PROG_ALLGEMEIN/DATENSERVER/cDATENSERVER.vb b/VERAG_PROG_ALLGEMEIN/DATENSERVER/cDATENSERVER.vb index b472b58b..72af02c1 100644 --- a/VERAG_PROG_ALLGEMEIN/DATENSERVER/cDATENSERVER.vb +++ b/VERAG_PROG_ALLGEMEIN/DATENSERVER/cDATENSERVER.vb @@ -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 If targetPath = "" Then targetPath = getTMPPath_PDF() @@ -1479,6 +1479,9 @@ Public Class cFormularManager Return "" End Function + Public Shared Sub PrintViaSpirePDF(task As Task(Of List(Of String))) + Throw New NotImplementedException() + End Sub End Class diff --git a/VERAG_PROG_ALLGEMEIN/Messenger/frmMessenger.Designer.vb b/VERAG_PROG_ALLGEMEIN/Messenger/frmMessenger.Designer.vb index 30d0ab19..455f96cc 100644 --- a/VERAG_PROG_ALLGEMEIN/Messenger/frmMessenger.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/Messenger/frmMessenger.Designer.vb @@ -24,7 +24,6 @@ Partial Class frmMessenger 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. _ Private Sub InitializeComponent() - Me.components = New System.ComponentModel.Container() Dim DataGridViewCellStyle1 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() Dim DataGridViewCellStyle3 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() @@ -39,11 +38,11 @@ Partial Class frmMessenger Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMessenger)) Me.SplitContainer = New System.Windows.Forms.SplitContainer() Me.SplitContainer2 = New System.Windows.Forms.SplitContainer() - Me.dgvChats = New VERAG_PROG_ALLGEMEIN.MyDatagridview(Me.components) + Me.dgvChats = New VERAG_PROG_ALLGEMEIN.MyDatagridview() Me.Panel6 = New System.Windows.Forms.Panel() Me.lblLKWChat_MsgCntInaktiv = New System.Windows.Forms.Label() Me.cbxInaktiveChats = New System.Windows.Forms.CheckBox() - Me.DGVSonstige = New VERAG_PROG_ALLGEMEIN.MyDatagridview(Me.components) + Me.DGVSonstige = New VERAG_PROG_ALLGEMEIN.MyDatagridview() Me.Panel5 = New System.Windows.Forms.Panel() Me.MyTextBox2 = New VERAG_PROG_ALLGEMEIN.MyTextBox() Me.PictureBox2 = New System.Windows.Forms.PictureBox() @@ -64,7 +63,7 @@ Partial Class frmMessenger Me.btnNeu = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() Me.SplitContainer1 = New System.Windows.Forms.SplitContainer() - Me.MyFlowLayoutPanel1 = New VERAG_PROG_ALLGEMEIN.MyFlowLayoutPanel(Me.components) + Me.MyFlowLayoutPanel1 = New VERAG_PROG_ALLGEMEIN.MyFlowLayoutPanel() Me.UsrCntlMessenger_ChatElement1 = New VERAG_PROG_ALLGEMEIN.usrCntlMessenger_ChatElement() Me.Panel3 = New System.Windows.Forms.Panel() Me.btnTeilnehmer = New System.Windows.Forms.Button() @@ -91,9 +90,9 @@ Partial Class frmMessenger Me.btnSendAtt = New System.Windows.Forms.Button() Me.btnSenden = New System.Windows.Forms.Button() Me.rtbChatMessage = New System.Windows.Forms.RichTextBox() - Me.TimerNEW_MESSAGE = New System.Windows.Forms.Timer(Me.components) - Me.Timer_REFRESH = New System.Windows.Forms.Timer(Me.components) - Me.cntxt = New System.Windows.Forms.ContextMenuStrip(Me.components) + Me.TimerNEW_MESSAGE = New System.Windows.Forms.Timer() + Me.Timer_REFRESH = New System.Windows.Forms.Timer() + Me.cntxt = New System.Windows.Forms.ContextMenuStrip() Me.ChatDeaktivierenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.toolChatReminder = New System.Windows.Forms.ToolStripMenuItem() Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn() diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb index 4fdedd30..a74910e1 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb @@ -1,6 +1,7 @@ Imports System.Data.SqlClient Imports System.Net Imports System.Reflection +Imports System.ServiceModel.Security Imports System.Threading Imports System.Web.Routing Imports System.Windows.Forms @@ -8,6 +9,107 @@ Imports System.Windows.Forms.VisualStyles.VisualStyleElement Imports Chilkat 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 >= 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 Property Id As Integer @@ -41,6 +143,7 @@ Public Class cATEZ_NCTS_DATA Public Property selectedDocuments As String Public Property fehlerbeschreibung As String Public Property json As String + Public Property sessionId As Integer 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("selectedDocuments", selectedDocuments)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("fehlerbeschreibung", fehlerbeschreibung)) + list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("sessionId", sessionId)) Return list End Function @@ -507,13 +611,25 @@ Public Class cATEZ_NCTS_IN 'PROD Shared API_STRING As String = "https://transcom.singlewindow.io" Shared token As String = "" + Shared refresh_token As String = "" Public dataTable As New DataTable() 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 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() @@ -556,9 +672,13 @@ Public Class cATEZ_NCTS_IN Dim jsonResp = New Chilkat.JsonObject() jsonResp.LoadSb(sbResponseBody) - - token = jsonResp.StringOf("access_token") - Itoken = token + Itoken = jsonResp.StringOf("access_token") + token = Itoken + 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 Catch ex As WebException From c8a9897afd9f9e157e709d935cbfee4945aae1dc Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Mon, 25 Sep 2023 16:19:01 +0200 Subject: [PATCH 2/2] ATEZ, MEssenger --- .../Messenger/frmMessenger.Designer.vb | 13 +++++++------ .../ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb | 2 +- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/VERAG_PROG_ALLGEMEIN/Messenger/frmMessenger.Designer.vb b/VERAG_PROG_ALLGEMEIN/Messenger/frmMessenger.Designer.vb index 455f96cc..30d0ab19 100644 --- a/VERAG_PROG_ALLGEMEIN/Messenger/frmMessenger.Designer.vb +++ b/VERAG_PROG_ALLGEMEIN/Messenger/frmMessenger.Designer.vb @@ -24,6 +24,7 @@ Partial Class frmMessenger 'Das Bearbeiten mit dem Code-Editor ist nicht möglich. _ Private Sub InitializeComponent() + Me.components = New System.ComponentModel.Container() Dim DataGridViewCellStyle1 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() Dim DataGridViewCellStyle2 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() Dim DataGridViewCellStyle3 As System.Windows.Forms.DataGridViewCellStyle = New System.Windows.Forms.DataGridViewCellStyle() @@ -38,11 +39,11 @@ Partial Class frmMessenger Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMessenger)) Me.SplitContainer = New System.Windows.Forms.SplitContainer() Me.SplitContainer2 = New System.Windows.Forms.SplitContainer() - Me.dgvChats = New VERAG_PROG_ALLGEMEIN.MyDatagridview() + Me.dgvChats = New VERAG_PROG_ALLGEMEIN.MyDatagridview(Me.components) Me.Panel6 = New System.Windows.Forms.Panel() Me.lblLKWChat_MsgCntInaktiv = New System.Windows.Forms.Label() Me.cbxInaktiveChats = New System.Windows.Forms.CheckBox() - Me.DGVSonstige = New VERAG_PROG_ALLGEMEIN.MyDatagridview() + Me.DGVSonstige = New VERAG_PROG_ALLGEMEIN.MyDatagridview(Me.components) Me.Panel5 = New System.Windows.Forms.Panel() Me.MyTextBox2 = New VERAG_PROG_ALLGEMEIN.MyTextBox() Me.PictureBox2 = New System.Windows.Forms.PictureBox() @@ -63,7 +64,7 @@ Partial Class frmMessenger Me.btnNeu = New System.Windows.Forms.Button() Me.Button1 = New System.Windows.Forms.Button() Me.SplitContainer1 = New System.Windows.Forms.SplitContainer() - Me.MyFlowLayoutPanel1 = New VERAG_PROG_ALLGEMEIN.MyFlowLayoutPanel() + Me.MyFlowLayoutPanel1 = New VERAG_PROG_ALLGEMEIN.MyFlowLayoutPanel(Me.components) Me.UsrCntlMessenger_ChatElement1 = New VERAG_PROG_ALLGEMEIN.usrCntlMessenger_ChatElement() Me.Panel3 = New System.Windows.Forms.Panel() Me.btnTeilnehmer = New System.Windows.Forms.Button() @@ -90,9 +91,9 @@ Partial Class frmMessenger Me.btnSendAtt = New System.Windows.Forms.Button() Me.btnSenden = New System.Windows.Forms.Button() Me.rtbChatMessage = New System.Windows.Forms.RichTextBox() - Me.TimerNEW_MESSAGE = New System.Windows.Forms.Timer() - Me.Timer_REFRESH = New System.Windows.Forms.Timer() - Me.cntxt = New System.Windows.Forms.ContextMenuStrip() + Me.TimerNEW_MESSAGE = New System.Windows.Forms.Timer(Me.components) + Me.Timer_REFRESH = New System.Windows.Forms.Timer(Me.components) + Me.cntxt = New System.Windows.Forms.ContextMenuStrip(Me.components) Me.ChatDeaktivierenToolStripMenuItem = New System.Windows.Forms.ToolStripMenuItem() Me.toolChatReminder = New System.Windows.Forms.ToolStripMenuItem() Me.DataGridViewTextBoxColumn1 = New System.Windows.Forms.DataGridViewTextBoxColumn() diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb index a74910e1..34791fe4 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/ATEZ/VERAG_OUT_ATEZ_IN/cATEZ_NCTS_IN.vb @@ -83,7 +83,7 @@ Public Class cATEZ_NCTS_Sessions Try hasEntry = False Using conn As SqlConnection = SQL.GetNewOpenConnectionFMZOLL() - Using cmd As New SqlCommand("SELECT TOP(1) * FROM tblATEZ_NCTS_Sessions where token_validuntil >= GetDate() order by datetime desc ", conn) + 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