EDMIService: First working version of ImportFile
This commit is contained in:
@@ -10,7 +10,8 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
|
||||
Private ReadOnly Patterns As Patterns2
|
||||
Private ReadOnly GetDatatable As GetDatatableFromCacheMethod
|
||||
|
||||
Private ReadOnly Connection As SqlClient.SqlConnection
|
||||
Private ReadOnly Transaction As SqlClient.SqlTransaction
|
||||
Private Profile As DataRow
|
||||
|
||||
Private Const VIEW_PROFILE = "VWGI_DOCTYPE_IDB"
|
||||
@@ -23,6 +24,8 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
|
||||
Patterns = New Patterns2(pLogConfig)
|
||||
GetDatatable = New GetDatatableFromCacheMethod(LogConfig, Database, GlobalState)
|
||||
Connection = Database.GetConnection()
|
||||
Transaction = Connection.BeginTransaction()
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
@@ -67,12 +70,52 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
|
||||
If oResponse.OK Then
|
||||
Logger.Info("Import of file [{0}] under ObjectId [{1}] successful!", pData.File.FileName, oResponse.ObjectId)
|
||||
Return New ImportFileResponse(oResponse.ObjectId)
|
||||
Else
|
||||
Throw New ApplicationException(oResponse.ErrorMessage)
|
||||
End If
|
||||
|
||||
Logger.Info("Writing Attributes for ObjectId [{0}]", oResponse.ObjectId)
|
||||
|
||||
Dim oAttributes As New Dictionary(Of String, Object)
|
||||
For Each oFinalAttribute In oFinalAttributes
|
||||
If oFinalAttribute.AttributeValues Is Nothing OrElse oFinalAttribute.AttributeValues.Count = 0 Then
|
||||
Logger.Warn("Values for Attribute [{0}] are empty. Skipping.", oFinalAttribute.AttributeName)
|
||||
Continue For
|
||||
End If
|
||||
|
||||
oAttributes.Add(oFinalAttribute.AttributeName, oFinalAttribute.AttributeValues.First)
|
||||
Next
|
||||
|
||||
For Each oAttribute As KeyValuePair(Of String, Object) In oAttributes
|
||||
Try
|
||||
' Dont write empty attributes
|
||||
If oAttribute.Value Is Nothing Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
Dim oSuccess = Helpers.SetAttributeValue(Connection, Transaction, oResponse.ObjectId, oAttribute.Key, oAttribute.Value, pData.User.Language, pData.User.UserName)
|
||||
If oSuccess Then
|
||||
Logger.Info("Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value)
|
||||
Else
|
||||
Logger.Warn("Attribute value could not be written")
|
||||
End If
|
||||
Catch ex As Exception
|
||||
LogAndThrow(ex, $"Attribute [{oAttribute.Key}] could not be written!")
|
||||
End Try
|
||||
Next
|
||||
|
||||
' Finally, commit the transaction
|
||||
Transaction?.Commit()
|
||||
|
||||
Return New ImportFileResponse(oResponse.ObjectId)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while importing file!")
|
||||
Logger.Error(ex)
|
||||
|
||||
Logger.Info("Rolling back transaction.")
|
||||
Transaction?.Rollback()
|
||||
|
||||
Return New ImportFileResponse(ex)
|
||||
End Try
|
||||
End Function
|
||||
@@ -142,7 +185,7 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
oIndexes.Add(oAutomaticIndex)
|
||||
Next
|
||||
|
||||
Logger.Info("[{0}] automatic indexes loaded.", oIndexes)
|
||||
Logger.Info("Automatic indexes loaded: [{0}]", oIndexes.Count)
|
||||
|
||||
Return oIndexes
|
||||
Catch ex As Exception
|
||||
@@ -186,6 +229,8 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
oIndexes.Add(oManualIndex)
|
||||
Next
|
||||
|
||||
Logger.Info("Manual indexes loaded: [{0}]", oIndexes.Count)
|
||||
|
||||
Return oIndexes
|
||||
|
||||
Catch ex As Exception
|
||||
|
||||
Reference in New Issue
Block a user