MS HTTPS, Log,

This commit is contained in:
Digital Data - Marlon Schreiber
2018-12-12 11:42:55 +01:00
parent 24f052f5b5
commit fd30d75e9f
9 changed files with 382 additions and 283 deletions

View File

@@ -33,7 +33,7 @@ Public Class clsDateiverarbeitung
MyLoggerConf = MyLogger
Logger = MyLogger.GetLogger()
_windream = New clsWindream_allgemein(MyLogger)
_database = New clsDatabase(MyLogger, clsCURRENT.SQLSERVER_CS)
_database = New clsDatabase(MyLogger)
End Sub
Public Function InitProfilData()
Try
@@ -319,6 +319,7 @@ Public Class clsDateiverarbeitung
''' <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 Function BNSjsonDownload(WMFile As WMObject, userId As String, apiAddress As String)
Dim url As String
Try
Logger.Info("handling BNSjsonDownload.....")
' Indizes für das aktuelle Dokument auslesen
@@ -352,42 +353,62 @@ 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 url As String = $"http://{apiAddress}/onwebui/api/Customer/{mandatenId}/{geschaeftsObjekt}/{geschaeftsId}/dokument"
url = $"https://{apiAddress}/onwebui/api/Customer/{mandatenId}/{geschaeftsObjekt}/{geschaeftsId}/dokument"
' Logger.Debug($">> Generiertes JSON: {json}")
Logger.Debug($">> Creating WebRequest for {url}")
Dim req As HttpWebRequest
Try
req = WebRequest.Create(url)
Catch ex As Exception
Logger.Warn($"Unhandled Exception in BNSjsonDownload - CreatingWebRequest ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Error(ex)
Return False
End Try
Dim req As HttpWebRequest = WebRequest.CreateHttp(url)
req.Method = "POST"
req.ContentType = "application/json"
req.ContentLength = bytes.Length
req.Timeout = 3000
req.ServicePoint.Expect100Continue = False
Dim reqStream As Stream
Try
reqStream = req.GetRequestStream()
Catch ex As Exception
Logger.Warn($"Unhandled Exception in BNSjsonDownload - GetRequestStream ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Error(ex)
Return False
End Try
Dim reqStream As Stream = req.GetRequestStream()
reqStream.Write(bytes, 0, bytes.Length)
reqStream.Close()
'Logger.Debug($">> Datei wird hochgeladen... docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
'Logger.Debug($">> Upload URL: {url}")
Try
Using res As HttpWebResponse = req.GetResponse()
Dim code As HttpStatusCode = res.StatusCode
Dim text As String = res.StatusDescription
Using res As HttpWebResponse = req.GetResponse()
Dim code As HttpStatusCode = res.StatusCode
Dim text As String = res.StatusDescription
' Status 201 Created bedeutet: Alles okay!
If code = HttpStatusCode.Created Then
Logger.Info($"File has been uploaded: docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
Else
Logger.Warn($"Server Error (HTTP {code}: {text})")
End If
End Using
Catch ex As Exception
Logger.Warn($"Unhandled Exception in BNSjsonDownload - GetResponse ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Error(ex)
Return False
End Try
' Status 201 Created bedeutet: Alles okay!
If code = HttpStatusCode.Created Then
Logger.Info($"File has been uploaded: docId: {DOKID}, dokart: {DOKART}, userId: {userId}")
Else
Logger.Warn($"Server Error (HTTP {code}: {text})")
End If
End Using
Return True
Catch ex As Exception
Logger.Warn($"Unhandled Exception in BNSjsonDownload - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Warn($"Unhandled Exception in BNSjsonDownload - Url ({url}) - Profile ({clsCURRENT._Profilname}) {ex.Message}")
Logger.Error(ex)
Return True
Return False
End Try
End Function
Public Function RUN_ORACLE_COMMAND(WMFile As WMObject, OracleCS As String, OracleCommandRAW As String)