EDMI: Update Service and Client to Use Messages for EDMI Methods
This commit is contained in:
@@ -33,6 +33,8 @@ Public Class EDMIService
|
||||
_username = oUsername
|
||||
_logger = LogConfig.GetLogger()
|
||||
_logger.Debug("New Request by User [{0}]", _username)
|
||||
|
||||
|
||||
End Sub
|
||||
|
||||
Public Function StripDomainFromUsername(UserName As String)
|
||||
@@ -313,16 +315,14 @@ Public Class EDMIService
|
||||
''' <summary>
|
||||
''' Imports a file according to ObjectStoreId
|
||||
''' </summary>
|
||||
''' <param name="FileName"></param>
|
||||
''' <param name="Contents"></param>
|
||||
''' <returns></returns>
|
||||
Public Function ImportFile(FileName As String, Contents() As Byte, ObjectStoreId As Int64, DocumentType As String, Optional RetentionDays As Int64 = Nothing) As DocumentResult Implements IEDMIService.ImportFile
|
||||
Public Function ImportFile(Data As Messages.DocumentImportRequest) As Messages.DocumentImportResponse Implements IEDMIService.ImportFile
|
||||
Dim oObjectStore = GlobalState.ObjectStores.
|
||||
Where(Function(s) s.Id = ObjectStoreId).
|
||||
Where(Function(s) s.Id = Data.ObjectStoreId).
|
||||
FirstOrDefault()
|
||||
|
||||
If oObjectStore Is Nothing Then
|
||||
Return New DocumentResult($"Object Store with Id [{ObjectStoreId}] does not exist!")
|
||||
Throw New FaultException($"Object Store with Id [{Data.ObjectStoreId}] does not exist!")
|
||||
End If
|
||||
|
||||
Dim EDMIPath = New EDMI.File.Path(LogConfig, oObjectStore.Path)
|
||||
@@ -335,24 +335,23 @@ Public Class EDMIService
|
||||
' and return ObjectStore Path from ObjectStoreId + RelativePath
|
||||
' VWIDB_OBJECTSTORE
|
||||
|
||||
Dim oRelativePath As String = EDMIPath.GetRelativePath(DocumentType, FileName)
|
||||
Dim oAbsolutePath As String = EDMIPath.GetFullPath(DocumentType, FileName)
|
||||
Dim oDirectoryPath = EDMIPath.GetFullPath(DocumentType)
|
||||
Dim oDocument = New DocumentResult.DocumentObject With {.FileName = FileName}
|
||||
Dim oRelativePath As String = EDMIPath.GetRelativePath(Data.DocumentType, Data.FileName)
|
||||
Dim oAbsolutePath As String = EDMIPath.GetFullPath(Data.DocumentType, Data.FileName)
|
||||
Dim oDirectoryPath = EDMIPath.GetFullPath(Data.DocumentType)
|
||||
|
||||
Try
|
||||
Directory.CreateDirectory(oDirectoryPath)
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult(ex.Message)
|
||||
Throw New FaultException(ex.Message)
|
||||
End Try
|
||||
|
||||
Try
|
||||
Dim oVersionedFileName As String = Filesystem.GetVersionedFilename(oAbsolutePath)
|
||||
|
||||
_logger.Info("ImportFile: Saving file [{0}] to path [{1}]", FileName, oVersionedFileName)
|
||||
_logger.Info("ImportFile: Saving file [{0}] to path [{1}]", Data.FileName, oVersionedFileName)
|
||||
Using oStream = New FileStream(oVersionedFileName, FileMode.CreateNew)
|
||||
oStream.Write(Contents, 0, Contents.Length)
|
||||
oStream.Write(Data.Contents, 0, Data.Contents.Length)
|
||||
oStream.Flush(True)
|
||||
oStream.Close()
|
||||
End Using
|
||||
@@ -367,12 +366,10 @@ Public Class EDMIService
|
||||
|
||||
Dim oObjectId = MSSQL.GetScalarValue(oCommand, "@IDB_OBJ_ID")
|
||||
|
||||
oDocument.FileId = oObjectId
|
||||
|
||||
Return New DocumentResult(oDocument)
|
||||
Return New Messages.DocumentImportResponse() With {.ObjectId = oObjectId}
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return New DocumentResult(ex.Message)
|
||||
Throw New FaultException(ex.Message)
|
||||
End Try
|
||||
End Function
|
||||
|
||||
@@ -427,7 +424,7 @@ Public Class EDMIService
|
||||
|
||||
Public Function ListFilesForUser() As Messages.DocumentListResponse Implements IEDMIService.ListFilesForUser
|
||||
Try
|
||||
Dim oSQL = $"SELECT * FROM VWIDB_DOC_DATA WHERE ADDED_WHO = UPPER('{_username}')"
|
||||
Dim oSQL = $"SELECT * FROM VWIDB_DOC_DATA"
|
||||
Dim oDatatable As DataTable = MSSQL.GetDatatable(oSQL)
|
||||
oDatatable.TableName = "DocumentList"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user