mseAPI, KundeBearbeiten (DatevExport).
This commit is contained in:
@@ -117,4 +117,7 @@
|
|||||||
<resheader name="writer">
|
<resheader name="writer">
|
||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
|
<metadata name="ContextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
||||||
@@ -1498,8 +1498,8 @@ Public Class usrcntlKundeBearbeitenFull
|
|||||||
|
|
||||||
Private Sub btnDatevExport_Click(sender As Object, e As EventArgs) Handles btnDatevExport.Click
|
Private Sub btnDatevExport_Click(sender As Object, e As EventArgs) Handles btnDatevExport.Click
|
||||||
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("DATEV_EXPORT", "SDL") And VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "AMBAR" Then
|
If VERAG_PROG_ALLGEMEIN.cBerechtignunen.CHECK_BERECHTIGUNG_bool("DATEV_EXPORT", "SDL") And VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA = "AMBAR" Then
|
||||||
If VERAG_PROG_ALLGEMEIN.cDatev_Interface.genDatensatzCSV_ALL(VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA, False, True, False, ,, False) Then
|
If VERAG_PROG_ALLGEMEIN.cDatev_Interface.genDatensatzCSV_ALL(VERAG_PROG_ALLGEMEIN.cAllgemein.FIRMA, False, True, False, ,, False, "ftp") Then
|
||||||
MsgBox("Stammdaten wurden erfolgreich exportiert!")
|
MsgBox("Stammdaten wurden erfolgreich exportiert unf auf FTP geladen!")
|
||||||
Else
|
Else
|
||||||
MsgBox("Es wurden keine Stammdaten exportiert!")
|
MsgBox("Es wurden keine Stammdaten exportiert!")
|
||||||
End If
|
End If
|
||||||
|
|||||||
@@ -25,37 +25,23 @@ Public Class cMSEAPI
|
|||||||
Public Function createJWT(ByRef failureText As String) As String
|
Public Function createJWT(ByRef failureText As String) As String
|
||||||
Try
|
Try
|
||||||
|
|
||||||
If apiSettingsloaded = False Then Return False
|
|
||||||
|
|
||||||
Dim jwt As New Chilkat.Jwt
|
Dim jwt As New Chilkat.Jwt
|
||||||
|
|
||||||
' Build the JOSE header
|
|
||||||
Dim jose As New Chilkat.JsonObject
|
Dim jose As New Chilkat.JsonObject
|
||||||
' Use HS256. Pass the string "HS384" or "HS512" to use a different algorithm.
|
|
||||||
Dim success As Boolean = jose.AppendString("alg", "HS256")
|
Dim success As Boolean = jose.AppendString("alg", "HS256")
|
||||||
success = jose.AppendString("typ", "JWT")
|
success = jose.AppendString("typ", "JWT")
|
||||||
|
|
||||||
' Now build the JWT claims (also known as the payload)
|
' Now build the JWT claims (also known as the payload)
|
||||||
Dim claims As New Chilkat.JsonObject
|
Dim claims As New Chilkat.JsonObject
|
||||||
success = claims.AppendString("iss", API.Rows(0).Item("api_user"))
|
success = claims.AppendString("iss", API.Rows(0).Item("api_user"))
|
||||||
'success = claims.AppendString("sub", "")
|
|
||||||
'success = claims.AppendString("aud", "http://example.com")
|
|
||||||
|
|
||||||
' Set the timestamp of when the JWT was created to now.
|
|
||||||
Dim curDateTime As Integer = jwt.GenNumericDate(0)
|
Dim curDateTime As Integer = jwt.GenNumericDate(0)
|
||||||
'success = claims.AddIntAt(-1, "iat", curDateTime)
|
|
||||||
|
|
||||||
' Set the "not process before" timestamp to now.
|
|
||||||
'success = claims.AddIntAt(-1, "nbf", curDateTime)
|
|
||||||
|
|
||||||
' Set the timestamp defining an expiration time (end time) for the token
|
' Set the timestamp defining an expiration time (end time) for the token
|
||||||
' to be now + 1 hour (3600 seconds)
|
' to be now + 1 hour (3600 seconds)
|
||||||
success = claims.AddIntAt(-1, "exp", curDateTime + 3600)
|
success = claims.AddIntAt(-1, "exp", curDateTime + 3600)
|
||||||
|
|
||||||
' Produce the smallest possible JWT:
|
|
||||||
jwt.AutoCompact = True
|
jwt.AutoCompact = True
|
||||||
|
|
||||||
Dim strJwt As String = jwt.CreateJwt(jose.Emit(), claims.Emit(), API.Rows(0).Item("api_passwort"))
|
Dim strJwt As String = jwt.CreateJwt(jose.Emit(), claims.Emit(), API.Rows(0).Item("api_password"))
|
||||||
|
|
||||||
Debug.WriteLine(strJwt)
|
Debug.WriteLine(strJwt)
|
||||||
Return strJwt
|
Return strJwt
|
||||||
@@ -66,30 +52,48 @@ Public Class cMSEAPI
|
|||||||
|
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Function getTransactions(jwt As String) As String
|
Public Function getNewestTransactions(jwt As String, dt As DataTable) As String
|
||||||
Try
|
Try
|
||||||
Dim returnText As String = ""
|
Dim returnText As String = ""
|
||||||
Dim failureText As String = ""
|
Dim failureText As String = ""
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Dim success As Boolean
|
Dim success As Boolean
|
||||||
|
|
||||||
|
rest.VerboseLogging = True
|
||||||
|
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.ClearAllQueryParams()
|
||||||
|
|
||||||
rest.AddHeader("X_API_KEY", jwt)
|
rest.AddHeader("X-API-Key", jwt)
|
||||||
|
|
||||||
rest.IdleTimeoutMs = 5000
|
rest.IdleTimeoutMs = 500000
|
||||||
|
|
||||||
Dim responseJson As String = rest.FullRequestNoBody("GET", "/v1/transactions/new")
|
Dim responseJson As String = rest.FullRequestNoBody("GET", "/v1/transactions/new")
|
||||||
If (rest.LastMethodSuccess <> True) Then
|
If (rest.LastMethodSuccess <> True) Then
|
||||||
Debug.WriteLine(rest.LastErrorText)
|
Debug.WriteLine(rest.LastErrorText)
|
||||||
rest.IdleTimeoutMs = 30000 'defualt
|
rest.IdleTimeoutMs = 30000 'defualt
|
||||||
Return "Fehler"
|
Return "rest.LastErrorText"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
If (rest.ResponseStatusCode <> 200) Then
|
If (rest.ResponseStatusCode <> 200) Then
|
||||||
Debug.WriteLine(rest.ResponseHeader)
|
Debug.WriteLine(rest.ResponseHeader)
|
||||||
Return "Fehler"
|
Return "rest.LastErrorText"
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Debug.WriteLine(responseJson)
|
Debug.WriteLine(responseJson)
|
||||||
@@ -104,6 +108,83 @@ Public Class cMSEAPI
|
|||||||
Debug.WriteLine(json)
|
Debug.WriteLine(json)
|
||||||
|
|
||||||
|
|
||||||
|
Dim jsonArray As New Chilkat.JsonArray
|
||||||
|
success = jsonArray.Load(responseJson)
|
||||||
|
If (success <> True) Then
|
||||||
|
Return jsonArray.LastErrorText
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Dim num As Integer = jsonArray.Size
|
||||||
|
If num = -1 Then
|
||||||
|
Return "FEHLER"
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
Dim j As Integer = 0
|
||||||
|
|
||||||
|
If dt IsNot Nothing And Not dt.Columns.Contains("transaction_id") Then
|
||||||
|
|
||||||
|
dt.Columns.Add("transaction_id", GetType(String))
|
||||||
|
dt.Columns.Add("partner_haulier_id", GetType(Integer))
|
||||||
|
dt.Columns.Add("supplier_name", GetType(String))
|
||||||
|
dt.Columns.Add("transaction_country", GetType(String))
|
||||||
|
dt.Columns.Add("transaction_domain", GetType(String))
|
||||||
|
|
||||||
|
dt.Columns.Add("purchase_datetime", GetType(DateTime))
|
||||||
|
dt.Columns.Add("entry_point_name", GetType(String))
|
||||||
|
dt.Columns.Add("entry_datetime", GetType(DateTime))
|
||||||
|
dt.Columns.Add("exit_point_name", GetType(String))
|
||||||
|
dt.Columns.Add("exit_datetime", GetType(DateTime))
|
||||||
|
|
||||||
|
dt.Columns.Add("device_product_type", GetType(String))
|
||||||
|
dt.Columns.Add("device_product_number", GetType(String))
|
||||||
|
dt.Columns.Add("transaction_product_id", GetType(Integer))
|
||||||
|
dt.Columns.Add("transaction_product_name", GetType(String))
|
||||||
|
dt.Columns.Add("license_plate_number", GetType(String))
|
||||||
|
|
||||||
|
dt.Columns.Add("vehicle_country", GetType(Integer))
|
||||||
|
dt.Columns.Add("original_currency", GetType(String))
|
||||||
|
dt.Columns.Add("original_net_amount", GetType(String))
|
||||||
|
dt.Columns.Add("original_gross_amount", GetType(String))
|
||||||
|
dt.Columns.Add("original_vat_percentage", GetType(Boolean))
|
||||||
|
|
||||||
|
dt.Columns.Add("transaction_net_amount", GetType(Integer))
|
||||||
|
dt.Columns.Add("transaction_gross_amount", GetType(String))
|
||||||
|
dt.Columns.Add("exempt_amount", GetType(String))
|
||||||
|
dt.Columns.Add("msts_fee_amount", GetType(String))
|
||||||
|
dt.Columns.Add("msts_vat_amount", GetType(Boolean))
|
||||||
|
|
||||||
|
dt.Columns.Add("msts_vat_percentage", GetType(Integer))
|
||||||
|
dt.Columns.Add("total_gross_amount", GetType(String))
|
||||||
|
dt.Columns.Add("transaction_status", GetType(String))
|
||||||
|
dt.Columns.Add("original_transaction_id", GetType(String))
|
||||||
|
dt.Columns.Add("credit_comment", GetType(Boolean))
|
||||||
|
dt.Columns.Add("loading_date", GetType(Date))
|
||||||
|
dt.Columns.Add("batch_seq_nr", GetType(Integer))
|
||||||
|
|
||||||
|
|
||||||
|
While j < num
|
||||||
|
|
||||||
|
Dim transaction As Chilkat.JsonObject = jsonArray.ObjectAt(j)
|
||||||
|
|
||||||
|
Dim R As DataRow = dt.NewRow
|
||||||
|
'R("id") = groups.IntOf("id")
|
||||||
|
'R("name") = groups.StringOf("name")
|
||||||
|
'R("groupType") = groups.StringOf("groupType")
|
||||||
|
'R("info") = groups.StringOf("info")
|
||||||
|
|
||||||
|
dt.Rows.Add(R)
|
||||||
|
j = j + 1
|
||||||
|
End While
|
||||||
|
|
||||||
|
|
||||||
|
dt = dt.DefaultView.ToTable()
|
||||||
|
|
||||||
|
End If
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Catch ex As WebException
|
Catch ex As WebException
|
||||||
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
||||||
|
|||||||
Reference in New Issue
Block a user