EDMI: Client Server Changes to prepare for initial Release

This commit is contained in:
Jonathan Jenne
2021-11-30 16:09:51 +01:00
parent 706d6b0cef
commit 61a15d472b
23 changed files with 426 additions and 32 deletions

View File

@@ -21,8 +21,6 @@ Public Class NewFileMethod
End Sub
Public Function Run(pData As NewFile.NewFileRequest) As NewFile.NewFileResponse
Dim oConnection As SqlConnection = Nothing
Dim oTransaction As SqlTransaction = Nothing
Dim oFilePath As String = Nothing
Dim oExistingObjectId = TestFileChecksumExists(pData.FileChecksum)
@@ -68,7 +66,7 @@ Public Class NewFileMethod
IO.Directory.CreateDirectory(oFinalPath)
Logger.Debug("Created folder [{0}]", oFinalPath)
Catch ex As Exception
LogAndThrow(ex)
LogAndThrow(ex, $"Store Directory [{oFinalPath}] could not be created!")
End Try
End If
Logger.Debug("Final Directory is [{0}]", oFinalPath)
@@ -103,8 +101,7 @@ Public Class NewFileMethod
oStream.Close()
End Using
Catch ex As Exception
Logger.Error(ex)
LogAndThrow($"Could not write file [{oFilePath}] to disk!")
LogAndThrow(ex, $"Could not write file [{oFilePath}] to disk!")
End Try
'---------------------------------------------------------------------------
@@ -113,17 +110,44 @@ Public Class NewFileMethod
' Insert into DB
Dim oSQL As String = $"EXEC PRIDB_NEW_IDBFO '{oFinalPath}', '{oFileObjectName}', '{oFileObjectExtension}',{oFileObjectSize},'{pData.FileChecksum}' ,'{pData.Who}','{oObjectId}',{oStore.Id}"
Dim oResult As Boolean = Database.ExecuteNonQueryWithConnectionObject(oSQL,
oConnection,
MSSQLServer.TransactionMode.ExternalTransaction,
oTransaction)
Dim oResult As Boolean = Database.ExecuteNonQueryWithConnectionObject(oSQL, Connection, ExternalTransaction, Transaction)
If oResult = False Then
LogAndThrow("IDB FileObject could not be created!")
End If
'---------------------------------------------------------------------------
'TODO: File dates in try catch
Dim oDefaultAttributes As New Dictionary(Of String, Object) From {
{"OriginFileName", pData?.FileName},
{"OriginCreationDatetime", pData?.FileCreatedAt},
{"OriginChangedDatetime", pData?.FileChangedAt}
}
For Each oAttribute As KeyValuePair(Of String, Object) In oDefaultAttributes
Try
' Dont write empty attributes
If oAttribute.Value Is Nothing Then
Continue For
End If
Dim oSuccess = Helpers.SetAttributeValue(Connection, Transaction, oObjectId, oAttribute.Key, oAttribute.Value, "de-DE", pData.Who)
If oSuccess Then
Logger.Debug("Default Attribute [{0}] written with value [{1}]", oAttribute.Key, oAttribute.Value)
Else
Logger.Warn("Default attribute value could not be written")
End If
Catch ex As Exception
LogAndThrow(ex, $"System attribute [{oAttribute.Key}] could not be written!")
End Try
Next
'---------------------------------------------------------------------------
' Finally, commit the transaction
oTransaction?.Commit()
Transaction?.Commit()
Return New NewFile.NewFileResponse(oObjectId)
Catch ex As Exception
@@ -141,7 +165,7 @@ Public Class NewFileMethod
End If
Logger.Info("Rolling back transaction.")
oTransaction?.Rollback()
Transaction?.Rollback()
Return New NewFile.NewFileResponse(ex)