Imports System.IO Imports MultiTool.Common.Templates Imports MultiTool.Common.Winline.Entities Namespace Documents Public Class Document Public File As FileInfo Public Property Type As DocumentType Public Schema As Template Public Mandator As Mandator Public TemplateName As String Public Property TemplateType As Integer Public [Option] As Integer Public PrintVoucher As Integer ''' ''' Original Values, read-only ''' Public Property Rows As New List(Of DocumentRow) Public Property Selected As Boolean = False Public Property Imported As Boolean = False Public ReadOnly Property HasErrors As Boolean Get Return Mandator Is Nothing Or Rows.Any(Function(r As DocumentRow) r.HasErrors) End Get End Property Public ReadOnly Property MandatorId As String Get Return Mandator?.Id End Get End Property Public ReadOnly Property CreatedAt As Date Get Return File?.CreationTime End Get End Property Public ReadOnly Property FullName As String Get Return File?.FullName End Get End Property Public ReadOnly Property FileName As String Get Return File?.Name End Get End Property ''' ''' Finds the first occurrence of Field and returns its value ''' Public Function GetFieldValue(pField As String) As String For Each oRow In Rows For Each oField In oRow.Fields If oField.Key = pField Then Return oField.Value.Final End If Next Next Return Nothing End Function Public Overrides Function Equals(obj As Object) As Boolean Return FullName = DirectCast(obj, Document).FullName End Function End Class End Namespace