Remove try-catch from Button1/2_Click event handlers
Refactored Button1_Click and Button2_Click to eliminate local try-catch blocks, allowing exceptions to propagate. Cleaned up redundant code and improved clarity by moving variable declarations outside of the previous try blocks. Core logic remains unchanged.
This commit is contained in:
@@ -7,7 +7,6 @@ Imports GdPicture14
|
|||||||
Imports Newtonsoft.Json.Linq
|
Imports Newtonsoft.Json.Linq
|
||||||
Imports EnvelopeGenerator.Infrastructure
|
Imports EnvelopeGenerator.Infrastructure
|
||||||
Imports Microsoft.EntityFrameworkCore
|
Imports Microsoft.EntityFrameworkCore
|
||||||
Imports System.Text
|
|
||||||
Imports DigitalData.Core.Abstractions
|
Imports DigitalData.Core.Abstractions
|
||||||
|
|
||||||
Public Class frmFinalizePDF
|
Public Class frmFinalizePDF
|
||||||
@@ -93,56 +92,36 @@ Public Class frmFinalizePDF
|
|||||||
End Function
|
End Function
|
||||||
|
|
||||||
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
|
||||||
Try
|
Dim oTable = LoadAnnotationDataForEnvelope()
|
||||||
|
Dim oJsonList = oTable.Rows.
|
||||||
|
Cast(Of DataRow).
|
||||||
|
Select(Function(r As DataRow) r.Item("VALUE").ToString()).
|
||||||
|
ToList()
|
||||||
|
|
||||||
Dim oTable = LoadAnnotationDataForEnvelope()
|
Dim envelopeId As Integer = CInt(txtEnvelope.Text)
|
||||||
Dim oJsonList = oTable.Rows.
|
Dim oBuffer As Byte() = ReadEnvelope(envelopeId)
|
||||||
Cast(Of DataRow).
|
Dim oNewBuffer = PDFBurner.BurnAnnotsToPDF(oBuffer, oJsonList, envelopeId)
|
||||||
Select(Function(r As DataRow) r.Item("VALUE").ToString()).
|
Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
|
||||||
ToList()
|
Dim oNewPath = Path.Combine(desktopPath, $"E{txtEnvelope.Text}R{txtReceiver.Text}.burned.pdf")
|
||||||
|
|
||||||
Dim envelopeId As Integer = CInt(txtEnvelope.Text)
|
File.WriteAllBytes(oNewPath, oNewBuffer)
|
||||||
Dim oBuffer As Byte() = ReadEnvelope(envelopeId)
|
|
||||||
Dim oNewBuffer = PDFBurner.BurnAnnotsToPDF(oBuffer, oJsonList, envelopeId)
|
|
||||||
Dim desktopPath As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
|
|
||||||
Dim oNewPath = Path.Combine(desktopPath, $"E{txtEnvelope.Text}R{txtReceiver.Text}.burned.pdf")
|
|
||||||
|
|
||||||
File.WriteAllBytes(oNewPath, oNewBuffer)
|
|
||||||
|
|
||||||
Process.Start(oNewPath)
|
|
||||||
Catch ex As Exception
|
|
||||||
Dim exMsg As StringBuilder = New StringBuilder(ex.Message).AppendLine()
|
|
||||||
|
|
||||||
Dim innerEx = ex.InnerException
|
|
||||||
While (innerEx IsNot Nothing)
|
|
||||||
exMsg.AppendLine(innerEx.Message)
|
|
||||||
innerEx = innerEx.InnerException
|
|
||||||
End While
|
|
||||||
|
|
||||||
MsgBox(exMsg.ToString(), MsgBoxStyle.Critical)
|
|
||||||
End Try
|
|
||||||
|
|
||||||
|
Process.Start(oNewPath)
|
||||||
End Sub
|
End Sub
|
||||||
|
|
||||||
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
|
||||||
Try
|
Dim oTable = LoadAnnotationDataForEnvelope()
|
||||||
Dim oTable = LoadAnnotationDataForEnvelope()
|
Dim oJsonList = oTable.Rows.
|
||||||
Dim oJsonList = oTable.Rows.
|
Cast(Of DataRow).
|
||||||
Cast(Of DataRow).
|
Select(Function(r As DataRow) r.Item("VALUE").ToString()).
|
||||||
Select(Function(r As DataRow) r.Item("VALUE").ToString()).
|
Select(Function(s As String) JObject.Parse(s)).
|
||||||
Select(Function(s As String) JObject.Parse(s)).
|
ToList()
|
||||||
ToList()
|
|
||||||
|
|
||||||
Dim oJObject1 = oJsonList.First()
|
Dim oJObject1 = oJsonList.First()
|
||||||
Dim oJObject2 = oJsonList.ElementAt(1)
|
Dim oJObject2 = oJsonList.ElementAt(1)
|
||||||
|
|
||||||
oJObject1.Merge(oJObject2)
|
oJObject1.Merge(oJObject2)
|
||||||
|
|
||||||
txtResult.Text = oJObject1.ToString()
|
txtResult.Text = oJObject1.ToString()
|
||||||
|
|
||||||
|
|
||||||
Catch ex As Exception
|
|
||||||
MsgBox(ex.Message, MsgBoxStyle.Critical)
|
|
||||||
End Try
|
|
||||||
End Sub
|
End Sub
|
||||||
End Class
|
End Class
|
||||||
Reference in New Issue
Block a user