This commit is contained in:
Jonathan Jenne 2022-05-05 16:35:22 +02:00
parent f540c1dc17
commit 46d3dfbd47
4 changed files with 24 additions and 8 deletions

View File

@ -223,7 +223,7 @@ Namespace Documents
Where(Function(t) t.Name = oTopLevelElement.Name).
FirstOrDefault()
Logger.Debug("Creating fields from [{0}] columns for Table [{1}]", oTable.Columns, oTable.Name)
Logger.Debug("Creating fields from [{0}] columns for Table [{1}]", oTable.Columns.Count, oTable.Name)
For Each oColumn In oTable.Columns
Dim oSubElement = oSubElements.
@ -283,7 +283,7 @@ Namespace Documents
End Function
Public Function GetFieldValueFromColumn(pColumn As Template.Column, pSortKey As Integer) As DocumentRow.FieldValue
Return New DocumentRow.FieldValue With {
Return New DocumentRow.FieldValue(LogConfig) With {
.DataType = pColumn.DataType,
.IsRequired = pColumn.IsRequired,
.IsVirtual = pColumn.Config.IsVirtual,
@ -615,9 +615,10 @@ Namespace Documents
If oArticleNumber IsNot Nothing Then
oNumberItem.SetExternalValue(oArticleNumber)
Logger.Info("EAN [{0}] resolved to ArticleNumber [{1}]", oNumberItem.Original, oArticleNumber)
Else
'oNumberItem.Error = FieldErrorType.ArticleNotFound
oNumberItem.AddFieldError(FieldErrorType.ArticleNotFound, $"EAN in Attribut '{pArticleField}' konnte nicht aufgelöst werden.")
Logger.Warn("EAN [{0}] could not be resolved ArticleNumber", oNumberItem.Original)
End If
End Sub

View File

@ -1,4 +1,5 @@
Imports System.Text.RegularExpressions
Imports DigitalData.Modules.Logging
Imports MultiTool.Common.Constants
Namespace Documents
@ -67,6 +68,7 @@ Namespace Documents
Private _Final As String = ""
Private _External As String = ""
Private _Original As String = ""
Private Logger As Logger
Public Property DataType As ColumnType = ColumnType.String
@ -95,7 +97,8 @@ Namespace Documents
Public Property PreferExternalValue As Boolean = True
Public Property SortKey As Integer = 0
Public Sub New()
Public Sub New(pLogConfig As LogConfig)
Logger = pLogConfig.GetLogger()
End Sub
Public Function GetValue(pValueType As String) As String
@ -137,12 +140,14 @@ Namespace Documents
' Set the external value as the final value, overriding the original / previous external value
' if the external value should be preferred
If PreferExternalValue = True Then
Logger.Debug("Setting Final value to [{0}] because PreferExternalValue is True", pValue)
_Final = pValue
End If
' If there is no Original value (because the field is virtual),
' set the external value as the final value regardless of the PreferExternalValue setting
If Original = String.Empty Then
If _Original = String.Empty Then
Logger.Debug("Setting Final value to [{0}] because Original value is empty", pValue)
_Final = pValue
End If
End Sub

View File

@ -515,6 +515,12 @@ Namespace Winline
Public Function TryGetArticleNumber(pEAN As String, pMandator As Mandator) As String
Try
If pEAN = String.Empty Then
Logger.Warn("Could not get ArticleNumber, EAN is empty.")
Return Nothing
End If
Dim oYear As Integer = Config.GetWinLineYear()
Dim oSQL As String = $"
SELECT
@ -545,6 +551,8 @@ Namespace Winline
Dim oRow As DataRow = oTable.Rows.Item(0)
Dim oArticleNumber As String = ItemEx(oRow, V21_MAINARTICLENUMBER, String.Empty)
Logger.Info("Found ArticleNumber [{0}] in Column [{1}]", oArticleNumber, V21_MAINARTICLENUMBER)
Return oArticleNumber
Catch ex As Exception
@ -929,7 +937,7 @@ Namespace Winline
Dim oExistingCount = Await Database.GetScalarValueAsync(oSql)
If oExistingCount = 0 Then
Logger.Debug("Running number [{0}] does not exist yet. Returning.")
Logger.Debug("Running number [{0}] does not exist yet. Returning.", pRunningNumber)
Return pRunningNumber
Else
Logger.Debug("Running number [{0}] already exists. Checking again.")

View File

@ -13,6 +13,7 @@ Imports DevExpress.XtraEditors.Controls
Imports DevExpress.XtraGrid.Views.Grid
Public Class frmRowEditor
Private ReadOnly LogConfig As LogConfig
Private ReadOnly Logger As Logger
Private ReadOnly FormHelper As FormHelper
@ -44,6 +45,7 @@ Public Class frmRowEditor
Public Sub New(pLogConfig As LogConfig, pColumns As List(Of String), pDocumentRow As DocumentRow, pMandator As Mandator, pWinline As WinlineData, pTable As Template.Table)
InitializeComponent()
LogConfig = pLogConfig
Logger = pLogConfig.GetLogger()
FormHelper = New FormHelper(pLogConfig, Me)
@ -119,7 +121,7 @@ Public Class frmRowEditor
If oField.Value Is Nothing Then
' TODO: Do we need to create a new field value here?
' aka. do we need to configure fieldvalue from column settings
oDict.Add(oColumnName, New FieldValue())
oDict.Add(oColumnName, New FieldValue(LogConfig))
Else
oDict.Add(oColumnName, oField.Value)
End If
@ -161,7 +163,7 @@ Public Class frmRowEditor
' If there are (non-virtual) fields in the template which do not have a value yet,
' this might happen.
If oField.Key Is Nothing Then
oField = New KeyValuePair(Of String, FieldValue)(oRow.Item(COL_KEY), New FieldValue())
oField = New KeyValuePair(Of String, FieldValue)(oRow.Item(COL_KEY), New FieldValue(LogConfig))
End If
Dim oFieldValue As FieldValue = oField.Value