Imports DigitalData.Modules.Base Imports DigitalData.Modules.Database Imports EnvelopeGenerator.Common Imports GdPicture14.Annotations Public Class FieldEditorController Inherits BaseClass Private ReadOnly ElementModel As ElementModel Private ReadOnly Database As MSSQLServer Private ReadOnly Document As EnvelopeDocument Public Property Elements As New List(Of EnvelopeDocumentElement) Public Sub New(pState As State, pDocument As EnvelopeDocument) MyBase.New(pState.LogConfig) Database = pState.Database Document = pDocument ElementModel = New ElementModel(pState) End Sub Public Sub AddOrUpdateElement(pAnnotation As AnnotationStickyNote) Dim oTag As String() = pAnnotation.Tag.Split("|"c) Dim oReceiverId = Integer.Parse(oTag(0)) Dim oPage = Integer.Parse(oTag(1)) Dim oIndex = Integer.Parse(oTag(2)) Dim oELement = Elements.Where(Function(e) e.AnnotationIndex = oIndex And e.Page = oPage And e.ReceiverId = oReceiverId).SingleOrDefault() If oELement IsNot Nothing Then oELement.Height = pAnnotation.Height oELement.Width = pAnnotation.Width oELement.X = pAnnotation.Left oELement.Y = pAnnotation.Top Else Elements.Add(New EnvelopeDocumentElement() With { .ElementType = Common.Constants.ElementType.Signature.ToString, .Height = pAnnotation.Height, .Width = pAnnotation.Width, .X = pAnnotation.Left, .Y = pAnnotation.Top, .DocumentId = Document.Id, .ReceiverId = oReceiverId, .AnnotationIndex = oIndex, .Page = oPage }) End If End Sub Public Function LoadElements() As Boolean Elements = ElementModel.List(Document.Id) If Elements Is Nothing Then Return False Else Return True End If End Function Public Function SaveElements() As Boolean Return Elements. Select(AddressOf SaveElement). All(Function(pResult) pResult = True) End Function Public Function SaveElement(pElement As EnvelopeDocumentElement) As Boolean Try If pElement.Id > 0 Then Return ElementModel.Update(pElement) Else Return ElementModel.Insert(pElement) End If Catch ex As Exception Logger.Error(ex) Return False End Try End Function End Class