From 07e9a0237d584acafc1e09befaead63beb32efb7 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 12 May 2023 10:36:52 +0200 Subject: [PATCH] Update gestione return errori --- DemoVB/Form1.vb | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/DemoVB/Form1.vb b/DemoVB/Form1.vb index 2529d4d..c082d80 100644 --- a/DemoVB/Form1.vb +++ b/DemoVB/Form1.vb @@ -105,31 +105,18 @@ Public Class Form1 End While Dim procResults As New List(Of CalcResultDTO) Dim currRes As New CalcResultDTO - - '' verifico esistenza file svg e lo carico - 'Dim sSvgPath As String = Path.ChangeExtension(sDdfPath, "svg") - '' leggo contenuto - 'Dim sSvgContent As String = GetFileContent(sSvgPath) - - 'bOk = File.Exists(sSvgPath) - 'Dim sSvgContent As String = "" - 'If bOk Then - ' Try - ' sSvgContent = File.ReadAllText(sSvgPath) - ' Catch ex As Exception - ' bOk = False - ' sSvgContent = "" - ' End Try - 'End If - + Dim fContent As String = "" + ' verifico esistenza file svg e lo carico + bOk = GetFileContent(Path.ChangeExtension(sDdfPath, "svg"), fContent) ' invio risposta currRes.Validated = Proc.ExitCode = 0 AndAlso bOk currRes.DoorIdVers = Item.Key ' se NON fosse validato --> messo il messaggio... If (currRes.Validated) Then - currRes.SvgGen = GetFileContent(Path.ChangeExtension(sDdfPath, "svg")) + currRes.SvgGen = fContent Else - currRes.ErrorMsg = GetFileContent(Path.ChangeExtension(sDdfPath, "txt")) + bOk = GetFileContent(Path.ChangeExtension(sDdfPath, "txt"), fContent) + currRes.ErrorMsg = fContent End If procResults.Add(currRes) @@ -145,8 +132,8 @@ Public Class Form1 End Sub - Private Function GetFileContent(filePath As String) As String - Dim fileContent As String = "" + Private Function GetFileContent(ByVal filePath As String, ByRef fileContent As String) As Boolean + Dim bOk As Boolean = File.Exists(filePath) If bOk Then Try @@ -156,7 +143,7 @@ Public Class Form1 fileContent = "" End Try End If - Return fileContent + Return bOk End Function