From 5658c233ee4ee760d95c286bdbc043359260ef6d Mon Sep 17 00:00:00 2001 From: Jonathan Jenne Date: Tue, 29 Jun 2021 11:22:19 +0200 Subject: [PATCH] EDMI: final changes to Client --- GUIs.ZooFlow/frmtest.vb | 8 ++------ Modules.EDMIAPI/Client.vb | 7 +++++-- Modules.EDMIAPI/Client/FileMeta.vb | 4 ++++ Modules.EDMIAPI/EDMI.API.vbproj | 1 + Service.EDMIService/EDMIService.vb | 5 +---- Service.EDMIService/GlobalState.vb | 6 ++++++ 6 files changed, 19 insertions(+), 12 deletions(-) create mode 100644 Modules.EDMIAPI/Client/FileMeta.vb diff --git a/GUIs.ZooFlow/frmtest.vb b/GUIs.ZooFlow/frmtest.vb index d92a8524..1d42098a 100644 --- a/GUIs.ZooFlow/frmtest.vb +++ b/GUIs.ZooFlow/frmtest.vb @@ -95,17 +95,13 @@ Public Class frmtest End Sub Private Async Sub Button8_Click(sender As Object, e As EventArgs) Handles Button8.Click - Dim oResult As Object - If OpenFileDialog1.ShowDialog() <> DialogResult.OK Then Exit Sub End If txtFile2Import.Text = OpenFileDialog1.FileName - - - oResult = Await My.Application.Service.Client.NewFileAsync( + Dim oResult As FileMeta = Await My.Application.Service.Client.NewFileAsync( txtFile2Import.Text, Environment.UserName, Date.Now, @@ -116,7 +112,7 @@ Public Class frmtest } ) - MsgBox($"File saved to: [{oResult}]") + MsgBox($"File saved to: [{oResult.FilePath}]") 'oResult = Await My.Application.Service.Client.ImportFileObjectAsync(oContents, My.Application.User.UserName, txtIDB_OBJ_ID.Text, 1, txtIDBFOPath.Text) End Sub diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb index 32bfaab7..18407700 100644 --- a/Modules.EDMIAPI/Client.vb +++ b/Modules.EDMIAPI/Client.vb @@ -104,7 +104,7 @@ Public Class Client ''' The ObjectId of the newly generated filesystem object ''' When local filepath was not found ''' When there was a error in the Service - Public Async Function NewFileAsync(pFilePath As String, pWho As String, pWhen As Date, pObjectStoreType As String, pBusinessEntity As String, ImportOptions As ImportFileOptions) As Task(Of Long) + Public Async Function NewFileAsync(pFilePath As String, pWho As String, pWhen As Date, pObjectStoreType As String, pBusinessEntity As String, ImportOptions As ImportFileOptions) As Task(Of FileMeta) Const oKindType = "DOC" Try @@ -156,7 +156,10 @@ Public Class Client End Using End Using - Return oObjectIdResponse.ObjectId + Return New FileMeta With { + .ObjectId = oObjectIdResponse.ObjectId, + .FilePath = oFilePathResponse.FileObjectPath + } Catch ex As Exception _logger.Error(ex) Return Nothing diff --git a/Modules.EDMIAPI/Client/FileMeta.vb b/Modules.EDMIAPI/Client/FileMeta.vb new file mode 100644 index 00000000..23bfdedd --- /dev/null +++ b/Modules.EDMIAPI/Client/FileMeta.vb @@ -0,0 +1,4 @@ +Public Class FileMeta + Public FilePath As String + Public ObjectId As String +End Class diff --git a/Modules.EDMIAPI/EDMI.API.vbproj b/Modules.EDMIAPI/EDMI.API.vbproj index 95b88971..95d7d127 100644 --- a/Modules.EDMIAPI/EDMI.API.vbproj +++ b/Modules.EDMIAPI/EDMI.API.vbproj @@ -81,6 +81,7 @@ + True diff --git a/Service.EDMIService/EDMIService.vb b/Service.EDMIService/EDMIService.vb index a5b14926..175ca994 100644 --- a/Service.EDMIService/EDMIService.vb +++ b/Service.EDMIService/EDMIService.vb @@ -581,10 +581,7 @@ Public Class EDMIService Public Function ImportFileIntoFileObject(Data As ImportFileIntoFileObjectRequest) As ImportFileIntoFileObjectResponse Implements IEDMIService.ImportFileIntoFileObject Try - Dim oObjectStore = GlobalState.ObjectStores. - Where(Function(o) o.Title = Data.ObjectStoreType). - FirstOrDefault() - + Dim oObjectStore = GlobalState.GetObjectStore(Data.ObjectStoreType) If oObjectStore Is Nothing Then Throw New KeyNotFoundException($"ObjectStore [{Data.ObjectStoreType}] was not found.") End If diff --git a/Service.EDMIService/GlobalState.vb b/Service.EDMIService/GlobalState.vb index 225e1ea0..8ab7b20a 100644 --- a/Service.EDMIService/GlobalState.vb +++ b/Service.EDMIService/GlobalState.vb @@ -43,6 +43,12 @@ Public Class GlobalState End Try End Sub + Public Function GetObjectStore(Name As String) As ObjectStore + Return ObjectStores. + Where(Function(o) o.Title.ToUpper = Name.ToUpper). + FirstOrDefault() + End Function + Class ObjectStore Public Id As Long Public Title As String