EDMI: Add generic ImportFile Method
This commit is contained in:
@@ -37,7 +37,7 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
'''
|
||||
'''
|
||||
''' </remarks>
|
||||
Public Function Run(pData As ImportFileRequest)
|
||||
Public Function Run(pData As Globix_ImportFileRequest)
|
||||
Try
|
||||
User = pData.User
|
||||
|
||||
@@ -99,14 +99,14 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
ToDictionary(Function(kv) kv.Key, Function(kv) kv.Value)
|
||||
|
||||
Logger.Info("Writing [{0}] Attributes for ObjectId [{0}] ", oResponse.ObjectId)
|
||||
WriteAttributeValues(oResponse.ObjectId, oFinalAttributes)
|
||||
Helpers.SetAttributeValuesWithTransaction(Connection, Transaction, oResponse.ObjectId, oFinalAttributes, User.Language, User.UserName)
|
||||
|
||||
'TODO: Write to TBGI_INDEX_HISTORY?
|
||||
|
||||
' Finally, commit the transaction
|
||||
Transaction?.Commit()
|
||||
|
||||
Return New ImportFileResponse(oResponse.ObjectId)
|
||||
Return New Globix_ImportFileResponse(oResponse.ObjectId)
|
||||
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while importing file!")
|
||||
@@ -115,7 +115,7 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
Logger.Info("Rolling back transaction.")
|
||||
Transaction?.Rollback()
|
||||
|
||||
Return New ImportFileResponse(ex)
|
||||
Return New Globix_ImportFileResponse(ex)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -154,30 +154,6 @@ Namespace Methods.GlobalIndexer.ImportFile
|
||||
|
||||
Return oFileName & pFileInfo.Extension
|
||||
End Function
|
||||
|
||||
Private Sub WriteAttributeValues(pObjectId As Long, pAttributes As Dictionary(Of String, List(Of String)))
|
||||
For Each oAttribute As KeyValuePair(Of String, List(Of String)) In pAttributes
|
||||
Try
|
||||
' TODO: This works only for simple attributes for now!!!
|
||||
Dim oValue = oAttribute.Value.FirstOrDefault()
|
||||
|
||||
' Dont write empty attributes
|
||||
If oValue Is Nothing Then
|
||||
Continue For
|
||||
End If
|
||||
|
||||
' Now make the call to the database
|
||||
Dim oSuccess = Helpers.SetAttributeValue(Connection, Transaction, pObjectId, oAttribute.Key, oValue, User.Language, User.UserName)
|
||||
If oSuccess Then
|
||||
Logger.Info("Attribute written [{0}] => [{1}]", oAttribute.Key, oAttribute.Value.First())
|
||||
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
|
||||
End Sub
|
||||
End Class
|
||||
|
||||
End Namespace
|
||||
Reference in New Issue
Block a user