Improve annotation handling and date retrieval robustness
Refactored annotation processing in PDFBurner.vb to handle null elements and annotations safely, preventing possible errors and improving code clarity. Updated GetSignedDate in ReceiverModel.vb to ensure consistent DateTime return values, handle DBNull and type conversions, and improve error handling.
This commit is contained in:
@@ -85,16 +85,37 @@ Namespace Jobs.FinalizeDocument
|
|||||||
|
|
||||||
'Add annotations
|
'Add annotations
|
||||||
For Each element In elements
|
For Each element In elements
|
||||||
|
If element Is Nothing Then
|
||||||
|
Continue For
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim elementAnnotations = If(element.Annotations, Enumerable.Empty(Of ElementAnnotation)())
|
||||||
|
If Not elementAnnotations.Any() Then
|
||||||
|
Continue For
|
||||||
|
End If
|
||||||
|
|
||||||
Dim frameX = (element.Left - 0.7 - margin)
|
Dim frameX = (element.Left - 0.7 - margin)
|
||||||
|
|
||||||
Dim frame = element.Annotations.FirstOrDefault(Function(a) a.Name = "frame")
|
Dim frame = elementAnnotations.FirstOrDefault(Function(a) a.Name = "frame")
|
||||||
Dim frameY = element.Top - 0.5 - margin
|
Dim frameY = element.Top - 0.5 - margin
|
||||||
Dim frameYShift = frame.Y - frameY * inchFactor
|
Dim frameYShift As Double = 0
|
||||||
Dim frameXShift = frame.X - frameX * inchFactor
|
Dim frameXShift As Double = 0
|
||||||
|
|
||||||
|
If frame IsNot Nothing Then
|
||||||
|
frameYShift = frame.Y - frameY * inchFactor
|
||||||
|
frameXShift = frame.X - frameX * inchFactor
|
||||||
|
End If
|
||||||
|
|
||||||
|
For Each annot In elementAnnotations
|
||||||
|
If annot Is Nothing Then
|
||||||
|
Continue For
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim yOffsetofFF As Double = 0
|
||||||
|
If Not String.IsNullOrEmpty(annot.Name) Then
|
||||||
|
yOffsetsOfFF.TryGetValue(annot.Name, yOffsetofFF)
|
||||||
|
End If
|
||||||
|
|
||||||
For Each annot In element.Annotations
|
|
||||||
Dim yOffsetofFF As Double = If(yOffsetsOfFF.TryGetValue(annot.Name, yOffsetofFF), yOffsetofFF, 0)
|
|
||||||
Dim y = frameY + yOffsetofFF
|
Dim y = frameY + yOffsetofFF
|
||||||
|
|
||||||
If annot.Type = AnnotationType.FormField Then
|
If annot.Type = AnnotationType.FormField Then
|
||||||
|
|||||||
@@ -270,12 +270,26 @@ Public Class ReceiverModel
|
|||||||
Private Function GetSignedDate(pEmailAddress As String, pEnvelopeId As Integer) As Date
|
Private Function GetSignedDate(pEmailAddress As String, pEnvelopeId As Integer) As Date
|
||||||
Try
|
Try
|
||||||
Dim oStatusInt As Integer = EnvelopeStatus.DocumentSigned
|
Dim oStatusInt As Integer = EnvelopeStatus.DocumentSigned
|
||||||
Return Database.GetScalarValue($"SELECT ACTION_DATE FROM [DD_ECM].[dbo].[TBSIG_ENVELOPE_HISTORY] WHERE ENVELOPE_ID = {pEnvelopeId}
|
Dim value = Database.GetScalarValue($"SELECT ACTION_DATE FROM [DD_ECM].[dbo].[TBSIG_ENVELOPE_HISTORY] WHERE ENVELOPE_ID = {pEnvelopeId}
|
||||||
And USER_REFERENCE = '{pEmailAddress}' AND [STATUS] = {oStatusInt}")
|
And USER_REFERENCE = '{pEmailAddress}' AND [STATUS] = {oStatusInt}")
|
||||||
|
|
||||||
|
If value Is Nothing OrElse value Is DBNull.Value Then
|
||||||
|
Return DateTime.MinValue
|
||||||
|
End If
|
||||||
|
|
||||||
|
If TypeOf value Is DateTime Then
|
||||||
|
Return DirectCast(value, DateTime)
|
||||||
|
End If
|
||||||
|
|
||||||
|
Dim parsedDate As DateTime
|
||||||
|
If DateTime.TryParse(value.ToString(), parsedDate) Then
|
||||||
|
Return parsedDate
|
||||||
|
End If
|
||||||
|
|
||||||
|
Return DateTime.MinValue
|
||||||
Catch ex As Exception
|
Catch ex As Exception
|
||||||
Logger.Error(ex)
|
Logger.Error(ex)
|
||||||
Return Nothing
|
Return DateTime.MinValue
|
||||||
End Try
|
End Try
|
||||||
End Function
|
End Function
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user