From 2c873747757c11b9ff8a444cb995140872747ad0 Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Thu, 21 Jan 2021 11:15:29 +0100 Subject: [PATCH] Handle NULL in Group Name --- WinLineArtikelnummerGenerator/Winline.vb | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/WinLineArtikelnummerGenerator/Winline.vb b/WinLineArtikelnummerGenerator/Winline.vb index 8fe2f71..193e777 100644 --- a/WinLineArtikelnummerGenerator/Winline.vb +++ b/WinLineArtikelnummerGenerator/Winline.vb @@ -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