Entfernen unnötige try-catch-Anweisungen.
This commit is contained in:
parent
419f421d52
commit
dbb745338c
@ -39,53 +39,31 @@ Public Class ReceiverModel
|
||||
}
|
||||
End Function
|
||||
|
||||
Private Function ToReceiver(pTable As DataTable) As Receiver
|
||||
Return pTable?.Rows.Cast(Of DataRow).
|
||||
Select(AddressOf ToReceiver).
|
||||
Single()
|
||||
End Function
|
||||
|
||||
Public Function TestReceiverExists(pReceiver As Receiver) As Boolean
|
||||
Try
|
||||
Dim oGuid = Database.GetScalarValue($"SELECT COALESCE(GUID, 0) FROM TBSIG_RECEIVER WHERE EMAIL_ADDRESS = '{pReceiver.EmailAddress}'")
|
||||
pReceiver.Id = oGuid
|
||||
Return oGuid > 0
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function Insert(pReceiver As Receiver, pTransaction As SqlTransaction) As Boolean
|
||||
Try
|
||||
Dim oSignature As String = pReceiver.GetSignature()
|
||||
Dim oCheck = $"SELECT COUNT(GUID) FROM [dbo].[TBSIG_RECEIVER] WHERE SIGNATURE = '{oSignature}'"
|
||||
Dim oExists = Database.GetScalarValue(oCheck)
|
||||
Dim oSignature As String = pReceiver.GetSignature()
|
||||
Dim oCheck = $"SELECT COUNT(GUID) FROM [dbo].[TBSIG_RECEIVER] WHERE SIGNATURE = '{oSignature}'"
|
||||
Dim oExists = Database.GetScalarValue(oCheck)
|
||||
|
||||
If oExists = 0 Then
|
||||
Dim oSql As String = $"INSERT INTO [dbo].[TBSIG_RECEIVER]
|
||||
If oExists = 0 Then
|
||||
Dim oSql As String = $"INSERT INTO [dbo].[TBSIG_RECEIVER]
|
||||
([EMAIL_ADDRESS]
|
||||
,[SIGNATURE])
|
||||
VALUES
|
||||
('{pReceiver.EmailAddress}'
|
||||
,'{pReceiver.GetSignature()}')"
|
||||
|
||||
Dim oCommand = New SqlCommand(oSql)
|
||||
Dim oResult = Database.ExecuteNonQuery(oCommand)
|
||||
If oResult = True Then
|
||||
pReceiver.Id = GetReceiverIdByEmail(pReceiver.EmailAddress, pTransaction)
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Else
|
||||
Logger.Warn($"Receiver [{pReceiver.EmailAddress}] already existing! SignatureID: {oSignature} Check SQL {oCheck}")
|
||||
Dim oCommand = New SqlCommand(oSql)
|
||||
Dim oResult = Database.ExecuteNonQuery(oCommand)
|
||||
If oResult = True Then
|
||||
pReceiver.Id = GetReceiverIdByEmail(pReceiver.EmailAddress, pTransaction)
|
||||
Return True
|
||||
Else
|
||||
Return False
|
||||
End If
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
Else
|
||||
Logger.Warn($"Receiver [{pReceiver.EmailAddress}] already existing! SignatureID: {oSignature} Check SQL {oCheck}")
|
||||
Return True
|
||||
End If
|
||||
End Function
|
||||
|
||||
Public Function Update(pReceiver As Receiver, pTransaction As SqlTransaction) As Boolean
|
||||
|
||||
@ -286,9 +286,7 @@ Public Class EnvelopeEditorController
|
||||
Dim oTransaction = oConnection.BeginTransaction()
|
||||
|
||||
Try
|
||||
If InsertReceivers(pNewReceivers, oTransaction) = False Then
|
||||
Throw New ApplicationException("Could not insert receivers!")
|
||||
End If
|
||||
InsertReceivers(pNewReceivers, oTransaction)
|
||||
|
||||
oTransaction.Commit()
|
||||
|
||||
@ -382,17 +380,15 @@ Public Class EnvelopeEditorController
|
||||
Return ElementModel.ElementsExist(Envelope.Id, pReceiverId)
|
||||
End Function
|
||||
|
||||
Private Function InsertReceivers(pReceivers As List(Of Receiver), pTransaction As SqlTransaction) As Boolean
|
||||
Try
|
||||
Return pReceivers.
|
||||
Select(Function(r) InsertReceiver(r, pTransaction)).
|
||||
All(Function(pResult) pResult = True)
|
||||
Private Sub InsertReceivers(pReceivers As List(Of Receiver), pTransaction As SqlTransaction)
|
||||
Dim status = pReceivers.
|
||||
Select(Function(r) InsertReceiver(r, pTransaction)).
|
||||
All(Function(pResult) pResult = True)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return False
|
||||
End Try
|
||||
End Function
|
||||
If Not status Then
|
||||
Throw New ApplicationException("Could not insert receivers!")
|
||||
End If
|
||||
End Sub
|
||||
|
||||
Private Function AssignReceivers(pEnvelope As Envelope, pTransaction As SqlTransaction) As Boolean
|
||||
If ReceiverModel.Unassign(pEnvelope, pTransaction) = False Then
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user