Improve User Feedback for errors, fix TestArticleExists
This commit is contained in:
parent
248162732f
commit
def3cdac1e
@ -179,18 +179,33 @@ Public Class Winline
|
|||||||
_Logger.Info("WebService Response: {0}", oXmlResponse)
|
_Logger.Info("WebService Response: {0}", oXmlResponse)
|
||||||
|
|
||||||
Dim oDocument As New XmlDocument
|
Dim oDocument As New XmlDocument
|
||||||
oDocument.LoadXml(oXmlResponse)
|
|
||||||
oDocument.Save(Console.Out)
|
Try
|
||||||
|
oDocument.LoadXml(oXmlResponse)
|
||||||
|
oDocument.Save(Console.Out)
|
||||||
|
Catch ex As Exception
|
||||||
|
_Logger.Error(ex)
|
||||||
|
Return False
|
||||||
|
End Try
|
||||||
|
|
||||||
Dim oSuccess As XmlNode = oDocument.DocumentElement.SelectSingleNode("OverallSuccess")
|
Dim oSuccess As XmlNode = oDocument.DocumentElement.SelectSingleNode("OverallSuccess")
|
||||||
|
Dim oInnerSuccess = True
|
||||||
|
|
||||||
If oSuccess.InnerText.ToUpper = "TRUE" Then
|
If oSuccess.InnerText.ToUpper = "TRUE" Then
|
||||||
For Each oNode As XmlNode In oDocument.DocumentElement.SelectNodes("Success")
|
Dim oSuccessNodes = oDocument.DocumentElement.SelectNodes("//Success")
|
||||||
|
|
||||||
|
For Each oNode As XmlNode In oSuccessNodes
|
||||||
|
If oNode.InnerText.ToUpper <> "TRUE" Then
|
||||||
|
oInnerSuccess = False
|
||||||
|
End If
|
||||||
Next
|
Next
|
||||||
_Logger.Info("Request was SUCCESSFUL!")
|
_Logger.Info("Request was SUCCESSFUL!")
|
||||||
|
|
||||||
Return True
|
If oInnerSuccess = False Then
|
||||||
|
Return False
|
||||||
|
Else
|
||||||
|
Return True
|
||||||
|
End If
|
||||||
Else
|
Else
|
||||||
_Logger.Info("Request FAILED!")
|
_Logger.Info("Request FAILED!")
|
||||||
Return False
|
Return False
|
||||||
@ -203,7 +218,7 @@ Public Class Winline
|
|||||||
|
|
||||||
Public Function TestArticleExists(ArticleNumber As String) As Boolean
|
Public Function TestArticleExists(ArticleNumber As String) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim oResult = _Winline.GetScalarValue($"SELECT c000 FROM v021 WHERE c002 = '{ArticleNumber}'")
|
Dim oResult = _Winline.GetScalarValue($"SELECT c002 FROM v021 WHERE c002 = '{ArticleNumber}'")
|
||||||
|
|
||||||
If IsNothing(oResult) Or IsDBNull(oResult) Then
|
If IsNothing(oResult) Or IsDBNull(oResult) Then
|
||||||
Return False
|
Return False
|
||||||
@ -275,8 +290,7 @@ Public Class Winline
|
|||||||
oXmlData &= $"</MESOWebService>"
|
oXmlData &= $"</MESOWebService>"
|
||||||
|
|
||||||
Try
|
Try
|
||||||
My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData)
|
Return My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData)
|
||||||
Return True
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
Return False
|
Return False
|
||||||
@ -301,25 +315,28 @@ Public Class Winline
|
|||||||
oXmlData &= $"</MESOWebService>"
|
oXmlData &= $"</MESOWebService>"
|
||||||
|
|
||||||
Try
|
Try
|
||||||
My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData)
|
Return My.Application.Winline.SendWebserviceRequest(oTemplateType, oTemplateName, oXmlData)
|
||||||
Return True
|
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
Return False
|
Return False
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
Public Sub RunWinlineMacro(MacroName As String, ParamArray Parameters As Object())
|
Public Function RunWinlineMacro(MacroName As String, ParamArray Parameters As Object()) As Boolean
|
||||||
Try
|
Try
|
||||||
Dim oCWLObject
|
Dim oCWLObject
|
||||||
Dim oParamArray As Object = New Runtime.InteropServices.VariantWrapper(Parameters)
|
Dim oParamArray As Object = New Runtime.InteropServices.VariantWrapper(Parameters)
|
||||||
|
|
||||||
oCWLObject = CreateObject("cwlstart.application")
|
oCWLObject = CreateObject("cwlstart.application")
|
||||||
oCWLObject.MacroCommands.MRunMacro(MacroName, oParamArray)
|
oCWLObject.MacroCommands.MRunMacro(MacroName, oParamArray)
|
||||||
|
|
||||||
|
Return True
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
_Logger.Error(ex)
|
_Logger.Error(ex)
|
||||||
MsgBox($"Das WinLine-Makro [{MacroName}] konnte nicht gestartet werden. Mehr Informationen im Log.", MsgBoxStyle.Critical, "WinLine")
|
_Logger.Warn($"Das WinLine-Makro [{MacroName}] konnte nicht gestartet werden.")
|
||||||
|
|
||||||
|
Return False
|
||||||
End Try
|
End Try
|
||||||
End Sub
|
End Function
|
||||||
End Class
|
End Class
|
||||||
|
|
||||||
|
|||||||
@ -33,8 +33,6 @@
|
|||||||
Dim oPriceResult = My.Application.Winline.CreatePriceInfo(ArticleNumber, RunningNumber, Vendor.WinlineNumber)
|
Dim oPriceResult = My.Application.Winline.CreatePriceInfo(ArticleNumber, RunningNumber, Vendor.WinlineNumber)
|
||||||
|
|
||||||
If oArticleResult And oPriceResult Then
|
If oArticleResult And oPriceResult Then
|
||||||
MsgBox("Artikel erfolgreich angelegt!", MsgBoxStyle.Information, Text)
|
|
||||||
|
|
||||||
txtFinalArticleNumber.Text = $"{ArticleNumber}{RunningNumber}"
|
txtFinalArticleNumber.Text = $"{ArticleNumber}{RunningNumber}"
|
||||||
|
|
||||||
Return $"{ArticleNumber}{RunningNumber}"
|
Return $"{ArticleNumber}{RunningNumber}"
|
||||||
@ -54,19 +52,29 @@
|
|||||||
MsgBoxStyle.Question Or vbYesNo, Text)
|
MsgBoxStyle.Question Or vbYesNo, Text)
|
||||||
|
|
||||||
If oResult = MsgBoxResult.Yes Then
|
If oResult = MsgBoxResult.Yes Then
|
||||||
Dim oArticle = StartArticleCreation(True)
|
Dim oArticleNumber = StartArticleCreation(True)
|
||||||
If oArticle IsNot Nothing Then
|
HandleArticleCreation(oArticleNumber)
|
||||||
My.Computer.Clipboard.SetText(oArticle)
|
|
||||||
My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, oArticle)
|
|
||||||
End If
|
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
||||||
Dim oArticle = StartArticleCreation(False)
|
Dim oArticleNumber = StartArticleCreation(False)
|
||||||
If oArticle IsNot Nothing Then
|
HandleArticleCreation(oArticleNumber)
|
||||||
My.Computer.Clipboard.SetText(oArticle)
|
End Sub
|
||||||
My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, oArticle)
|
|
||||||
|
Private Sub HandleArticleCreation(ArticleNumber As String)
|
||||||
|
If ArticleNumber IsNot Nothing Then
|
||||||
|
If My.Application.Winline.TestArticleExists(ArticleNumber) Then
|
||||||
|
My.Computer.Clipboard.SetText(ArticleNumber)
|
||||||
|
If My.Application.Winline.RunWinlineMacro(My.Application.ConfigManager.Config.CompletionMacro, ArticleNumber) = False Then
|
||||||
|
MsgBox($"Der Artikelstamm konnte nicht geöffnet werden. Die Artikelnummer {ArticleNumber} wurde in die Zwischenablage kopiert.", MsgBoxStyle.Information, Text)
|
||||||
|
End If
|
||||||
|
Application.Exit()
|
||||||
|
|
||||||
|
Else
|
||||||
|
MsgBox($"Der Artikel '{ArticleNumber}' wurde nicht angelegt!", MsgBoxStyle.Critical, Text)
|
||||||
|
|
||||||
|
End If
|
||||||
End If
|
End If
|
||||||
End Sub
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
Loading…
x
Reference in New Issue
Block a user