97 lines
2.8 KiB
VB.net
97 lines
2.8 KiB
VB.net
Imports System.IO
|
|
Imports MultiTool.Common.Constants
|
|
Imports MultiTool.Common.Templates
|
|
Imports MultiTool.Common.Winline.Entities
|
|
|
|
Namespace Documents
|
|
Public Class Document
|
|
Public File As FileInfo
|
|
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
|
|
|
|
''' <summary>
|
|
''' Original Values, read-only
|
|
''' </summary>
|
|
Public Property Rows As New List(Of DocumentRow)
|
|
|
|
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 Errors As List(Of String)
|
|
Get
|
|
Dim oRowErrors = Rows.SelectMany(Function(row) row.Errors).ToList()
|
|
Dim oDocumentErrors As List(Of String) = GetDocumentErrors().
|
|
Select(Function(err) err.ToString()).
|
|
ToList()
|
|
Return oDocumentErrors.
|
|
Concat(oRowErrors).
|
|
ToList()
|
|
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
|
|
|
|
''' <summary>
|
|
''' Finds the first occurrence of Field and returns its value
|
|
''' </summary>
|
|
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
|
|
|
|
Private Function GetDocumentErrors() As List(Of DocumentError)
|
|
Dim oErrors As New List(Of DocumentError)
|
|
|
|
If Mandator Is Nothing Then
|
|
oErrors.Add(DocumentError.MandatorNotFound)
|
|
End If
|
|
|
|
Return oErrors
|
|
End Function
|
|
|
|
End Class
|
|
|
|
End Namespace |