From e5f1d2ef4a33207a558b4824ca473280cdf2d0c5 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Mon, 13 Nov 2023 16:07:30 +0100 Subject: [PATCH] Digicust, Timas, Essensbestellungen --- SDL/UsrCntlEssensbestellungen.vb | 2 +- SDL/frmMain.vb | 5 +- .../frmMitarbeitersuche.vb | 10 +- .../Schnittstellen/Digicast/cDigicustAPI.vb | 94 ++++++++++++++----- .../Schnittstellen/TIMAS/cTimasAPI.vb | 13 ++- 5 files changed, 92 insertions(+), 32 deletions(-) diff --git a/SDL/UsrCntlEssensbestellungen.vb b/SDL/UsrCntlEssensbestellungen.vb index f09b3091..af55b585 100644 --- a/SDL/UsrCntlEssensbestellungen.vb +++ b/SDL/UsrCntlEssensbestellungen.vb @@ -586,7 +586,7 @@ Public Class UsrCntlessensbestellungen cbxMenu.fillWithSQL("SELECT Distinct Top 50 (REPLACE(MenuTitel,'Wochenkarte ','')) + ' - ' + Convert(varchar, Year(MenuDateVon)), MenuDateVon from tblEBMenu order by MenuDateVon desc", True, "AVISO", True) '/ where MenuDateVon >= GETDATE() - cbxMitarbeiter.fillWithSQL("SELECT [mit_id], ([mit_vname] + ' ' + [mit_nname]) as name FROM [tblMitarbeiter] where [mit_ChatBenutzer] = 1 AND [mit_pseudoUser] = 0 AND [mit_gekuendigt] = 0 AND mit_niederlassung = 'SUB' AND ((CAse when mit_firma = 'ALL' Then mit_FirmaHaupt else mit_firma END ) = 'VERAG' Or mit_firma = 'UNISPED' OR mit_firma = 'IMEX' OR mit_firma = 'FRONTOFFICE') order by name ", False, "ADMIN", True) + cbxMitarbeiter.fillWithSQL("SELECT [mit_id], ([mit_vname] + ' ' + [mit_nname]) as name FROM [tblMitarbeiter] where [mit_ChatBenutzer] = 1 AND [mit_pseudoUser] = 0 AND [mit_gekuendigt] = 0 AND mit_niederlassung = 'SUB' AND ((CAse when mit_firma = 'ALL' Then mit_FirmaHaupt else mit_firma END ) = 'VERAG' Or mit_firma = 'UNISPED' OR mit_firma = 'IMEX' OR mit_firma = 'FRONTOFFICE') Or mit_id = 144 order by name ", False, "ADMIN", True) cbxAbteilung.fillWithSQL("SELECT [abt_kuerzel], [abt_bezeichnung] from [tblAbteilungen] ", False, "ADMIN", True,, "") cbxGebäude.Items.Add(New VERAG_PROG_ALLGEMEIN.MyListItem("Frontoffice", "Frontoffice")) diff --git a/SDL/frmMain.vb b/SDL/frmMain.vb index 2b01dbcd..eb4e8d39 100644 --- a/SDL/frmMain.vb +++ b/SDL/frmMain.vb @@ -143,8 +143,9 @@ Public Class frmMain Dim timas As New cTimasAPI Dim infoMessage As String = "" Dim timeEntryExisting As Boolean = False - timas.getTimeEntries(cAllgemein.MITARBEITER.mit_timasId, Nothing, timeEntryExisting) - If Not timeEntryExisting Then + Dim isEndpointRunning As Boolean + timas.getTimeEntries(cAllgemein.MITARBEITER.mit_timasId, Nothing, timeEntryExisting,, isEndpointRunning) + If Not timeEntryExisting AndAlso isEndpointRunning Then Dim a As MsgBoxResult = MsgBox("Für " & VERAG_PROG_ALLGEMEIN.cAllgemein.USRKURZNAME & " wurde heute noch keine Zeit erfasst!" & vbNewLine & Now.ToString() & " als Startzeit erfassen?", vbYesNo) If a = vbYes Then Dim info diff --git a/VERAG_PROG_ALLGEMEIN/Mitarbeiterverzeichnis/frmMitarbeitersuche.vb b/VERAG_PROG_ALLGEMEIN/Mitarbeiterverzeichnis/frmMitarbeitersuche.vb index 4d550046..9f6d3898 100644 --- a/VERAG_PROG_ALLGEMEIN/Mitarbeiterverzeichnis/frmMitarbeitersuche.vb +++ b/VERAG_PROG_ALLGEMEIN/Mitarbeiterverzeichnis/frmMitarbeitersuche.vb @@ -322,12 +322,11 @@ Public Class frmMitarbeitersuche Dim timeEntryExisting As Boolean = False Dim isOnline = timas.getTimeEntries(cAllgemein.MITARBEITER.mit_timasId, Nothing, timeEntryExisting) - If timeEntryExisting AndAlso isOnline Then timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "out", 0) 'Ende - timestp = timestp.AddMinutes(1) timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "in", 6) 'Start Post 6 Postgang timestp = timestp.AddHours(1) timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "out", 6) ' Ende Post 6 Postgang + If timeEntryExisting AndAlso isOnline Then timas.setTimeEntry(cAllgemein.MITARBEITER, timestp, info, "out", 0) 'Ende MsgBox(info) Thread.Sleep(2000) 'warten bis Eintrag in Timas-DB requestDone = False @@ -367,7 +366,12 @@ Public Class frmMitarbeitersuche lblTimasSaldo.Text = "" Dim dtZeiten As New DataTable If timas IsNot Nothing Then - timas.getTimeSaldo(MA.mit_timasId, lblTimasSaldo.Text) + Dim isServiceRunning As Boolean = True + timas.getTimeSaldo(MA.mit_timasId, lblTimasSaldo.Text, isServiceRunning) + If Not isServiceRunning Then + MsgBox("Abfragefehler!") + Exit Sub + End If lblStatusZE.Visible = True Dim checkEntry As Boolean = timas.getTimeEntries(MA.mit_timasId, dtZeiten,, requestDone) diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb index f25004f4..93d71e53 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/Digicast/cDigicustAPI.vb @@ -1,16 +1,10 @@ -Imports System.ComponentModel.Design -Imports System.Data.SqlClient +Imports System.Data.SqlClient Imports System.Net Imports System.Reflection -Imports System.ServiceModel.Security Imports System.Threading Imports System.Windows.Forms -Imports System.Windows.Forms.VisualStyles.VisualStyleElement Imports Chilkat Imports iTextSharp.text -Imports Newtonsoft.Json.Linq -Imports Org.BouncyCastle.Bcpg -Imports VERAG_PROG_ALLGEMEIN.cCreditSafeAPI Public Class cDigicustSessions @@ -124,6 +118,8 @@ Public Class cDigicustSettings Public Property valid As Boolean Public Property companyId As Integer Public Property description As String + Public Property type As String + Public Property companyGroup As String Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL @@ -140,6 +136,8 @@ Public Class cDigicustSettings list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("valid", valid)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("companyId", companyId)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("description", description)) + list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("companyGroup", companyGroup)) + list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("type", Type)) Return list End Function @@ -209,6 +207,9 @@ Public Class cDigicustSendungen Public Property prepaper_code As String Public Property licencePlate As String Public Property lkwCountryId As String + Public Property customsOfficeNr As String + Public Property settingsId As Integer + Public Property type As String Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL @@ -244,6 +245,9 @@ Public Class cDigicustSendungen list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("prepaper_code", prepaper_code)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("licencePlate", licencePlate)) list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("lkwCountryId", lkwCountryId)) + list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("customsOfficeNr", customsOfficeNr)) + list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("settingsId", settingsId)) + list.Add(New VERAG_PROG_ALLGEMEIN.SQLVariable("type", type)) Return list End Function @@ -405,7 +409,7 @@ Public Class cDigicustAPI now = now.AddSeconds(jsonResp.IntOf("expires_in")) session = New cDigicustSessions(_token, refresh_token, now.ToString("yyyy-MM-dd HH:mm:ss")) - Return rest.ResponseStatusCode & " " & rest.ResponseStatusText + Return rest.ResponseStatusCode Catch ex As WebException VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) @@ -421,7 +425,8 @@ Public Class cDigicustAPI End Function - Shared Function uploadingCase(dig As cDigicustSendungen, settings As cDigicustSettings, dgv As DataGridView, withAvisoData As Boolean) As Boolean + Shared Function uploadingCase(dig As cDigicustSendungen, settings As cDigicustSettings, dgv As DataGridView, withAvisoData As Boolean, sender As Boolean, recipient As Boolean) As Boolean + Dim rest As New Chilkat.Rest Dim success As Boolean @@ -491,7 +496,7 @@ Public Class cDigicustAPI rest.SetMultipartBodyString(dig.reference) counter += 1 - If withAvisoData Then createUserinput(rest, counter, dig) + If withAvisoData Then createUserinput(rest, counter, dig, sender, recipient) rest.PartSelector = "0" @@ -559,6 +564,12 @@ Public Class cDigicustAPI Dim jsonResp = New Chilkat.JsonObject() jsonResp.Load(responseBodyStr) + If (jsonResp.LastMethodSuccess <> True) Then + MsgBox(rest.LastErrorText) + Return False + End If + + Dim dateTime As New Chilkat.CkDateTime Dim getAsLocal As Boolean = False jsonResp.DateOf("result.createdAt", dateTime) @@ -639,7 +650,7 @@ Public Class cDigicustAPI End Function - Shared Function createUserinput(ByRef rest As Chilkat.Rest, ByRef counter As Integer, ByVal sendung As cDigicustSendungen) + Shared Function createUserinput(ByRef rest As Chilkat.Rest, ByRef counter As Integer, ByVal sendung As cDigicustSendungen, ByRef sender As Boolean, ByRef recipient As Boolean) 'zusätzliche Informationen aus dem AVISO @@ -653,22 +664,59 @@ Public Class cDigicustAPI json.UpdateString("documentStatus", "finished") json.UpdateString("documentType", "UserInput") - If sendung.consignee_name <> "" Then json.UpdateString("annotatedAggregated.consignee.name.input", sendung.consignee_name) + If recipient Then 'im DIGICUST werden Stakeholder Buyer, Importeur, Declarant, und Consignee gesetzt! - If sendung.consignee_address <> "" Then json.UpdateString("annotatedAggregated.consignee.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, "")) + If sendung.consignee_name <> "" Then + json.UpdateString("annotatedAggregated.consignee.name.input", sendung.consignee_name) + json.UpdateString("annotatedAggregated.declarant.name.input", sendung.consignee_name) + json.UpdateString("annotatedAggregated.importer.name.input", sendung.consignee_name) + json.UpdateString("annotatedAggregated.buyer.name.input", sendung.consignee_name) + End If + If sendung.consignee_address <> "" Then + json.UpdateString("annotatedAggregated.consignee.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, "")) + json.UpdateString("annotatedAggregated.declarant.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, "")) + json.UpdateString("annotatedAggregated.importer.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, "")) + json.UpdateString("annotatedAggregated.buyer.address.input", sendung.consignee_address & IIf(sendung.consignee_postcode <> "", " / " & sendung.consignee_postcode, "") & IIf(sendung.consignee_city_name <> "", " " & sendung.consignee_city_name, "")) + End If + If sendung.consignee_eori <> "" Then + json.UpdateString("annotatedAggregated.consignee.EORI.input", sendung.consignee_eori) + json.UpdateString("annotatedAggregated.declarant.EORI.input", sendung.consignee_eori) + json.UpdateString("annotatedAggregated.importer.EORI.input", sendung.consignee_eori) + json.UpdateString("annotatedAggregated.buyer.EORI.input", sendung.consignee_eori) + End If - If sendung.consignee_eori <> "" Then json.UpdateString("annotatedAggregated.consignee.EORI.input", sendung.consignee_eori) - - If sendung.licencePlate <> "" AndAlso sendung.lkwCountryId <> "" Then - json.UpdateString("annotatedAggregated.meansOfTransportation[0].type", "Border") - json.UpdateString("annotatedAggregated.meansOfTransportation[0].value", "Road") - json.UpdateString("annotatedAggregated.meansOfTransportation[0].licensePlate", sendung.licencePlate) - json.UpdateString("annotatedAggregated.meansOfTransportation[0].countryCode", sendung.lkwCountryId) End If - 'json.UpdateString("annotatedAggregated.consignee.email.input", "") - 'json.UpdateString("annotatedAggregated.consignee.contactPerson.input", "Herr Berger") - 'json.UpdateString("annotatedAggregated.consignee.VAT.input", "") + + If sender Then 'im DIGICUST werden Stakeholder Shipper und Exporter gesetzt! + If sendung.consignor_name <> "" Then + json.UpdateString("annotatedAggregated.shipper.name.input", sendung.consignor_name) + json.UpdateString("annotatedAggregated.exporter.name.input", sendung.consignor_name) + End If + If sendung.consignor_address <> "" Then + json.UpdateString("annotatedAggregated.shipper.address.input", sendung.consignor_address & IIf(sendung.consignor_postcode <> "", " / " & sendung.consignor_postcode, "") & IIf(sendung.consignor_city_name <> "", " " & sendung.consignor_city_name, "")) + json.UpdateString("annotatedAggregated.exporter.address.input", sendung.consignor_address & IIf(sendung.consignor_postcode <> "", " / " & sendung.consignor_postcode, "") & IIf(sendung.consignor_city_name <> "", " " & sendung.consignor_city_name, "")) + End If + If sendung.consignor_eori <> "" Then + json.UpdateString("annotatedAggregated.shipper.EORI.input", sendung.consignor_eori) + json.UpdateString("annotatedAggregated.exporter.EORI.input", sendung.consignor_eori) + End If + End If + + + + If Not (sendung.licencePlate = "" And sendung.lkwCountryId = "") Then + json.UpdateString("annotatedAggregated.meansOfTransportation[0].type", "Border") + json.UpdateString("annotatedAggregated.meansOfTransportation[0].value", "Road") + If sendung.licencePlate <> "" Then json.UpdateString("annotatedAggregated.meansOfTransportation[0].licensePlate", sendung.licencePlate) + If sendung.lkwCountryId <> "" Then json.UpdateString("annotatedAggregated.meansOfTransportation[0].countryCode", sendung.lkwCountryId) + End If + + If sendung.customsOfficeNr <> "" AndAlso sendung.type <> "" Then + json.UpdateString("annotatedAggregated.customsOffices[0].value", sendung.customsOfficeNr) + json.UpdateString("annotatedAggregated.customsOffices[0].officeType", sendung.type) + End If + rest.PartSelector = counter diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/TIMAS/cTimasAPI.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/TIMAS/cTimasAPI.vb index c493a245..cb315d36 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/TIMAS/cTimasAPI.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/TIMAS/cTimasAPI.vb @@ -49,7 +49,7 @@ Public Class cTimasAPI End Function - Public Sub getTimeSaldo(maid As Integer, ByRef info As String, Optional ByRef requestDone As Boolean = False) + Public Sub getTimeSaldo(maid As Integer, ByRef info As String, Optional isEndpointRunning As Boolean = True) Try Dim returnText As String = "" Dim failureText As String = "" @@ -66,10 +66,12 @@ Public Class cTimasAPI Dim success As Boolean - + rest.IdleTimeoutMs = 5000 Dim responseJson As String = rest.FullRequestNoBody("GET", "/rest/web-api/employees/" & maid & "/balance") If (rest.LastMethodSuccess <> True) Then Debug.WriteLine(rest.LastErrorText) + isEndpointRunning = rest.LastMethodSuccess + rest.IdleTimeoutMs = 30000 'defualt Exit Sub End If @@ -117,7 +119,7 @@ Public Class cTimasAPI End Sub - Public Function getTimeEntries(ByVal maid As Integer, ByRef dtZeiten As DataTable, Optional ByRef entryExistingToday As Boolean = True, Optional ByRef requestDone As Boolean = False) As Boolean + Public Function getTimeEntries(ByVal maid As Integer, ByRef dtZeiten As DataTable, Optional ByRef entryExistingToday As Boolean = True, Optional ByRef requestDone As Boolean = False, Optional isEndpointRunning As Boolean = True) As Boolean Try Dim isPresent = False @@ -141,10 +143,15 @@ Public Class cTimasAPI Dim Response As String + rest.IdleTimeoutMs = 5000 '5 sec Response = rest.FullRequestNoBody("GET", "/rest/web-api/employees/" & maid & "/bookings") If (rest.LastMethodSuccess <> True) Then Debug.WriteLine(rest.LastErrorText) + isEndpointRunning = rest.LastMethodSuccess + rest.IdleTimeoutMs = 30000 'defualt Return isPresent + Else + rest.IdleTimeoutMs = 30000 End If If (rest.ResponseStatusCode <> 200) Then