WIP
This commit is contained in:
@@ -1,18 +1,15 @@
|
||||
Imports System.IO
|
||||
Imports ImporterShared.Schemas
|
||||
Imports ImporterShared.Winline
|
||||
|
||||
Namespace Documents
|
||||
Public Class Document
|
||||
Public File As FileInfo
|
||||
Public Type As DocumentType
|
||||
Public Schema As Schema
|
||||
Public Mandator As String
|
||||
Public Selected As Boolean = False
|
||||
Public Mandator As Mandator
|
||||
|
||||
''' <summary>
|
||||
''' TODO: Set before submitting to web services
|
||||
''' </summary>
|
||||
Public CreatedAt As Date
|
||||
Public Selected As Boolean = False
|
||||
|
||||
Public TemplateName As String
|
||||
Public TemplateType As Integer
|
||||
@@ -24,6 +21,18 @@ Namespace Documents
|
||||
''' </summary>
|
||||
Public Property Rows As New List(Of DocumentRow)
|
||||
|
||||
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
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports ImporterShared.Schemas
|
||||
Imports ImporterShared.Winline
|
||||
|
||||
Namespace Documents
|
||||
Public Class DocumentLoader
|
||||
@@ -17,7 +18,7 @@ Namespace Documents
|
||||
End Sub
|
||||
|
||||
|
||||
Public Function LoadFiles(pInputDirectory As String, pSchema As Schema) As Boolean
|
||||
Public Function LoadFiles(pInputDirectory As String, pSchema As Schema, pMandator As Mandator) As Boolean
|
||||
If pInputDirectory = String.Empty Then
|
||||
Throw New ArgumentNullException("InputDirectory")
|
||||
End If
|
||||
@@ -32,7 +33,8 @@ Namespace Documents
|
||||
Logger.Debug("Found [{0}] files in directory [{1}]", oFiles.Count, oDirectory)
|
||||
|
||||
For Each oFile In oFiles
|
||||
Dim oDocument = LoadFile(oFile, pSchema)
|
||||
' TODO: Supply currently selected mandator when the mandator selection works
|
||||
Dim oDocument = LoadFile(oFile, pSchema, pMandator)
|
||||
Files.Add(oDocument)
|
||||
Next
|
||||
|
||||
@@ -40,12 +42,12 @@ Namespace Documents
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Throw New IOException($"Could not load files from directory {pInputDirectory}", ex)
|
||||
Throw ex
|
||||
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function LoadFile(pFileInfo As FileInfo, pSchema As Schema) As Document
|
||||
Public Function LoadFile(pFileInfo As FileInfo, pSchema As Schema, pMandator As Mandator) As Document
|
||||
Dim oFileList As New List(Of FileInfo) From {pFileInfo}
|
||||
Logger.Info("Loading file [{0}]", pFileInfo.Name)
|
||||
|
||||
@@ -54,11 +56,11 @@ Namespace Documents
|
||||
Select(AddressOf WrapFileInfo).
|
||||
Select(Function(d) IncludeSchema(d, pSchema)).
|
||||
Select(Function(d) LoadDocumentData(d, pSchema)).
|
||||
Select(Function(d) MatchDataFromWinLine(d, Winline.Mandators)).
|
||||
Select(Function(d) MatchDataFromWinLine(d, Winline.Mandators, pMandator)).
|
||||
SingleOrDefault()
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return Nothing
|
||||
Throw ex
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -154,20 +156,26 @@ Namespace Documents
|
||||
End Function
|
||||
|
||||
|
||||
Private Function MatchDataFromWinLine(pDocument As Document, pMandators As List(Of Winline.Mandator)) As Document
|
||||
Private Function MatchDataFromWinLine(pDocument As Document, pMandators As List(Of Mandator), pMandator As Mandator) As Document
|
||||
Dim oMandators As List(Of Winline.Mandator) = pMandators.
|
||||
Where(Function(m) m.IsWhitelisted = True).
|
||||
OrderBy(Function(m) m.Order).
|
||||
ToList()
|
||||
|
||||
Dim oMandator = Winline.FindMatchingMandatorFromOrder(pDocument)
|
||||
Dim oMandator As Mandator = Nothing
|
||||
If pMandator IsNot Nothing Then
|
||||
oMandator = pMandator
|
||||
Else
|
||||
oMandator = Winline.FindMatchingMandatorFromOrder(pDocument)
|
||||
End If
|
||||
|
||||
If oMandator Is Nothing Then
|
||||
Logger.Warn("Mandator not found for File [{0}]", pDocument.File.Name)
|
||||
Throw New Exceptions.NoMandatorException($"Mandator not found for file [{pDocument.File.Name}]")
|
||||
End If
|
||||
|
||||
pDocument = MatchDocumentData(pDocument, oMandator)
|
||||
pDocument.Mandator = oMandator.Id
|
||||
pDocument.Mandator = oMandator
|
||||
|
||||
Return pDocument
|
||||
End Function
|
||||
|
||||
@@ -522,7 +522,7 @@ Namespace Winline
|
||||
|
||||
Public Function LoadTemplateConfiguration() As Boolean
|
||||
Try
|
||||
Dim oSql = $"SELECT XML_NAME, XML_ROOT, TEMPLATE_NAME, DATA_TYPE, IS_HEAD, FUNCTION_ID, READ_ONLY FROM [DD_ECM].[dbo].[VWEDI_XML_ITEMS]"
|
||||
Dim oSql = $"SELECT * FROM [DD_ECM].[dbo].[VWEDI_XML_ITEMS]"
|
||||
Dim oTable As DataTable = Database.GetDatatable(oSql)
|
||||
Dim oItems As New List(Of TemplateColumn)
|
||||
|
||||
@@ -533,7 +533,8 @@ Namespace Winline
|
||||
.Type = oRow.Item("XML_TYPE"),
|
||||
.Template = oRow.Item("TEMPLATE_NAME"),
|
||||
.[Function] = oRow.Item("FUNCTION_ID"),
|
||||
.[ReadOnly] = oRow.Item("READ_ONLY")
|
||||
.[ReadOnly] = oRow.Item("IS_READ_ONLY"),
|
||||
.[Visible] = oRow.Item("IS_VISIBLE")
|
||||
}
|
||||
|
||||
oItems.Add(oColumn)
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
Public IsHead As Boolean
|
||||
Public Template As String
|
||||
Public [ReadOnly] As Boolean
|
||||
Public Visible As Boolean
|
||||
Public [Function] As Constants.XmlFunction
|
||||
End Class
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ Namespace Winline
|
||||
' 1 = As File (relative to Winline Server directory)
|
||||
Dim oByref = 1
|
||||
|
||||
Dim oURL As String = $"{oWS.BaseUrl}/ewlservice/import?User={oWS.Username}&Password={oWS.Password}&Company={pDocument.Mandator}&Type={oTemplateType}&Vorlage={oTemplateName}&ActionCode={oActionCode}&Byref={oByref}&Data={oImportRelativeFilePath}"
|
||||
Dim oURL As String = $"{oWS.BaseUrl}/ewlservice/import?User={oWS.Username}&Password={oWS.Password}&Company={pDocument.Mandator.Id}&Type={oTemplateType}&Vorlage={oTemplateName}&ActionCode={oActionCode}&Byref={oByref}&Data={oImportRelativeFilePath}"
|
||||
Dim oClient As New HttpClient()
|
||||
|
||||
Logger.Info("Creating HTTP Request to [{0}]", oWS.BaseUrl)
|
||||
|
||||
Reference in New Issue
Block a user