jj Änderungen JSON API
This commit is contained in:
parent
3c6ef71b55
commit
3c02303007
@ -19,6 +19,9 @@
|
||||
<setting name="myConnString" serializeAs="String">
|
||||
<value>Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_RENOLIT;Persist Security Info=True;User ID=sa;Password=dd</value>
|
||||
</setting>
|
||||
<setting name="BNSAPI_HOST" serializeAs="String">
|
||||
<value />
|
||||
</setting>
|
||||
</ResultHandler_Konfig.My.MySettings>
|
||||
</userSettings>
|
||||
<system.data>
|
||||
|
||||
@ -78,6 +78,18 @@ Namespace My
|
||||
Return CType(Me("SQLSERVER_CS"),String)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
<Global.System.Configuration.UserScopedSettingAttribute(), _
|
||||
Global.System.Diagnostics.DebuggerNonUserCodeAttribute(), _
|
||||
Global.System.Configuration.DefaultSettingValueAttribute("")> _
|
||||
Public Property BNSAPI_HOST() As String
|
||||
Get
|
||||
Return CType(Me("BNSAPI_HOST"),String)
|
||||
End Get
|
||||
Set
|
||||
Me("BNSAPI_HOST") = value
|
||||
End Set
|
||||
End Property
|
||||
End Class
|
||||
End Namespace
|
||||
|
||||
|
||||
@ -13,5 +13,8 @@
|
||||
</SerializableConnectionString></DesignTimeValue>
|
||||
<Value Profile="(Default)">Data Source=172.24.12.41\tests;Initial Catalog=DD_ECM_RENOLIT;Persist Security Info=True;User ID=sa;Password=dd</Value>
|
||||
</Setting>
|
||||
<Setting Name="BNSAPI_HOST" Type="System.String" Scope="User">
|
||||
<Value Profile="(Default)" />
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@ -212,13 +212,22 @@ Public Class clsDateiverarbeitung
|
||||
Return link
|
||||
End Function
|
||||
|
||||
Private Shared Function GetDocTypeCategory(docType As String)
|
||||
Select Case docType
|
||||
Case "Abliefernachweis"
|
||||
Return 5
|
||||
Case Else
|
||||
Return 0
|
||||
End Select
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Generiert einen Link für BNS und fügt das Dokument WMFile
|
||||
''' ins BNS ein
|
||||
''' </summary>
|
||||
''' <param name="WMFile">Das WMObject, dass das aktuelle Dokument repräsentiert</param>
|
||||
''' <param name="userId">Die eindeutige Benutzer Kennung für die Authentifizierung in Windream</param>
|
||||
Public Shared Sub BNSjsonDownload(WMFile As WMObject, userId As String)
|
||||
Public Shared Sub BNSjsonDownload(WMFile As WMObject, userId As String, apiAddress As String)
|
||||
Try
|
||||
' Indizes für das aktuelle Dokument auslesen
|
||||
Dim SENDUNGNR = WMFile.GetVariableValue("Sendungnr")
|
||||
@ -235,8 +244,8 @@ Public Class clsDateiverarbeitung
|
||||
doc.Ivalidfrom = now
|
||||
doc.Ivaliduntil = now.AddDays(30)
|
||||
doc.Pfad = link
|
||||
doc.Kategorie = New List(Of BNSDocumentCategory) From {
|
||||
New BNSDocumentCategory With {.Name = DOKART}
|
||||
doc.Kategorien = New List(Of BNSDocumentCategory) From {
|
||||
New BNSDocumentCategory With {.Id = GetDocTypeCategory(DOKART)}
|
||||
}
|
||||
|
||||
Dim json As String = JsonConvert.SerializeObject(doc, Formatting.Indented)
|
||||
@ -249,11 +258,10 @@ Public Class clsDateiverarbeitung
|
||||
Dim geschaeftsObjekt = "Sendung"
|
||||
' Für Tests wird hier die Sendungsnummer verwendet, später hängt der verwendete Index von 'geschaeftsObjekt' ab
|
||||
Dim geschaeftsId = SENDUNGNR
|
||||
Dim host = "1.2.3.4"
|
||||
Dim url As String = $"http://{host}/onwebui/api/Customer/{mandatenId}/{geschaeftsObjekt}/{geschaeftsId}/dokument"
|
||||
Dim url As String = $"http://{apiAddress}/onwebui/api/Customer/{mandatenId}/{geschaeftsObjekt}/{geschaeftsId}/dokument"
|
||||
|
||||
clsLogger.Add($"Generiertes JSON: {json}", False, "BNSjsonDownload")
|
||||
clsLogger.Add($"Creating WebRequest for {url}", False, "BNSjsonDownload")
|
||||
clsLogger.Add($">> Generiertes JSON: {json}", False, "BNSjsonDownload")
|
||||
clsLogger.Add($">> Creating WebRequest for {url}", False, "BNSjsonDownload")
|
||||
|
||||
Dim req As HttpWebRequest = WebRequest.CreateHttp(url)
|
||||
|
||||
@ -267,8 +275,8 @@ Public Class clsDateiverarbeitung
|
||||
reqStream.Write(bytes, 0, bytes.Length)
|
||||
reqStream.Close()
|
||||
|
||||
clsLogger.Add($"Datei wird hochgeladen... docId: {DOKID}, dokart: {DOKART}, userId: {userId}", False, "BNSjsonDownload")
|
||||
clsLogger.Add($"Upload URL: {url}", False, "BNSjsonDownload")
|
||||
clsLogger.Add($">> Datei wird hochgeladen... docId: {DOKID}, dokart: {DOKART}, userId: {userId}", False, "BNSjsonDownload")
|
||||
clsLogger.Add($">> Upload URL: {url}", False, "BNSjsonDownload")
|
||||
|
||||
Using res As HttpWebResponse = req.GetResponse()
|
||||
Dim code As HttpStatusCode = res.StatusCode
|
||||
@ -276,10 +284,10 @@ Public Class clsDateiverarbeitung
|
||||
|
||||
' Status 201 Created bedeutet: Alles okay!
|
||||
If code = HttpStatusCode.Created Then
|
||||
clsLogger.Add($"Datei geschrieben! docId: {DOKID}, dokart: {DOKART}, userId: {userId}", False, "BNSjsonDownload")
|
||||
clsLogger.Add($">> Datei geschrieben! docId: {DOKID}, dokart: {DOKART}, userId: {userId}", False, "BNSjsonDownload")
|
||||
Else
|
||||
Throw New Exception($"Server Error (HTTP {code}: {text})")
|
||||
End If
|
||||
|
||||
Throw New Exception($"Server Error (HTTP {code}: {text})")
|
||||
End Using
|
||||
|
||||
Catch ex As Exception
|
||||
@ -380,11 +388,12 @@ Public Class clsDateiverarbeitung
|
||||
Public Ivaliduntil As DateTime
|
||||
Public Bemerkung As String
|
||||
Public Primaer As Boolean = False
|
||||
Public Kategorie As List(Of BNSDocumentCategory)
|
||||
Public Fremsysid As Integer = 1
|
||||
Public Kategorien As List(Of BNSDocumentCategory)
|
||||
End Class
|
||||
|
||||
Public Class BNSDocumentCategory
|
||||
Public Name As String
|
||||
Public Id As Integer
|
||||
End Class
|
||||
|
||||
End Class
|
||||
|
||||
@ -267,7 +267,7 @@ Public Class clsProfil
|
||||
End If
|
||||
'Next
|
||||
Case "BNS json Download".ToUpper
|
||||
clsDateiverarbeitung.BNSjsonDownload(WMdok, DR_PR_JB.Item("STRING1"))
|
||||
clsDateiverarbeitung.BNSjsonDownload(WMdok, DR_PR_JB.Item("STRING1"), DR_PR_JB.Item("STRING2"))
|
||||
|
||||
|
||||
End Select
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user