Improve logging

This commit is contained in:
Jonathan Jenne 2022-05-13 13:54:24 +02:00
parent cd1cdfe19a
commit bc8289e1b7
3 changed files with 25 additions and 3 deletions

View File

@ -398,6 +398,10 @@ Namespace Documents
Dim oFunctionName = oColumn.Config.FunctionName Dim oFunctionName = oColumn.Config.FunctionName
Dim oFunctionParams = oColumn.Config.FunctionParams Dim oFunctionParams = oColumn.Config.FunctionParams
If oFunctionName = String.Empty Then
Continue For
End If
Logger.Debug("Running Function: [{0}]", oFunctionName) Logger.Debug("Running Function: [{0}]", oFunctionName)
Logger.Debug("With Parameters: [{0}]", oFunctionParams) Logger.Debug("With Parameters: [{0}]", oFunctionParams)

View File

@ -52,6 +52,7 @@ Namespace Winline
Dim oWS = Config Dim oWS = Config
RaiseEvent WebServiceProgress(Me, "Einstellungen laden") RaiseEvent WebServiceProgress(Me, "Einstellungen laden")
Logger.Debug("Loading setting and creating directories")
' --- Build all teh filenamez and pathz ' --- Build all teh filenamez and pathz
Dim oBaseFileName As String = FileEx.GetDateTimeString() Dim oBaseFileName As String = FileEx.GetDateTimeString()
@ -72,12 +73,14 @@ Namespace Winline
Dim oImportRelativeFilePath = IO.Path.Combine(oRelativePath, oFileName) Dim oImportRelativeFilePath = IO.Path.Combine(oRelativePath, oFileName)
RaiseEvent WebServiceProgress(Me, "Dateien schreiben") RaiseEvent WebServiceProgress(Me, "Dateien schreiben")
Logger.Debug("Writing request file to [{oOutputFilePath}]")
' --- Serialize Data into XML string ' --- Serialize Data into XML string
IO.File.WriteAllBytes(oOutputFilePath, oBytes) IO.File.WriteAllBytes(oOutputFilePath, oBytes)
' --- Copy file to Winline Import Directory ' --- Copy file to Winline Import Directory
Try Try
Logger.Debug("Copying request file to [{oImportAbsoluteFilePath}]")
IO.File.Copy(oOutputFilePath, oImportAbsoluteFilePath, True) IO.File.Copy(oOutputFilePath, oImportAbsoluteFilePath, True)
Catch ex As Exception Catch ex As Exception
Logger.Error(ex) Logger.Error(ex)
@ -87,6 +90,7 @@ Namespace Winline
' --- Prepare URL and HTTP Client ' --- Prepare URL and HTTP Client
Dim oTemplateType = pDocument.TemplateType Dim oTemplateType = pDocument.TemplateType
Dim oTemplateName = pDocument.TemplateName Dim oTemplateName = pDocument.TemplateName
Logger.Debug("Using Template [{0}/{1}]", oTemplateName, oTemplateType)
' ActionCode: Should this be a test or not? ' ActionCode: Should this be a test or not?
' 0 = Test call ' 0 = Test call
@ -95,6 +99,7 @@ Namespace Winline
If pIsTest = True Then If pIsTest = True Then
oActionCode = 0 oActionCode = 0
End If End If
Logger.Debug("Using ActionCode [{0}]", oActionCode)
' Byref: Should data be supplied as file or as string? ' Byref: Should data be supplied as file or as string?
' 0 = As String ' 0 = As String
@ -113,6 +118,8 @@ Namespace Winline
' --- Bring the action! ' --- Bring the action!
Try Try
Dim oResponse As HttpResponseMessage = Await oClient.GetAsync(oURL) Dim oResponse As HttpResponseMessage = Await oClient.GetAsync(oURL)
Logger.Debug("HTTP Response recevied!")
Await HandleImportResponse(oResponse, pTemplate, oBaseFileName) Await HandleImportResponse(oResponse, pTemplate, oBaseFileName)
Return True Return True
@ -133,8 +140,12 @@ Namespace Winline
RaiseEvent WebServiceProgress(Me, "Antwort verarbeiten") RaiseEvent WebServiceProgress(Me, "Antwort verarbeiten")
Logger.Debug("Response ContentType: [{0}]", oContentType)
Select Case oContentType Select Case oContentType
Case "text/xml" Case "text/xml"
Logger.Debug("Got XML Response. Checking.")
WriteResponseFile(oOutputDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}-Response.xml") WriteResponseFile(oOutputDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}-Response.xml")
Dim oBytes As Byte() = Encoding.UTF8.GetBytes(oResponseBody) Dim oBytes As Byte() = Encoding.UTF8.GetBytes(oResponseBody)
@ -146,8 +157,8 @@ Namespace Winline
For Each oDetails As Templates.Entities.MESOWebServiceResultResultDetails In oResponseObject.ResultDetails For Each oDetails As Templates.Entities.MESOWebServiceResultResultDetails In oResponseObject.ResultDetails
If oDetails.Success = True Then If oDetails.Success = True Then
Logger.Info("KeyValue: [{0}]", oDetails.KeyValue) Logger.Debug("KeyValue: [{0}]", oDetails.KeyValue)
Logger.Info("VoucherNumber: [{0}]", oDetails.VoucherNumber) Logger.Debug("VoucherNumber: [{0}]", oDetails.VoucherNumber)
Else Else
Logger.Warn("ErrorCode: [{0}]", oDetails.ErrorCode) Logger.Warn("ErrorCode: [{0}]", oDetails.ErrorCode)
Logger.Warn("ErrorText: [{0}]", oDetails.ErrorText) Logger.Warn("ErrorText: [{0}]", oDetails.ErrorText)
@ -159,17 +170,23 @@ Namespace Winline
If oResponseObject.OverallSuccess = False Then If oResponseObject.OverallSuccess = False Then
Dim oMessage = $"Request to Webservice was unsuccessful:{vbNewLine}{vbNewLine}{String.Join(vbNewLine, oErrorStrings.ToArray)}" Dim oMessage = $"Request to Webservice was unsuccessful:{vbNewLine}{vbNewLine}{String.Join(vbNewLine, oErrorStrings.ToArray)}"
Logger.Warn("Overall Success was [false]")
Throw New WebServiceException(oMessage) Throw New WebServiceException(oMessage)
End If End If
End Using End Using
Case "text/html" Case "text/html"
Logger.Debug("Got TEXT/HTML Response. Throwing.")
WriteResponseFile(oOutputDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}-Response.xml") WriteResponseFile(oOutputDirectory, oResponseBody, $"{pTemplate.Name}-{pBaseFileName}-Response.xml")
Throw New WebServiceException(oResponseBody) Throw New WebServiceException(oResponseBody)
Case Else Case Else
Logger.Debug("Unknown Response ContentType: [{0}]", oContentType)
Throw New WebServiceException(oResponseBody) Throw New WebServiceException(oResponseBody)
End Select End Select
End Function End Function
@ -216,7 +233,7 @@ Namespace Winline
#End Region #End Region
#Region "Export" #Region "Export"
Async Function ExportDocumentFromWinline(pDocument As Entities.ExportDocument, pTemplate As Template, pMandator As Mandator, Optional pIsTest As Boolean = False) As Task(Of Boolean) Async Function ExportDocumentFromWinline(pDocument As ExportDocument, pTemplate As Template, pMandator As Mandator, Optional pIsTest As Boolean = False) As Task(Of Boolean)
Dim oWS = Config Dim oWS = Config
Logger.Info("Exporting document from Winline") Logger.Info("Exporting document from Winline")

View File

@ -39,6 +39,7 @@ Public Class FormHelper
MsgBox(oMessage, MsgBoxStyle.Exclamation, Form.Text) MsgBox(oMessage, MsgBoxStyle.Exclamation, Form.Text)
End Sub End Sub
Public Sub TryOpenDirectory(pPath As String, pDisplayName As String) Public Sub TryOpenDirectory(pPath As String, pDisplayName As String)
If IO.Directory.Exists(pPath) Then If IO.Directory.Exists(pPath) Then
Process.Start(pPath) Process.Start(pPath)