Handle NULL in Group Name

This commit is contained in:
Jonathan Jenne 2021-01-21 11:15:29 +01:00
parent 8a220ff21f
commit 2c87374775

View File

@ -12,6 +12,9 @@ Public Class Winline
Public ReadOnly Property ARTICLE_ALREADY_EXISTS = "ARTICLE_ALREADY_EXISTS"
Public ReadOnly Property UNKNOWN_ERROR = "UNKNOWN_ERROR"
Private Const ACTIONCODE_CHECK = 0
Private Const ACTIONCODE_IMPORT = 1
Public Sub New(LogConfig As LogConfig, EximDatabase As Database, WinlineDatabase As Database, Config As Config)
_Logger = LogConfig.GetLogger()
_EXIM = EximDatabase
@ -70,6 +73,14 @@ Public Class Winline
End Try
End Function
Private Function NotNull(Of T)(ByVal value As T, ByVal defaultValue As T) As T
If IsNothing(value) OrElse String.IsNullOrEmpty(value.ToString) OrElse IsDBNull(value) Then
Return defaultValue
Else
Return value
End If
End Function
Public Function GetGroupsByVendor(VendorCode As String) As List(Of ProductGroup)
Try
Dim oDatatable = _EXIM.GetDatatable($"SELECT * FROM TBDD_ARTICLE_GENERATOR_GROUPS WHERE CODE = '{VendorCode}'")
@ -77,10 +88,10 @@ Public Class Winline
For Each oRow As DataRow In oDatatable.Rows
Dim oGroup As New ProductGroup() With {
.Guid = oRow.Item("GUID"),
.Name = oRow.Item("NAME"),
.GroupId = oRow.Item("GROUP"),
.Code = oRow.Item("CODE")
.Guid = NotNull(oRow.Item("GUID"), 0),
.Name = NotNull(oRow.Item("NAME"), "(Kein Name)"),
.GroupId = NotNull(oRow.Item("GROUP"), 0),
.Code = NotNull(oRow.Item("CODE"), "(Kein Code)")
}
oGroups.Add(oGroup)
@ -174,6 +185,9 @@ Public Class Winline
Dim oSuccess As XmlNode = oDocument.DocumentElement.SelectSingleNode("OverallSuccess")
If oSuccess.InnerText.ToUpper = "TRUE" Then
For Each oNode As XmlNode In oDocument.DocumentElement.SelectNodes("Success")
Next
_Logger.Info("Request was SUCCESSFUL!")
Return True
@ -214,6 +228,7 @@ Public Class Winline
Dim oUseShape As String
Dim oDefaultShape As String
Dim oMultipleShapes As String
Dim oActionCode As Integer = ACTIONCODE_IMPORT
If IsSerialnumberArticle = True Then
oArticleType = 0