108 lines
3.1 KiB
VB.net
108 lines
3.1 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
|
|
|
|
''' <summary>
|
|
''' This is used for saving the selected state via checkbox, don't remove!
|
|
''' </summary>
|
|
Public Property Selected As Boolean = False
|
|
|
|
Private DocumentErrors As New List(Of DocumentError)
|
|
|
|
Public ReadOnly Property HasErrors As Boolean
|
|
Get
|
|
Return Errors.Count > 0
|
|
End Get
|
|
End Property
|
|
|
|
Public ReadOnly Property Errors As List(Of String)
|
|
Get
|
|
Dim oRowErrors = Rows.
|
|
SelectMany(Function(row) row.Errors, Function(row, err) err.ToString).
|
|
ToList()
|
|
|
|
Dim oDocumentErrors As List(Of String) = DocumentErrors.
|
|
Select(Function(err) err.ToString()).
|
|
ToList()
|
|
|
|
Return oDocumentErrors.
|
|
Concat(oRowErrors).
|
|
ToList()
|
|
End Get
|
|
End Property
|
|
|
|
Public Sub AddDocumentError(pDocumentError As DocumentErrorType, pMessage As String)
|
|
DocumentErrors.Add(New DocumentError With {
|
|
.Type = pDocumentError,
|
|
.Message = pMessage
|
|
})
|
|
End Sub
|
|
|
|
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
|
|
If obj Is Nothing Then
|
|
Return False
|
|
End If
|
|
|
|
Return FullName = DirectCast(obj, Document).FullName
|
|
End Function
|
|
End Class
|
|
|
|
End Namespace |