EDMI: changes in newfile and updatefile method
This commit is contained in:
@@ -138,26 +138,12 @@ Namespace IDB
|
||||
|
||||
Public Function GetFileObjectPath(pStore As GlobalState.ObjectStore, pDateImported As Date) As String
|
||||
' Get directory by DateImported or, if not supplied, by current date
|
||||
Dim oSubDirectory As String
|
||||
Dim oFinalPath As String
|
||||
If IsNothing(pDateImported) Then
|
||||
oSubDirectory = FileEx.CreateDateDirectory(Now)
|
||||
oFinalPath = FileEx.CreateDateDirectory(pStore.Path, Now)
|
||||
Else
|
||||
oSubDirectory = FileEx.CreateDateDirectory(pDateImported)
|
||||
oFinalPath = FileEx.CreateDateDirectory(pStore.Path, pDateImported)
|
||||
End If
|
||||
Logger.Debug("Subdirectory is [{0}]", oSubDirectory)
|
||||
|
||||
' Check and create final path, if necessary
|
||||
Dim oFinalPath = IO.Path.Combine(pStore.Path, oSubDirectory)
|
||||
If Not IO.Directory.Exists(oFinalPath) Then
|
||||
Try
|
||||
Logger.Debug("Path does not exist, creating: [{0}]", oFinalPath)
|
||||
IO.Directory.CreateDirectory(oFinalPath)
|
||||
Logger.Debug("Created folder [{0}]", oFinalPath)
|
||||
Catch ex As Exception
|
||||
LogAndThrow(ex, $"Store Directory [{oFinalPath}] could not be created!")
|
||||
End Try
|
||||
End If
|
||||
Logger.Debug("Final Directory is [{0}]", oFinalPath)
|
||||
|
||||
Return oFinalPath
|
||||
End Function
|
||||
|
||||
@@ -59,13 +59,15 @@ Namespace Methods.IDB.NewFile
|
||||
oFilePath = IO.Path.Combine(oFinalPath, oFileName)
|
||||
Dim oFileObjectInfo As IO.FileInfo = New IO.FileInfo(oFilePath)
|
||||
|
||||
Dim oFileObjectSize As Long = pData.File.FileContents.Length
|
||||
Dim oFileObjectName As String = oFileObjectInfo.Name
|
||||
Dim oOriginalExtension As String = pData.File.FileInfoRaw.Extension.Substring(1)
|
||||
|
||||
Logger.Debug("File Information for [{0}]:", oFileObjectName)
|
||||
|
||||
Dim oFileObjectSize As Long = pData.File.FileContents.Length
|
||||
Logger.Debug("Size: [{0}]", oFileObjectSize)
|
||||
|
||||
Dim oOriginalExtension As String = pData.File.FileInfoRaw.Extension.Substring(1)
|
||||
Logger.Debug("Original Extension: [{0}]", oOriginalExtension)
|
||||
|
||||
Logger.Debug("Checksum: [{0}]", pData.File.FileChecksum)
|
||||
|
||||
Try
|
||||
|
||||
@@ -29,6 +29,8 @@ Namespace Methods.IDB.UpdateFile
|
||||
'TODO: Create a view that collects all information about an idb object
|
||||
Dim oResultObjectId As Long
|
||||
|
||||
Logger.Debug("Creating new Version: [{0}]", pData.CreateNewVersion)
|
||||
|
||||
If pData.CreateNewVersion = False Then
|
||||
' ----------------------------------------------
|
||||
' -- Replace the existing file-object
|
||||
@@ -71,7 +73,12 @@ Namespace Methods.IDB.UpdateFile
|
||||
Dim oObjectRow As DataRow = oObjectTable.Rows.Item(0)
|
||||
Dim oKind As String = oObjectRow.Item("KIND_NAME")
|
||||
Dim oBusinessEntity As String = oObjectRow.Item("BE_NAME")
|
||||
Dim oStore As String = oObjectRow.ItemArray("STORE_NAME")
|
||||
Dim oStore As String = oObjectRow.Item("STORE_NAME")
|
||||
|
||||
Logger.Debug("Getting information for ObjectId [{0}]", pData.ObjectId)
|
||||
Logger.Debug("Kind: [{0}]", oKind)
|
||||
Logger.Debug("BE: [{0}]", oBusinessEntity)
|
||||
Logger.Debug("Store: [{0}]", oStore)
|
||||
|
||||
Dim oNewFileMethod As New NewFile.NewFileMethod(LogConfig, DatabaseIDB, DatabaseECM, GlobalState)
|
||||
Dim oNewFileRequest As New NewFile.NewFileRequest With {
|
||||
@@ -82,11 +89,17 @@ Namespace Methods.IDB.UpdateFile
|
||||
.User = pData.User
|
||||
}
|
||||
Dim oNewFileResponse = oNewFileMethod.Run(oNewFileRequest)
|
||||
Dim oNewObjectId = oNewFileResponse.ObjectId
|
||||
|
||||
If oNewFileResponse.OK = False Then
|
||||
LogAndThrow(oNewFileResponse.ErrorMessage)
|
||||
End If
|
||||
|
||||
Dim oNewObjectId As Long = oNewFileResponse.ObjectId
|
||||
Logger.Debug("New file Version has ObjectId [{0}]", oNewObjectId)
|
||||
|
||||
Dim oSql As String = $"EXEC PRIDB_NEW_VERSION_OBJECT '{pData.ObjectId}', '{oNewObjectId}', '{pData.User.UserName}'"
|
||||
DatabaseIDB.ExecuteNonQuery(oSql)
|
||||
|
||||
Logger.Debug("Versioning complete from [{0}] to [{1}]", pData.ObjectId, oNewObjectId)
|
||||
|
||||
oResultObjectId = oNewObjectId
|
||||
|
||||
@@ -97,7 +110,7 @@ Namespace Methods.IDB.UpdateFile
|
||||
|
||||
Return New UpdateFileResponse(oResultObjectId)
|
||||
Catch ex As Exception
|
||||
Logger.Warn("Error occurred while creating file!")
|
||||
Logger.Warn("Error occurred while updating file!")
|
||||
Logger.Error(ex)
|
||||
|
||||
Logger.Info("Rolling back transaction.")
|
||||
|
||||
Reference in New Issue
Block a user