From 3930d9c18cca092083d43bca9ab1cdf3592542a0 Mon Sep 17 00:00:00 2001 From: "d.breimaier" Date: Thu, 22 Aug 2024 11:56:51 +0200 Subject: [PATCH] USTV, MSE, MDM --- SDL/My Project/AssemblyInfo.vb | 4 +- SDL/USTV/usrCntlUSTV.vb | 2 +- SDL/USTV/ustCntlUSTV_AntragPosition.vb | 3 +- SDL/mdm/frmMDMDatenverarbetiung.vb | 13 +- .../Schnittstellen/MSE/cMSEAPI.vb | 137 ++++++++++++++++-- .../VERAG_PROG_ALLGEMEIN.vbproj | 9 +- 6 files changed, 142 insertions(+), 26 deletions(-) diff --git a/SDL/My Project/AssemblyInfo.vb b/SDL/My Project/AssemblyInfo.vb index c4994e53..4c8feec9 100644 --- a/SDL/My Project/AssemblyInfo.vb +++ b/SDL/My Project/AssemblyInfo.vb @@ -31,5 +31,5 @@ Imports System.Runtime.InteropServices ' übernehmen, indem Sie "*" eingeben: ' - - + + diff --git a/SDL/USTV/usrCntlUSTV.vb b/SDL/USTV/usrCntlUSTV.vb index a8b48640..e61bb393 100644 --- a/SDL/USTV/usrCntlUSTV.vb +++ b/SDL/USTV/usrCntlUSTV.vb @@ -2,7 +2,7 @@ Imports System.Data.SqlClient Imports Microsoft.Office.Interop Imports VERAG_PROG_ALLGEMEIN -Imports VERAG_PROG_ALLGEMEIN.CBAM_QReport_17 + Public Class usrCntlUSTV diff --git a/SDL/USTV/ustCntlUSTV_AntragPosition.vb b/SDL/USTV/ustCntlUSTV_AntragPosition.vb index 80e78c08..4c035502 100644 --- a/SDL/USTV/ustCntlUSTV_AntragPosition.vb +++ b/SDL/USTV/ustCntlUSTV_AntragPosition.vb @@ -1,4 +1,5 @@ -Imports java.awt.print + + Imports VERAG_PROG_ALLGEMEIN Public Class ustCntlUSTV_AntragPosition diff --git a/SDL/mdm/frmMDMDatenverarbetiung.vb b/SDL/mdm/frmMDMDatenverarbetiung.vb index 3ca05232..0ede3f90 100644 --- a/SDL/mdm/frmMDMDatenverarbetiung.vb +++ b/SDL/mdm/frmMDMDatenverarbetiung.vb @@ -448,14 +448,14 @@ Public Class frmMDMDatenverarbetiung Dim displayFilter = False Dim sqlstr As String = "" - sqlstr &= " SELECT Adressen.AdressenNr, Adressen.[Name 1], trans.transaction_country AS Country,trans.device_product_type AS CardType, Sum(trans.transaction_gross_amount) AS [Transaction Amount], Sum(trans.total_gross_amount) AS [Total Amount] + sqlstr &= " SELECT Adressen.AdressenNr as KundenNr, Adressen.[Name 1] as Name, trans.transaction_country AS Country,trans.device_product_type AS CardType, trans.device_product_number AS CardNr,Sum(trans.transaction_gross_amount) AS [Transaction Amount], Sum(trans.total_gross_amount) AS [Total Amount] FROM [VERAG].[dbo].[tblMSESettlements] as bills inner join [VERAG].[dbo].[tblMSETransactions] as trans on bills.[transaction_id] = trans.[transaction_id] inner join [VERAG].[dbo].[tblMSECustomers] as cust on cust.partner_customer_number = trans.partner_haulier_id inner join [VERAG].[dbo].[tblMSEInvoices] as inv on inv.[invoice_id] = bills.[invoice_number] and inv.customer_number = cust.[customer_id] and trans.transaction_country = inv.country left join adressen ON cust.[customer_id] = Adressen.MSEKundenNr where bills.invoice_date = '" & DateTimePicker2.Text & "' and trans.charged <> 1 - GROUP BY Adressen.AdressenNr, Adressen.[Name 1], trans.transaction_country, trans.device_product_type order by cust.customer_id" + GROUP BY Adressen.AdressenNr, Adressen.[Name 1], trans.transaction_country, trans.device_product_type, trans.device_product_number " Dim dt As DataTable = SQL.loadDgvBySql_Param(sqlstr, "FMZOLL") 'DataGridView.DataSource = dt @@ -468,9 +468,8 @@ Public Class frmMDMDatenverarbetiung rpt.DataSource = dt - 'If cbxProdukt.Checked Then - ' rpt.GroupHeader2.DataField = "prod_descr" + 'Else ' rpt.GroupHeader2.Visible = False ' rpt.GroupFooter2.Visible = False @@ -503,7 +502,7 @@ Public Class frmMDMDatenverarbetiung rpt.lblKundennr.Text = SQL.isDbnullEmpty(rpt.Fields.Item("KundenNr").Value, "") rpt.lblName1.Text = SQL.isDbnullEmpty(rpt.Fields.Item("Name").Value, "") - rpt.lblKartennr.Text = SQL.isDbnullEmpty(rpt.Fields.Item("Country").Value, "") & " " & SQL.isDbnullEmpty(rpt.Fields.Item("CardType").Value, "") + rpt.lblKartennr.Text = SQL.isDbnullEmpty(rpt.Fields.Item("CardType").Value, "") & " - " & SQL.isDbnullEmpty(rpt.Fields.Item("Country").Value, "") & " - " & SQL.isDbnullEmpty(rpt.Fields.Item("CardNr").Value, "") rpt.lblNetto.Text = SQL.isDbnullEmptyDbl(rpt.Fields.Item("Transaction Amount").Value, 2, "") rpt.lblMWST.Text = "" 'SQL.isDbnullEmptyDbl(CDbl(rpt.Fields.Item("SummevonGesamtbetrag_Brutto_in_Darstellwährung").Value) - CDbl(rpt.Fields.Item("SummevonGesamtbetrag_Netto_in_Darstellwährung").Value), 2, "") @@ -525,7 +524,7 @@ Public Class frmMDMDatenverarbetiung AddHandler rpt.ReportFooter1.Format, Sub() rpt.lblSumNetto.Text = sumNetto.ToString("N2") - 'rpt.lblSumMwst.Text = sumMWST.ToString("N2") + rpt.lblSumMwst.Text = "" 'sumMWST.ToString("N2") rpt.lblSumBrutto.Text = sumBrutto.ToString("N2") End Sub @@ -3443,7 +3442,7 @@ Public Class frmMDMDatenverarbetiung Dim fehlendeTransactionen As Integer = 0 - fehlendeTransactionen = CInt((New SQL).getValueTxtBySql("select count(*) FROM [VERAG].[dbo].[tblMSESettlements] where [invoice_date] = '" & DateTimePicker2.Text & "' AND [transaction_id] not in (select [transaction_id] from [VERAG].[dbo].[tblMSETransactions]) ", "AVISO")) + fehlendeTransactionen = CInt((New SQL).getValueTxtBySql("select count(*) FROM [VERAG].[dbo].[tblMSESettlements] where [invoice_date] = '" & DateTimePicker2.Text & "' AND [transaction_id] not in (select [transaction_id] from [VERAG].[dbo].[tblMSETransactions]) ", "FMZOLL")) diff --git a/VERAG_PROG_ALLGEMEIN/Schnittstellen/MSE/cMSEAPI.vb b/VERAG_PROG_ALLGEMEIN/Schnittstellen/MSE/cMSEAPI.vb index c1074263..8acb2ae0 100644 --- a/VERAG_PROG_ALLGEMEIN/Schnittstellen/MSE/cMSEAPI.vb +++ b/VERAG_PROG_ALLGEMEIN/Schnittstellen/MSE/cMSEAPI.vb @@ -159,6 +159,103 @@ Public Class cMSEAPI End Function + Public Function getNewestSettlements(jwt As String, dt As DataTable, ByRef batchNr As Integer, ByRef totalPages As Integer, ByRef currentPage As Integer) As String + Try + Dim returnText As String = "" + Dim failureText As String = "" + + Dim success As Boolean + + rest.DebugMode = test + + Dim bTls As Boolean = True + Dim port As Integer = 443 + Dim bAutoReconnect As Boolean = True + success = rest.Connect(API_STRING, port, bTls, bAutoReconnect) + If (success <> True) Then + Debug.WriteLine("ConnectFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + failureText = rest.LastErrorText + Return False + End If + + If (success <> True) Then + Debug.WriteLine("BAFailReason: " & rest.ConnectFailReason) + Debug.WriteLine(rest.LastErrorText) + failureText = rest.LastErrorText + Return False + End If + + rest.ClearAllQueryParams() + + rest.AddHeader("X-API-Key", jwt) + + rest.IdleTimeoutMs = 1000000 + + Dim responseJson As String = rest.FullRequestNoBody("GET", "/v1/settlements/new") + If (rest.LastMethodSuccess <> True) Then + Debug.WriteLine(rest.LastErrorText) + rest.IdleTimeoutMs = 30000 'defualt + Return rest.LastErrorText + End If + + If (rest.ResponseStatusCode <> IIf(rest.DebugMode = True, 201, 200) And rest.ResponseStatusCode <> 404) Then + Debug.WriteLine(rest.ResponseHeader) + Return rest.LastErrorText + End If + + Debug.WriteLine(responseJson) + + 'Newest Settlements werden nicht benötigt, erst beim Abrufen der RECHNUNG sollen die dazugehörigen Settlements abgerufen werden, allerdings müssen diese initial 1x per API abgerufen werden (mittels getNewSettlements , ansonsten können Sie nicht gefunden werden)! + + 'sollten sie dennoch gespeichert werden, dann fogenden Return-Statement auskommentieren (damit nachfolgender Code ausgeführt werden kann): + + '-------------START--- + + Return "" + + '-------------ENDE--- + + + If test Then + responseJson = "" + End If + + Dim json As New Chilkat.JsonObject + success = json.Load(responseJson) + If (success <> True) Then + Debug.WriteLine(json.LastErrorText) + End If + + Debug.WriteLine(json) + + batchNr = json.StringOf("batch_seq_nr") + totalPages = json.IntOf("total_pages") + currentPage = json.IntOf("page_nr") + + If json.StringOf("message") <> "" AndAlso json.StringOf("message") <> "OK" Then Return json.StringOf("message") + + Dim settlements As New Chilkat.JsonArray + settlements = json.ArrayOf("settlements") + If (json.LastMethodSuccess = False) Then + Debug.WriteLine("settlements member not found.") + End If + + + Dim num As Integer = settlements.Size + If num = -1 Then + Return "FEHLER im settlementsArray" + End If + + If json.StringOf("receiver") = "10738" Then saveSettlements(num, dt, settlements, json.StringOf("receiver")) + + + Catch ex As WebException + VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name) + End Try + + End Function + Public Function getCustomers(jwt As String, dt As DataTable) As String Try Dim returnText As String = "" @@ -324,6 +421,8 @@ Public Class cMSEAPI Try Dim returnText As String = "" Dim failureText As String = "" + Dim missingcounter As Integer = 0 + Dim listOfMissingTransactions As New List(Of String) Dim success As Boolean @@ -387,26 +486,40 @@ Public Class cMSEAPI End If Debug.WriteLine(json) + Dim saveTransaction As Boolean = True + If json.StringOf("message") <> "" AndAlso json.StringOf("message") <> "OK" Then + If Not json.StringOf("message").ToString.Contains("No transaction found for") Then + Return json.StringOf("message") + Else + saveTransaction = False + transactionID.Columns("found").ReadOnly = False + row.Item("found") = False + transactionID.Columns("found").ReadOnly = True - If json.StringOf("message") <> "" AndAlso json.StringOf("message") <> "OK" Then Return json.StringOf("message") - Dim transactions As New Chilkat.JsonArray - transactions = json.ArrayOf("transactions") - If (json.LastMethodSuccess = False) Then - Debug.WriteLine("transactions member not found.") + End If + End If + If saveTransaction Then + Dim transactions As New Chilkat.JsonArray + transactions = json.ArrayOf("transactions") + If (json.LastMethodSuccess = False) Then + Debug.WriteLine("transactions member not found.") + End If - Dim num As Integer = transactions.Size - If num = -1 Then - Return "FEHLER Array Transaktions ist leer" + + Dim num As Integer = transactions.Size + If num = -1 Then + Return "FEHLER Array Transaktions ist leer" + End If + + + 'If json.StringOf("receiver") = "10738" Then saveTransactions(num, dt, transactions, json.StringOf("receiver")) + saveTransactions(num, dt, transactions, json.StringOf("receiver"), True) ' wenn ID explizit aufgerufen keine Prüfung auf receivcer und purchaseDate End If - 'If json.StringOf("receiver") = "10738" Then saveTransactions(num, dt, transactions, json.StringOf("receiver")) - saveTransactions(num, dt, transactions, json.StringOf("receiver"), True) ' wenn ID explizit aufgerufen keine Prüfung auf receivcer und purchaseDate - - Next row diff --git a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj index 16a10d93..5fbbf0e4 100644 --- a/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj +++ b/VERAG_PROG_ALLGEMEIN/VERAG_PROG_ALLGEMEIN.vbproj @@ -24,6 +24,7 @@ bin\Debug\ VERAG_PROG_ALLGEMEIN.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + Off AnyCPU @@ -34,6 +35,7 @@ bin\Release\ VERAG_PROG_ALLGEMEIN.xml 42016,41999,42017,42018,42019,42032,42036,42020,42021,42022 + Off On @@ -70,7 +72,7 @@ false - ProgAllg.pfx + Sebastian.pfx @@ -886,6 +888,7 @@ Designer + Designer @@ -1269,10 +1272,10 @@ 13.0.3 - 7.2.4 + 8.4.1 - 110.2.0 + 111.4.1