154 lines
5.9 KiB
VB.net
154 lines
5.9 KiB
VB.net
Imports System.Net
|
|
Imports System.Web.Http
|
|
Imports System.Web.Http.Description
|
|
Imports Microsoft.Web.Http
|
|
Imports Newtonsoft.Json
|
|
|
|
|
|
Namespace api_CustomsDeclaration.Controllers
|
|
|
|
<ApiExplorerSettings(IgnoreApi:=True)> 'hide controller
|
|
<ApiVersion("001")>
|
|
<System.Web.Http.Route("api/v{version:apiVersion}/CustomsDeclaration")>
|
|
Public Class CustomsDeclaration1Controller
|
|
Inherits System.Web.Http.ApiController
|
|
|
|
Public Function GetValues() As VERAG_PROG_ALLGEMEIN.cVERAG_in_eza
|
|
Dim EZA As New VERAG_PROG_ALLGEMEIN.cVERAG_in_eza
|
|
EZA.POSITIONS.Add(New VERAG_PROG_ALLGEMEIN.cVERAG_in_eza_position)
|
|
EZA.POSITIONS(0).DOCUMENTS.Add(New VERAG_PROG_ALLGEMEIN.cVERAG_in_eza_position_document)
|
|
'EZA.DOCUMENTS.Add(New VERAG_PROG_ALLGEMEIN.cVERAG_in_eza_document)
|
|
EZA.ADDRESS.Add(New VERAG_PROG_ALLGEMEIN.cVERAG_in_eza_Adressen)
|
|
|
|
Return EZA
|
|
End Function
|
|
|
|
'Public Function PostValue(ByVal EZA_FREMD As VERAG_PROG_ALLGEMEIN.cVERAG_in_eza) As String
|
|
' ' VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = False
|
|
' VERAG_PROG_ALLGEMEIN.cAllgemein.TESTSYSTEM = cREST_Options.isTESTSSTEM(Request)
|
|
|
|
' VERAG_PROG_ALLGEMEIN.cAllgemein.ERR_OP_GLOBAL = VERAG_PROG_ALLGEMEIN.ERROR_OP.MAIL
|
|
' Dim SQL As New VERAG_PROG_ALLGEMEIN.SQL
|
|
' Dim ip = Request.Properties("MS_HttpContext").Request.UserHostAddress()
|
|
|
|
' SQL.doSQL("insert into tbltest (test,ipaddress) Values('ATEZ_EZA_START_X101_ " & Now.ToShortDateString & "-" & Now.ToShortTimeString & "','" & ip & "')", "FMZOLL")
|
|
|
|
|
|
' Try
|
|
|
|
' Dim resultJson2 = jsonString.FromClass(EZA_FREMD)
|
|
' SQL.doSQL("insert into tbltest (test) Values('EZA_" & resultJson2.Replace("'", "") & "')", "FMZOLL")
|
|
|
|
' Catch ex As Exception
|
|
' SQL.doSQL("insert into tbltest (test) Values('ERR:EZA_101_" & ex.Message & "')", "FMZOLL")
|
|
|
|
' End Try
|
|
|
|
|
|
' PostValue = "EZA_ERR"
|
|
' Try
|
|
' If EZA_FREMD Is Nothing Then Return EZA_Exceptions.ERR_01_Wrong_Format
|
|
' ' If EZA_FREMD.TransportBorderLicensePlate = "" Then Return EZA_Exceptions.ERR_07_Missing_PlateNr
|
|
' ' If EZA_FREMD.Reference = "" Then Return EZA_Exceptions.ERR_08_Missing_Reference
|
|
|
|
' Dim Reference = If(EZA_FREMD.Reference, "")
|
|
|
|
' Dim EZA_TR = VERAG_PROG_ALLGEMEIN.cVERAG_in_eza_FULL.LOADByReference("ATEZ", Reference, True)
|
|
|
|
' If EZA_TR Is Nothing Then
|
|
' EZA_TR = New VERAG_PROG_ALLGEMEIN.cVERAG_in_eza_FULL(EZA_FREMD)
|
|
' Else
|
|
' EZA_TR.setEZA(EZA_FREMD)
|
|
' End If
|
|
|
|
' EZA_TR.shTr_Partnersystem = "ATEZ"
|
|
' EZA_TR.shTr_Status = 5
|
|
' 'EZA_TR.shTr_Status_KEWILL_Equivalent = 5
|
|
|
|
' EZA_TR.EZA.Company = "VERAG"
|
|
' EZA_TR.EZA.Department = "SUB"
|
|
' 'EZA_TR.Reference = ""
|
|
|
|
|
|
' If EZA_TR.SAVE_ALL Then
|
|
' 'PostValue = "EZA_OK " & Now.ToShortDateString & "-" & Now.ToShortTimeString
|
|
' 'Dim resultJson = jsonString.FromClass(EZA_FREMD)
|
|
' 'SQL.doSQL("insert into tbltest (test) Values('EZA_" & resultJson & "')", "FMZOLL")
|
|
' 'SQL.doSQL("insert into tbltest (test) Values('ATEZ_EZA_TEST: " & EZA_FREMD.TransportBorderLicensePlate & " - " & EZA_FREMD.Reference & "')", "FMZOLL")
|
|
' SQL.doSQL("insert into tbltest (test,ipaddress) Values('ATEZ_EZA_OK - ID: " & EZA_TR.shTr_id & "','" & ip & "')", "FMZOLL")
|
|
|
|
' Return "OK"
|
|
' Else
|
|
' PostValue = EZA_Exceptions.ERR_04_InternalSave
|
|
' End If
|
|
|
|
|
|
' Catch ex As Exception
|
|
' VERAG_PROG_ALLGEMEIN.cErrorHandler.ERR(ex.Message, ex.StackTrace & vbNewLine & "Datei: " & EZA_Exceptions.ERR_03_InternalVerarb, System.Reflection.MethodInfo.GetCurrentMethod.Name)
|
|
' SQL.doSQL("insert into tbltest (test) Values('" & EZA_Exceptions.ERR_03_InternalVerarb & ex.Message & "')", "FMZOLL")
|
|
' Return EZA_Exceptions.ERR_03_InternalVerarb
|
|
' End Try
|
|
|
|
' ' SQL.doSQL("insert into tbltest (test) Values('" & PostValue & "')", "FMZOLL")
|
|
|
|
' Return PostValue
|
|
|
|
|
|
'End Function
|
|
|
|
|
|
End Class
|
|
|
|
|
|
End Namespace
|
|
|
|
|
|
|
|
Public Class jsonString
|
|
|
|
Shared Function FromClass(Of T)(data As T,
|
|
Optional isEmptyToNull As Boolean = False,
|
|
Optional jsonSettings As JsonSerializerSettings = Nothing) As String
|
|
|
|
Dim response As String = String.Empty
|
|
|
|
If Not EqualityComparer(Of T).Default.Equals(data, Nothing) Then
|
|
response = JsonConvert.SerializeObject(data, jsonSettings)
|
|
End If
|
|
|
|
Return If(isEmptyToNull, (If(response = "{}", "null", response)), response)
|
|
|
|
End Function
|
|
|
|
Shared Function ToClass(Of T)(data As String,
|
|
Optional jsonSettings As JsonSerializerSettings = Nothing) As T
|
|
|
|
Dim response = Nothing
|
|
|
|
If Not String.IsNullOrEmpty(data) Then
|
|
response = If(jsonSettings Is Nothing,
|
|
JsonConvert.DeserializeObject(Of T)(data),
|
|
JsonConvert.DeserializeObject(Of T)(data, jsonSettings))
|
|
End If
|
|
|
|
Return response
|
|
|
|
End Function
|
|
|
|
|
|
|
|
End Class
|
|
|
|
Class EZA_Exceptions
|
|
Public Const ERR_01_Wrong_Format As String = "ERR_01"
|
|
Public Const ERR_02_Missing_MRN As String = "ERR_02"
|
|
Public Const ERR_03_InternalVerarb As String = "ERR_03"
|
|
Public Const ERR_04_InternalSave As String = "ERR_04"
|
|
Public Const ERR_05_Missing_Colli As String = "ERR_05"
|
|
Public Const ERR_06_Missing_Gewicht As String = "ERR_06"
|
|
Public Const ERR_07_Missing_PlateNr As String = "ERR_07"
|
|
Public Const ERR_08_Missing_Reference As String = "ERR_08"
|
|
|
|
End Class
|
|
|