Zooflow: WIP
This commit is contained in:
@@ -14,13 +14,13 @@ Public MustInherit Class BaseMethod
|
||||
Helpers = New Helpers(pLogConfig, pMSSQLServer)
|
||||
End Sub
|
||||
|
||||
Public Function LogAndThrow(pMessage As String)
|
||||
Public Sub LogAndThrow(pMessage As String)
|
||||
Logger.Warn(pMessage)
|
||||
Throw New ApplicationException(pMessage)
|
||||
End Function
|
||||
End Sub
|
||||
|
||||
Public Function LogAndThrow(pException As Exception, pMessage As String)
|
||||
Public Sub LogAndThrow(pException As Exception, pMessage As String)
|
||||
Logger.Error(pException)
|
||||
Throw New ApplicationException(pMessage, pException)
|
||||
End Function
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
@@ -10,8 +10,8 @@ Imports DigitalData.Services.EDMIService.Messages
|
||||
Imports DigitalData.Modules.EDMI.API.Rights
|
||||
Imports DigitalData.Services.EDMIService.Exceptions
|
||||
Imports DigitalData.Services.EDMIService.GlobalState
|
||||
Imports DigitalData.Services.EDMIService.FileStorage
|
||||
Imports DigitalData.Services.EDMIService.FileStorage.SetAttributeValue
|
||||
Imports DigitalData.Services.EDMIService.Methods
|
||||
Imports DigitalData.Services.EDMIService.Methods.SetAttributeValue
|
||||
|
||||
<ServiceBehavior(InstanceContextMode:=InstanceContextMode.PerSession)>
|
||||
Public Class EDMIService
|
||||
@@ -81,52 +81,18 @@ Public Class EDMIService
|
||||
|
||||
#Region "=== Database ==="
|
||||
Public Function ReturnDatatableFromCache(Name As String, FilterExpression As String, SortByColumn As String) As TableResult Implements IEDMIService.ReturnDatatableFromCache
|
||||
Try
|
||||
_Logger.Debug($"ReturnDatatableFromCache: Datatable: {Name}")
|
||||
Dim oReturnDatatableFromCache As New GetDatatableFromCache.GetDatatableFromCacheMethod(LogConfig, MSSQL_ECM, GlobalState.TableStore)
|
||||
Dim oResult = oReturnDatatableFromCache.Run(New GetDatatableFromCache.GetDatatableFromCacheRequest With {
|
||||
.DataTable = Name,
|
||||
.FilterExpression = FilterExpression,
|
||||
.SortByColumn = SortByColumn
|
||||
})
|
||||
|
||||
Dim oDataset As DataSet = GlobalState.TableStore
|
||||
Dim oDataTable As DataTable = Nothing
|
||||
|
||||
_Logger.Debug("ReturnDatatableFromCache: DataSet contains [{0}] datatables", oDataset.Tables.Count)
|
||||
|
||||
If oDataset.Tables.Contains(Name) Then
|
||||
oDataTable = oDataset.Tables.Item(Name).Copy()
|
||||
|
||||
' Apply filter and sorting to data
|
||||
Dim oFilterExpression As String = Utils.NotNull(FilterExpression, String.Empty)
|
||||
Dim oSortByColumn As String = Utils.NotNull(SortByColumn, String.Empty)
|
||||
|
||||
Dim oFilteredRows = oDataTable.Select(oFilterExpression, oSortByColumn)
|
||||
Dim oFilteredTable As DataTable = Nothing
|
||||
|
||||
If oFilteredRows.Count > 0 Then
|
||||
oFilteredTable = oFilteredRows.CopyToDataTable()
|
||||
oFilteredTable.TableName = Name
|
||||
Else
|
||||
' Produce empty table
|
||||
oFilteredTable = oDataTable.Clone()
|
||||
oFilteredTable.TableName = Name
|
||||
End If
|
||||
|
||||
_Logger.Debug("ReturnDatatableFromCache: Datatable Stats for [{0}]:", Name)
|
||||
_Logger.Debug("Unfiltered: [{0}] rows", oDataTable.Rows.Count)
|
||||
_Logger.Debug("Filtered: [{0}] rows", oFilteredTable.Rows.Count)
|
||||
|
||||
Return New TableResult(oFilteredTable)
|
||||
Else
|
||||
_Logger.Warn($"ReturnDatatableFromCache: Datatable {Name} does not exist")
|
||||
Throw GetFault($"ReturnDatatableFromCache: Datatable {Name} does not exist")
|
||||
End If
|
||||
|
||||
Catch ex As FaultException
|
||||
_Logger.Error(ex)
|
||||
Throw ex
|
||||
|
||||
Catch ex As Exception
|
||||
_Logger.Error(ex)
|
||||
Throw GetFault(ex)
|
||||
|
||||
End Try
|
||||
If oResult.OK Then
|
||||
Return New TableResult(oResult.Table)
|
||||
Else
|
||||
Return New TableResult(oResult.ErrorMessage)
|
||||
End If
|
||||
End Function
|
||||
#End Region
|
||||
|
||||
|
||||
@@ -131,15 +131,22 @@
|
||||
<Compile Include="BaseMethod.vb" />
|
||||
<Compile Include="ClassConstants.vb" />
|
||||
<Compile Include="Config.vb" />
|
||||
<Compile Include="Filestorage\GetAttributeValue\GetAttributeValueMethod.vb" />
|
||||
<Compile Include="Filestorage\GetAttributeValue\GetAttributeValueRequest.vb" />
|
||||
<Compile Include="Filestorage\GetAttributeValue\GetAttributeValueResponse.vb" />
|
||||
<Compile Include="Filestorage\NewFile\NewFileMethod.vb" />
|
||||
<Compile Include="Filestorage\NewFile\NewFileRequest.vb" />
|
||||
<Compile Include="Filestorage\NewFile\NewFileResponse.vb" />
|
||||
<Compile Include="Filestorage\SetAttributeValue\SetAttributeValueMethod.vb" />
|
||||
<Compile Include="Filestorage\SetAttributeValue\SetAttributeValueResponse.vb" />
|
||||
<Compile Include="Filestorage\SetAttributeValue\SetAttributeValueRequest.vb" />
|
||||
<Compile Include="Methods\FileProperties.vb" />
|
||||
<Compile Include="Methods\GetAttributeValue\GetAttributeValueMethod.vb" />
|
||||
<Compile Include="Methods\GetAttributeValue\GetAttributeValueRequest.vb" />
|
||||
<Compile Include="Methods\GetAttributeValue\GetAttributeValueResponse.vb" />
|
||||
<Compile Include="Methods\GetDatatableFromCache\GetDatatableFromCacheMethod.vb" />
|
||||
<Compile Include="Methods\GetDatatableFromCache\GetDatatableFromCacheRequest.vb" />
|
||||
<Compile Include="Methods\GetDatatableFromCache\GetDatatableFromCacheResponse.vb" />
|
||||
<Compile Include="Methods\GlobalIndexer\ImportFile\ImportFileMethod.vb" />
|
||||
<Compile Include="Methods\GlobalIndexer\ImportFile\ImportFileRequest.vb" />
|
||||
<Compile Include="Methods\GlobalIndexer\ImportFile\ImportFileResponse.vb" />
|
||||
<Compile Include="Methods\NewFile\NewFileMethod.vb" />
|
||||
<Compile Include="Methods\NewFile\NewFileRequest.vb" />
|
||||
<Compile Include="Methods\NewFile\NewFileResponse.vb" />
|
||||
<Compile Include="Methods\SetAttributeValue\SetAttributeValueMethod.vb" />
|
||||
<Compile Include="Methods\SetAttributeValue\SetAttributeValueResponse.vb" />
|
||||
<Compile Include="Methods\SetAttributeValue\SetAttributeValueRequest.vb" />
|
||||
<Compile Include="GlobalState.vb" />
|
||||
<Compile Include="IDB\Helpers.vb" />
|
||||
<Compile Include="Messages\AccessRightResult.vb" />
|
||||
@@ -148,6 +155,7 @@
|
||||
<Compile Include="Exceptions.vb" />
|
||||
<Compile Include="Messages\DatabaseResult.vb" />
|
||||
<Compile Include="EDMIService.vb" />
|
||||
<Compile Include="Methods\UserAttributeValue.vb" />
|
||||
<Compile Include="Scheduler\Scheduler.vb" />
|
||||
<Compile Include="Scheduler\DatatableJob.vb" />
|
||||
<Compile Include="Scheduler\JobListener.vb" />
|
||||
@@ -233,6 +241,10 @@
|
||||
<Project>{903B2D7D-3B80-4BE9-8713-7447B704E1B0}</Project>
|
||||
<Name>Logging</Name>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\Modules.Patterns\Patterns.vbproj">
|
||||
<Project>{7c3b0c7e-59fe-4e1a-a655-27ae119f9444}</Project>
|
||||
<Name>Patterns</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include=".NETFramework,Version=v4.6.1">
|
||||
|
||||
@@ -26,7 +26,7 @@ Public Class GlobalState
|
||||
|
||||
ObjectStores.Clear()
|
||||
|
||||
_Logger.Debug("Found {0} Object Stores", oDatatable.Rows)
|
||||
_Logger.Info("Found [{0}] Object Stores", oDatatable.Rows.Count)
|
||||
|
||||
For Each oRow As DataRow In oDatatable.Rows
|
||||
Dim oStore As New ObjectStore() With {
|
||||
@@ -35,7 +35,7 @@ Public Class GlobalState
|
||||
.Path = oRow.Item("IDB_PRAEFIX"),
|
||||
.Title = oRow.Item("OS_TITLE")
|
||||
}
|
||||
_Logger.Debug("New Object Store [{0}]", oStore.Title)
|
||||
_Logger.Info("New Object Store [{0}]", oStore.Title)
|
||||
ObjectStores.Add(oStore)
|
||||
Next
|
||||
Catch ex As Exception
|
||||
|
||||
@@ -3,7 +3,7 @@ Imports System.ServiceModel
|
||||
Imports DigitalData.Modules.Filesystem
|
||||
Imports DigitalData.Services.EDMIService.Exceptions
|
||||
Imports DigitalData.Services.EDMIService.Messages
|
||||
Imports DigitalData.Services.EDMIService.FileStorage
|
||||
Imports DigitalData.Services.EDMIService.Methods
|
||||
|
||||
<ServiceContract(Name:="IEDMIService", [Namespace]:="http://DigitalData.Services.EDMIService")>
|
||||
Interface IEDMIService
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace FileStorage.NewFile
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class NewFileRequest
|
||||
Namespace Methods
|
||||
Public Class FileProperties
|
||||
''' <summary>
|
||||
''' Absolute filename of the file to be imported
|
||||
''' </summary>
|
||||
@@ -39,38 +37,6 @@ Namespace FileStorage.NewFile
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property FileChecksum As String
|
||||
|
||||
''' <summary>
|
||||
''' Name/title of the ObjectStore to save the file to, ex. Work
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property StoreName As String
|
||||
|
||||
''' <summary>
|
||||
''' The business entity of the file, ex DEFAULT
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property BusinessEntity As String
|
||||
|
||||
''' <summary>
|
||||
''' The kind of object to be created, ex. DOC
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property KindType As String
|
||||
|
||||
''' <summary>
|
||||
''' The name of the user importing the file, ex. JenneJ
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property Who As String
|
||||
|
||||
''' <summary>
|
||||
''' The language of the user
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<DataMember>
|
||||
Public Property Language As String
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
|
||||
End Namespace
|
||||
@@ -1,7 +1,7 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace FileStorage.GetAttributeValue
|
||||
Namespace Methods.GetAttributeValue
|
||||
Public Class GetAttributeValueMethod
|
||||
Inherits BaseMethod
|
||||
|
||||
@@ -16,7 +16,7 @@ Namespace FileStorage.GetAttributeValue
|
||||
End If
|
||||
|
||||
Dim oValue As Object
|
||||
|
||||
' TODO: Implement GetAttributeValue
|
||||
|
||||
Return New GetAttributeValueResponse(pData.ObjectId, oValue)
|
||||
Catch ex As Exception
|
||||
@@ -1,4 +1,4 @@
|
||||
Namespace FileStorage.GetAttributeValue
|
||||
Namespace Methods.GetAttributeValue
|
||||
Public Class GetAttributeValueRequest
|
||||
Public Property ObjectId As Long
|
||||
End Class
|
||||
@@ -1,6 +1,6 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace FileStorage.GetAttributeValue
|
||||
Namespace Methods.GetAttributeValue
|
||||
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
@@ -0,0 +1,62 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Modules.Logging
|
||||
|
||||
Namespace Methods.GetDatatableFromCache
|
||||
Public Class GetDatatableFromCacheMethod
|
||||
Inherits BaseMethod
|
||||
|
||||
Private ReadOnly TableStore As DataSet
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer, pTableStore As DataSet)
|
||||
MyBase.New(pLogConfig, pMSSQLServer)
|
||||
TableStore = pTableStore
|
||||
End Sub
|
||||
|
||||
Public Function Run(pData As GetDatatableFromCacheRequest) As GetDatatableFromCacheResponse
|
||||
Try
|
||||
Logger.Debug($"ReturnDatatableFromCache: Datatable: {pData.DataTable}")
|
||||
|
||||
Dim oDataTable As DataTable = Nothing
|
||||
|
||||
Logger.Debug("ReturnDatatableFromCache: DataSet contains [{0}] datatables", TableStore.Tables.Count)
|
||||
|
||||
If TableStore.Tables.Contains(pData.DataTable) Then
|
||||
oDataTable = TableStore.Tables.Item(pData.DataTable).Copy()
|
||||
|
||||
' Apply filter and sorting to data
|
||||
Dim oFilterExpression As String = Utils.NotNull(pData.FilterExpression, String.Empty)
|
||||
Dim oSortByColumn As String = Utils.NotNull(pData.SortByColumn, String.Empty)
|
||||
|
||||
Dim oFilteredRows = oDataTable.Select(oFilterExpression, oSortByColumn)
|
||||
Dim oFilteredTable As DataTable = Nothing
|
||||
|
||||
If oFilteredRows.Count > 0 Then
|
||||
oFilteredTable = oFilteredRows.CopyToDataTable()
|
||||
oFilteredTable.TableName = pData.DataTable
|
||||
Else
|
||||
' Produce empty table
|
||||
oFilteredTable = oDataTable.Clone()
|
||||
oFilteredTable.TableName = pData.DataTable
|
||||
End If
|
||||
|
||||
Logger.Debug("ReturnDatatableFromCache: Datatable Stats for [{0}]:", pData.DataTable)
|
||||
Logger.Debug("Unfiltered: [{0}] rows", oDataTable.Rows.Count)
|
||||
Logger.Debug("Filtered: [{0}] rows", oFilteredTable.Rows.Count)
|
||||
|
||||
Return New GetDatatableFromCacheResponse(oFilteredTable)
|
||||
Else
|
||||
Logger.Warn($"ReturnDatatableFromCache: Datatable {pData.DataTable} does not exist")
|
||||
|
||||
Return New GetDatatableFromCacheResponse(New KeyNotFoundException($"Datatable {pData.DataTable} does not exist"))
|
||||
End If
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Error(ex)
|
||||
Return New GetDatatableFromCacheResponse(ex)
|
||||
|
||||
End Try
|
||||
End Function
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,14 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace Methods.GetDatatableFromCache
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class GetDatatableFromCacheRequest
|
||||
<DataMember>
|
||||
Public Property DataTable As String
|
||||
<DataMember>
|
||||
Public Property FilterExpression As String
|
||||
<DataMember>
|
||||
Public Property SortByColumn As String
|
||||
End Class
|
||||
End Namespace
|
||||
@@ -0,0 +1,22 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace Methods.GetDatatableFromCache
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class GetDatatableFromCacheResponse
|
||||
Inherits Messages.BaseResponse
|
||||
|
||||
<DataMember>
|
||||
Public Property Table As DataTable
|
||||
|
||||
Public Sub New(pTable As DataTable)
|
||||
MyBase.New()
|
||||
Table = pTable
|
||||
End Sub
|
||||
|
||||
Public Sub New(pException As Exception, Optional pDetails As String = "")
|
||||
MyBase.New(pException, pDetails)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,227 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Modules.Patterns
|
||||
Imports DigitalData.Modules.Language
|
||||
Imports DigitalData.Services.EDMIService.Methods.GetDatatableFromCache
|
||||
|
||||
Namespace Methods.GlobalIndexer.ImportFile
|
||||
Public Class ImportFileMethod
|
||||
Inherits BaseMethod
|
||||
|
||||
Private ReadOnly TableStore As DataSet
|
||||
Private ReadOnly Patterns As Patterns2
|
||||
Private ReadOnly GetDatatable As GetDatatableFromCacheMethod
|
||||
|
||||
Private ManualIndexes As DataTable
|
||||
Private AutomaticIndexes As DataTable
|
||||
Private ManualIndexesPostProcessing As DataTable
|
||||
|
||||
Private Const VIEW_INDEX_MANUAL = "VWDDINDEX_MAN"
|
||||
Private Const VIEW_INDEX_AUTOMATIC = "VWDDINDEX_AUTOM"
|
||||
Private Const TABLE_POST_PROCESSING = "TBDD_INDEX_MAN_POSTPROCESSING"
|
||||
|
||||
Private Const TYPE_VBSPLIT = "VBSPLIT"
|
||||
Private Const TYPE_VBREPLACE = "VBREPLACE"
|
||||
Private Const TYPE_REGEXPRESSION = "REG. EXPRESSION"
|
||||
|
||||
Public Sub New(pLogConfig As LogConfig, pMSSQLServer As MSSQLServer, pTableStore As DataSet)
|
||||
MyBase.New(pLogConfig, pMSSQLServer)
|
||||
|
||||
TableStore = pTableStore
|
||||
Patterns = New Patterns2(pLogConfig)
|
||||
GetDatatable = New GetDatatableFromCacheMethod(LogConfig, Database, TableStore)
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
'''
|
||||
''' </summary>
|
||||
''' <remarks>
|
||||
'''
|
||||
'''
|
||||
'''
|
||||
''' </remarks>
|
||||
Public Function Run(pData As ImportFileRequest)
|
||||
Try
|
||||
LoadIndexes(pData.ProfileId)
|
||||
|
||||
Dim oFinalAttributes = pData.AttributeValues
|
||||
|
||||
' apply the post processing
|
||||
oFinalAttributes = ApplyManualPostprocessing(oFinalAttributes, ManualIndexesPostProcessing)
|
||||
|
||||
' TODO: apply the manual attributes
|
||||
oFinalAttributes = ApplyAutomaticeAttributes(oFinalAttributes)
|
||||
|
||||
|
||||
Catch ex As Exception
|
||||
Return New ImportFileResponse(ex)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Private Function ApplyManualPostprocessing(pManualAttributes As List(Of UserAttributeValue), pPostprocessingSteps As DataTable) As List(Of UserAttributeValue)
|
||||
Logger.Debug("Start of Method [ApplyManualPostprocessing]")
|
||||
Dim oAttributes = pManualAttributes
|
||||
|
||||
For Each oProcessingRow As DataRow In pPostprocessingSteps.Rows
|
||||
|
||||
Dim oIndexId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")
|
||||
Dim oIndexRow As DataRow = ManualIndexes.Select($"GUID = {oIndexId}").FirstOrDefault()
|
||||
Dim oIndex As UserAttributeValue = pManualAttributes.
|
||||
Where(Function(attr) attr.AttributeId = oProcessingRow.ItemEx(Of Integer)("IDXMAN_ID")).
|
||||
FirstOrDefault()
|
||||
|
||||
Dim oValue = GetPostprocessingValue(oIndex.AttributeValues, oIndexRow)
|
||||
|
||||
oAttributes.Add(New UserAttributeValue With {
|
||||
.AttributeId = oIndexId,
|
||||
.AttributeName = oIndex.AttributeName,
|
||||
.AttributeValues = oIndex.AttributeValues,
|
||||
.ControlName = oIndex.ControlName
|
||||
})
|
||||
Next
|
||||
|
||||
Return oAttributes
|
||||
End Function
|
||||
|
||||
Private Function ApplyAutomaticeAttributes(pManualAttributes As List(Of UserAttributeValue)) As List(Of UserAttributeValue)
|
||||
Logger.Debug("Start of Method [ApplyAutomaticeAttributes]")
|
||||
|
||||
Return pManualAttributes
|
||||
End Function
|
||||
|
||||
Private Function GetPostprocessingValue(pValues As List(Of String), pRow As DataRow)
|
||||
Logger.Debug("Start of Method [GetPostprocessingValue]")
|
||||
|
||||
Dim oType = pRow.Item("TYPE")
|
||||
Dim oResult As New List(Of String)
|
||||
|
||||
Logger.Debug("Type of Postprocessing is [{0}]", oType)
|
||||
|
||||
Select Case oType
|
||||
Case TYPE_VBREPLACE
|
||||
Dim oFindString = pRow.Item("TEXT1")
|
||||
Dim oReplaceString = pRow.Item("TEXT2")
|
||||
|
||||
Logger.Debug("Replacing [{0}] with [{1}]", oFindString, oReplaceString)
|
||||
|
||||
For Each oIndexValue In pValues
|
||||
Dim oReplaceResult = oIndexValue.Replace(oFindString, oReplaceString)
|
||||
If oReplaceResult.Equals(oIndexValue) Then
|
||||
Logger.Debug("Replace did not succeed, ReplaceString was not found.")
|
||||
Else
|
||||
Logger.Debug("Replace successful for [{0}].", oIndexValue)
|
||||
End If
|
||||
|
||||
oResult.Add(oReplaceResult)
|
||||
Next
|
||||
|
||||
Case TYPE_VBSPLIT
|
||||
Dim oSeparator As String = pRow.Item("TEXT1")
|
||||
Dim oSplitIndex As Integer = 0
|
||||
Integer.TryParse(pRow.Item("TEXT2"), oSplitIndex)
|
||||
|
||||
Logger.Debug("Splitting String at Separator [{0}] and Index [{1}]", oSeparator, oSplitIndex)
|
||||
|
||||
For Each oIndexValue In pValues
|
||||
Dim oSplitted As List(Of String) = oIndexValue.Split(oSeparator).ToList()
|
||||
Logger.Debug("Split succeeded, resulting list has [{0}] items.", oSplitted.Count)
|
||||
|
||||
If oSplitIndex < oSplitted.Count Then
|
||||
Dim oValue = oSplitted.Item(oSplitIndex)
|
||||
Logger.Debug("Saving value [{0}] from Index [{1}]", oValue, oSplitIndex)
|
||||
oResult.Add(oValue)
|
||||
Else
|
||||
Logger.Debug("SplitIndex(TEXT2) was out of array bounds. Skipping.")
|
||||
End If
|
||||
|
||||
Next
|
||||
|
||||
Case Else
|
||||
LogAndThrow($"Postprocessing type [{oType}] is not supported!")
|
||||
End Select
|
||||
|
||||
Return oResult
|
||||
End Function
|
||||
|
||||
Private Sub LoadIndexes(pProfileId As Integer)
|
||||
Logger.Debug("Start of Method [LoadIndexes]")
|
||||
|
||||
LoadManualIndexes(pProfileId)
|
||||
LoadAutomaticIndexes(pProfileId)
|
||||
LoadPostProcessingSteps()
|
||||
End Sub
|
||||
|
||||
Private Sub LoadAutomaticIndexes(pProfileId As Integer)
|
||||
Logger.Debug("Start of Method [LoadAutomaticIndexes]")
|
||||
|
||||
Try
|
||||
' Load automatic Indexes for this Import
|
||||
Dim oAutomaticIndexes = GetDatatable.Run(
|
||||
New GetDatatableFromCacheRequest With {
|
||||
.DataTable = VIEW_INDEX_MANUAL,
|
||||
.FilterExpression = $"DOK_ID = {pProfileId}"
|
||||
})
|
||||
|
||||
If oAutomaticIndexes.OK = False Then
|
||||
LogAndThrow(oAutomaticIndexes.ErrorMessage)
|
||||
End If
|
||||
|
||||
AutomaticIndexes = oAutomaticIndexes.Table
|
||||
Catch ex As Exception
|
||||
LogAndThrow(ex, "Error while automatic loading indexes!")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub LoadManualIndexes(pProfileId As Integer)
|
||||
Logger.Debug("Start of Method [LoadManualIndexes]")
|
||||
|
||||
|
||||
Try
|
||||
' Load manual Indexes for this Import
|
||||
Dim oManualIndexes = GetDatatable.Run(
|
||||
New GetDatatableFromCacheRequest With {
|
||||
.DataTable = VIEW_INDEX_MANUAL,
|
||||
.FilterExpression = $"DOK_ID = {pProfileId}"
|
||||
})
|
||||
|
||||
If oManualIndexes.OK = False Then
|
||||
LogAndThrow(oManualIndexes.ErrorMessage)
|
||||
End If
|
||||
|
||||
ManualIndexes = oManualIndexes.Table
|
||||
|
||||
Catch ex As Exception
|
||||
LogAndThrow(ex, "Error while loading indexes!")
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub LoadPostProcessingSteps()
|
||||
Logger.Debug("Start of Method [LoadPostProcessingSteps]")
|
||||
|
||||
Try
|
||||
' Generate a string containing all index ids joined into a string
|
||||
Dim oIndexIdList As New List(Of Integer)
|
||||
For Each oRow As DataRow In ManualIndexes.Rows
|
||||
oIndexIdList.Add(oRow.ItemEx(Of Integer)("GUID"))
|
||||
Next
|
||||
Dim oIndexIds As String = String.Join(",", oIndexIdList)
|
||||
|
||||
' Load all relevant postprocessing steps
|
||||
Dim oPostProcessingSteps = GetDatatable.Run(
|
||||
New GetDatatableFromCacheRequest With {
|
||||
.DataTable = TABLE_POST_PROCESSING,
|
||||
.FilterExpression = $"IDXMAN_ID IN ({oIndexIds})"
|
||||
})
|
||||
|
||||
If oPostProcessingSteps.OK = False Then
|
||||
LogAndThrow(oPostProcessingSteps.ErrorMessage)
|
||||
End If
|
||||
|
||||
ManualIndexesPostProcessing = oPostProcessingSteps.Table
|
||||
Catch ex As Exception
|
||||
LogAndThrow(ex, "Error while loading post processing steps!")
|
||||
End Try
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -0,0 +1,36 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace Methods.GlobalIndexer.ImportFile
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class ImportFileRequest
|
||||
''' <summary>
|
||||
''' Important File properties like, Name, Contents, CreatedAt, ModifiedAt, Checksum
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property File As FileProperties
|
||||
|
||||
''' <summary>
|
||||
''' The ProfileId the file will be imported with
|
||||
''' </summary>
|
||||
Public Property ProfileId As Integer
|
||||
|
||||
''' <summary>
|
||||
''' The attribute values given by the user in the form of
|
||||
''' Attribute Name/Attribute Value/ControlName
|
||||
''' </summary>
|
||||
Public Property AttributeValues As List(Of UserAttributeValue)
|
||||
|
||||
''' <summary>
|
||||
''' The name of the user importing the file, ex. JenneJ
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property Who As String
|
||||
|
||||
''' <summary>
|
||||
''' The language of the user, ex. de-DE
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property Language As String
|
||||
End Class
|
||||
End Namespace
|
||||
@@ -0,0 +1,22 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace Methods.GlobalIndexer.ImportFile
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class ImportFileResponse
|
||||
Inherits Messages.BaseResponse
|
||||
|
||||
<DataMember>
|
||||
Public Property ObjectId As Long
|
||||
|
||||
Public Sub New(pObjectId As Long)
|
||||
MyBase.New()
|
||||
ObjectId = pObjectId
|
||||
End Sub
|
||||
|
||||
Public Sub New(pException As Exception, Optional pDetails As String = "")
|
||||
MyBase.New(pException, pDetails)
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -2,7 +2,7 @@
|
||||
Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Modules.Database.MSSQLServer.TransactionMode
|
||||
Imports DigitalData.Modules.Logging
|
||||
Imports DigitalData.Services.EDMIService.FileStorage
|
||||
Imports DigitalData.Services.EDMIService.Methods
|
||||
Imports DigitalData.Services.EDMIService.GlobalState
|
||||
|
||||
Public Class NewFileMethod
|
||||
@@ -23,7 +23,7 @@ Public Class NewFileMethod
|
||||
Public Function Run(pData As NewFile.NewFileRequest) As NewFile.NewFileResponse
|
||||
Dim oFilePath As String = Nothing
|
||||
|
||||
Dim oExistingObjectId = TestFileChecksumExists(pData.FileChecksum)
|
||||
Dim oExistingObjectId = TestFileChecksumExists(pData.File.FileChecksum)
|
||||
If oExistingObjectId > 0 Then
|
||||
Return New NewFile.NewFileResponse(oExistingObjectId)
|
||||
End If
|
||||
@@ -51,10 +51,10 @@ Public Class NewFileMethod
|
||||
|
||||
' Get directory by DateImported or, if not supplied, by current date
|
||||
Dim oSubDirectory As String
|
||||
If IsNothing(pData.FileImportedAt) Then
|
||||
If IsNothing(pData.File.FileImportedAt) Then
|
||||
oSubDirectory = GetDateSubDirectory(Now)
|
||||
Else
|
||||
oSubDirectory = GetDateSubDirectory(pData.FileImportedAt)
|
||||
oSubDirectory = GetDateSubDirectory(pData.File.FileImportedAt)
|
||||
End If
|
||||
Logger.Debug("Subdirectory is [{0}]", oSubDirectory)
|
||||
|
||||
@@ -78,25 +78,25 @@ Public Class NewFileMethod
|
||||
oKeepFileName = True
|
||||
End If
|
||||
|
||||
Dim oFileName As String = GetFileObjectFileName(oObjectId, pData.FileName, oKeepFileName)
|
||||
Dim oFileName As String = GetFileObjectFileName(oObjectId, pData.File.FileName, oKeepFileName)
|
||||
Logger.Debug("Filename is [{0}]", oFileName)
|
||||
|
||||
oFilePath = IO.Path.Combine(oFinalPath, oFileName)
|
||||
Dim oFileObjectInfo As IO.FileInfo = New IO.FileInfo(oFilePath)
|
||||
|
||||
Dim oFileObjectSize As Long = pData.FileContents.Length
|
||||
Dim oFileObjectSize As Long = pData.File.FileContents.Length
|
||||
Dim oFileObjectExtension As String = oFileObjectInfo.Extension.Substring(1)
|
||||
Dim oFileObjectName As String = oFileObjectInfo.Name
|
||||
|
||||
Logger.Debug("File Information for [{0}]:", oFileObjectName)
|
||||
Logger.Debug("Size: [{0}]", oFileObjectSize)
|
||||
Logger.Debug("Extension: [{0}]", oFileObjectExtension)
|
||||
Logger.Debug("Checksum: [{0}]", pData.FileChecksum)
|
||||
Logger.Debug("Checksum: [{0}]", pData.File.FileChecksum)
|
||||
|
||||
Try
|
||||
Using oStream = New IO.FileStream(oFilePath, IO.FileMode.Create, IO.FileAccess.Write)
|
||||
Logger.Info("Saving file to path [{0}]", oFilePath)
|
||||
oStream.Write(pData.FileContents, 0, oFileObjectSize)
|
||||
oStream.Write(pData.File.FileContents, 0, oFileObjectSize)
|
||||
oStream.Flush(True)
|
||||
oStream.Close()
|
||||
End Using
|
||||
@@ -109,7 +109,7 @@ Public Class NewFileMethod
|
||||
Logger.Info("Creating IDB FileObject for ObjectId [{0}].", oObjectId)
|
||||
|
||||
' Insert into DB
|
||||
Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO '{oFinalPath}', '{oFileObjectName}', '{oFileObjectExtension}',{oFileObjectSize},'{pData.FileChecksum}' ,'{pData.Who}','{oObjectId}',{oStore.Id}"
|
||||
Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO '{oFinalPath}', '{oFileObjectName}', '{oFileObjectExtension}',{oFileObjectSize},'{pData.File.FileChecksum}' ,'{pData.Who}','{oObjectId}',{oStore.Id}"
|
||||
Dim oResult As Boolean = Database.ExecuteNonQueryWithConnectionObject(oSQL, Connection, ExternalTransaction, Transaction)
|
||||
|
||||
If oResult = False Then
|
||||
@@ -121,9 +121,9 @@ Public Class NewFileMethod
|
||||
'TODO: File dates in try catch
|
||||
|
||||
Dim oDefaultAttributes As New Dictionary(Of String, Object) From {
|
||||
{"OriginFileName", pData?.FileName},
|
||||
{"OriginCreationDatetime", pData?.FileCreatedAt},
|
||||
{"OriginChangedDatetime", pData?.FileChangedAt}
|
||||
{"OriginFileName", pData.File.FileName},
|
||||
{"OriginCreationDatetime", pData.File.FileCreatedAt},
|
||||
{"OriginChangedDatetime", pData.File.FileChangedAt}
|
||||
}
|
||||
|
||||
For Each oAttribute As KeyValuePair(Of String, Object) In oDefaultAttributes
|
||||
43
Service.EDMIService/Methods/NewFile/NewFileRequest.vb
Normal file
43
Service.EDMIService/Methods/NewFile/NewFileRequest.vb
Normal file
@@ -0,0 +1,43 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace Methods.NewFile
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class NewFileRequest
|
||||
<DataMember>
|
||||
Public Property File As FileProperties
|
||||
|
||||
''' <summary>
|
||||
''' Name/title of the ObjectStore to save the file to, ex. Work
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property StoreName As String
|
||||
|
||||
''' <summary>
|
||||
''' The business entity of the file, ex DEFAULT
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property BusinessEntity As String
|
||||
|
||||
''' <summary>
|
||||
''' The kind of object to be created, ex. DOC
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property KindType As String
|
||||
|
||||
''' <summary>
|
||||
''' The name of the user importing the file, ex. JenneJ
|
||||
''' </summary>
|
||||
<DataMember>
|
||||
Public Property Who As String
|
||||
|
||||
''' <summary>
|
||||
''' The language of the user
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
<DataMember>
|
||||
Public Property Language As String
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace FileStorage.SetAttributeValue
|
||||
Namespace Methods.SetAttributeValue
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class SetAttributeValueResponse
|
||||
@@ -3,7 +3,7 @@ Imports DigitalData.Modules.Database
|
||||
Imports DigitalData.Services.EDMIService.IDB
|
||||
Imports System.Data.SqlClient
|
||||
|
||||
Namespace FileStorage.SetAttributeValue
|
||||
Namespace Methods.SetAttributeValue
|
||||
Public Class SetAttributeValueMethod
|
||||
Inherits BaseMethod
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace FileStorage.SetAttributeValue
|
||||
Namespace Methods.SetAttributeValue
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class SetAttributeValueRequest
|
||||
@@ -1,6 +1,6 @@
|
||||
Imports System.Runtime.Serialization
|
||||
|
||||
Namespace FileStorage.NewFile
|
||||
Namespace Methods.NewFile
|
||||
<Serializable>
|
||||
<DataContract>
|
||||
Public Class NewFileResponse
|
||||
10
Service.EDMIService/Methods/UserAttributeValue.vb
Normal file
10
Service.EDMIService/Methods/UserAttributeValue.vb
Normal file
@@ -0,0 +1,10 @@
|
||||
Namespace Methods
|
||||
|
||||
Public Class UserAttributeValue
|
||||
Public Property AttributeId As Integer
|
||||
Public Property AttributeName As String
|
||||
Public Property AttributeValues As List(Of String)
|
||||
Public Property ControlName As String
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
@@ -1,4 +1,5 @@
|
||||
Module SettingsModule
|
||||
Public Const SERVICE_NAME As String = "DDEDMIService"
|
||||
Public Const SERVICE_DISPLAY_NAME As String = "Digital Data EDMI Service"
|
||||
Public Const SERVICE_BASE_ADDRESS As String = "net.tcp://localhost:9000/DigitalData/Services/Main"
|
||||
End Module
|
||||
|
||||
@@ -92,7 +92,7 @@ Public Class WindowsService
|
||||
|
||||
_Logger.Debug("Starting WCF ServiceHost")
|
||||
|
||||
Dim oBaseAddresses() As Uri = {New Uri("net.tcp://localhost:9000/DigitalData/Services/Main")}
|
||||
Dim oBaseAddresses() As Uri = {New Uri(SERVICE_BASE_ADDRESS)}
|
||||
_ServiceHost = New ServiceHost(Of EDMIService)(oBaseAddresses)
|
||||
_ServiceHost.EnableMetadataExchange(False)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user