diff --git a/GUIs.ZooFlow/frmtest.vb b/GUIs.ZooFlow/frmtest.vb index 618e7d6e..d82e116a 100644 --- a/GUIs.ZooFlow/frmtest.vb +++ b/GUIs.ZooFlow/frmtest.vb @@ -100,11 +100,7 @@ Public Class frmtest txtFile2Import.Text, "WORK", "DOC", - "DEFAULT", - New NewFileOptions With { - .Username = Environment.UserName, - .DateImported = DateTimePicker1.Value - } + "DEFAULT" ) If oObjectId <> INVALID_OBEJCT_ID Then diff --git a/Modules.EDMIAPI/Client.vb b/Modules.EDMIAPI/Client.vb index 828edb15..3cb18c88 100644 --- a/Modules.EDMIAPI/Client.vb +++ b/Modules.EDMIAPI/Client.vb @@ -17,7 +17,7 @@ Public Class Client Private _dummy_table_attributes As DataTable Private _channel As IEDMIServiceChannel - Private _FileEx As FileSystem.File + Private _FileEx As Filesystem.File ''' @@ -122,11 +122,11 @@ Public Class Client ''' When local filepath was not found ''' When there was a error in the Service ''' The ObjectId of the newly generated filesystem object - Public Async Function NewFileAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pBusinessEntity As String, Optional pImportOptions As NewFileOptions = Nothing) As Task(Of Long) + Public Async Function NewFileAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pBusinessEntity As String, Optional pImportOptions As Options.NewFileOptions = Nothing) As Task(Of Long) Try ' Set default options If pImportOptions Is Nothing Then - pImportOptions = New NewFileOptions() + pImportOptions = New Options.NewFileOptions() End If ' Check if file exists @@ -161,6 +161,7 @@ Public Class Client .KindType = pObjectKind, .StoreName = pObjectStoreName, .User = New UserState With { + .Language = pImportOptions.Language, .UserName = pImportOptions.Username } }) @@ -178,11 +179,11 @@ Public Class Client End Try End Function - Public Async Function ImportFileAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pBusinessEntity As String, Optional pImportOptions As NewFileOptions = Nothing) As Task(Of Long) + Public Async Function ImportFileAsync(pFilePath As String, pObjectStoreName As String, pObjectKind As String, pBusinessEntity As String, Optional pImportOptions As Options.NewFileOptions = Nothing) As Task(Of Long) Try ' Set default options If pImportOptions Is Nothing Then - pImportOptions = New NewFileOptions() + pImportOptions = New Options.NewFileOptions() End If ' Check if file exists @@ -217,8 +218,9 @@ Public Class Client }, .KindType = pObjectKind, .StoreName = pObjectStoreName, - .User = New UserState With { - .UserName = pImportOptions.Username + .User = New UserState() With { + .UserName = pImportOptions.Username, + .Language = pImportOptions.Language } }) If oFileImportResponse.OK = False Then @@ -242,18 +244,16 @@ Public Class Client ''' ''' ''' - Public Function SetVariableValue(pObjectId As Long, pAttributeName As String, pValue As Object, Optional pOptions As SetVariableValueOptions = Nothing) As Boolean + Public Function SetVariableValue(pObjectId As Long, pAttributeName As String, pValue As Object, Optional pOptions As Options.SetVariableValueOptions = Nothing) As Boolean Try ' Set default options If pOptions Is Nothing Then - pOptions = New SetVariableValueOptions() + pOptions = New Options.SetVariableValueOptions() End If - Dim oLanguage = GetUserLanguage(pOptions.UserLanguage) - Dim oUsername = GetUserName(pOptions.UserName) - Dim oOptions As New GetVariableValueOptions With { - .UserLanguage = oLanguage, - .UserName = oUsername + Dim oOptions As New Options.GetVariableValueOptions With { + .Language = pOptions.Language, + .Username = pOptions.Username } Try @@ -331,9 +331,9 @@ Public Class Client End If For Each oNewValueRow As DataRow In oValueTable.Rows - Dim oResult As Boolean = NewObjectData(pObjectId, pAttributeName, pValue, New NewObjectOptions With { - .UserLanguage = oLanguage, - .UserName = oUsername + Dim oResult As Boolean = NewObjectData(pObjectId, pAttributeName, pValue, New Options.NewObjectOptions With { + .Language = pOptions.Language, + .Username = pOptions.Username }) If oResult = False Then @@ -342,9 +342,9 @@ Public Class Client Next Return True Else - Return NewObjectData(pObjectId, pAttributeName, pValue, New NewObjectOptions With { - .UserLanguage = oLanguage, - .UserName = oUsername + Return NewObjectData(pObjectId, pAttributeName, pValue, New Options.NewObjectOptions With { + .Language = pOptions.Language, + .Username = pOptions.Username }) End If @@ -361,14 +361,11 @@ Public Class Client ''' ''' ''' - Public Function GetVariableValue(pObjectId As Long, pAttributeName As String, Optional pOptions As GetVariableValueOptions = Nothing) As VariableValue + Public Function GetVariableValue(pObjectId As Long, pAttributeName As String, Optional pOptions As Options.GetVariableValueOptions = Nothing) As VariableValue If pOptions Is Nothing Then - pOptions = New GetVariableValueOptions() + pOptions = New Options.GetVariableValueOptions() End If - pOptions.UserLanguage = GetUserLanguage(pOptions.UserLanguage) - pOptions.UserName = GetUserName(pOptions.UserName) - ' Check if ObjectId exists Try Dim oResponse = _channel.TestObjectIdExists(New TestObjectIdExistsRequest With {.ObjectId = pObjectId}) @@ -385,7 +382,7 @@ Public Class Client Try ' Get Attributes and Values from Database - Dim oAttributes As List(Of ObjectAttribute) = GetAttributesForObject(pObjectId, pOptions.UserLanguage) + Dim oAttributes As List(Of ObjectAttribute) = GetAttributesForObject(pObjectId, pOptions.Language) If oAttributes Is Nothing Then Return New VariableValue() @@ -498,13 +495,13 @@ Public Class Client End Try End Function - Private Function NewObjectData(pObjectId As Long, pAttributeName As String, pValue As Object, pOptions As NewObjectOptions) + Private Function NewObjectData(pObjectId As Long, pAttributeName As String, pValue As Object, pOptions As Options.NewObjectOptions) If pOptions Is Nothing Then - pOptions = New NewObjectOptions() + pOptions = New Options.NewObjectOptions() End If - Dim oLanguage = GetUserLanguage(pOptions.UserLanguage) - Dim oUsername = GetUserName(pOptions.UserName) + Dim oLanguage = GetUserLanguage(pOptions.Language) + Dim oUsername = GetUserName(pOptions.Username) Dim oSql = $"DECLARE @NEW_OBJ_MD_ID BIGINT EXEC PRIDB_NEW_OBJ_DATA({pObjectId}, '{pAttributeName}', '{oUsername}', '{pValue}', '{oLanguage}', 0, @OMD_ID = @NEW_OBJ_MD_ID OUTPUT)" @@ -692,39 +689,6 @@ Public Class Client End Function -#Region "Option & Parameter Classes" - ''' - ''' Import options for NewFileAsync. - ''' - Public Class NewFileOptions - ''' - ''' Windows username of the user responsible for the import. Defaults to the currently logged in user. - ''' - Public Property Username As String = Environment.UserName - ''' - ''' Date when the file was imported. Can be in the past. Defaults to now. - ''' - Public Property DateImported As Date = Date.Now - End Class - - Public Class NewObjectOptions - Public UserName As String - Public UserLanguage As String - End Class - - Public Class VariableValueOptions - Public UserName As String - Public UserLanguage As String - End Class - - Public Class GetVariableValueOptions - Inherits VariableValueOptions - End Class - - Public Class SetVariableValueOptions - Inherits VariableValueOptions - End Class -#End Region #Region "Response Classes" Public Class StreamedFile diff --git a/Modules.EDMIAPI/Client/Options.vb b/Modules.EDMIAPI/Client/Options.vb new file mode 100644 index 00000000..688e3725 --- /dev/null +++ b/Modules.EDMIAPI/Client/Options.vb @@ -0,0 +1,39 @@ +Public Class Options + + Public MustInherit Class BaseOptions + ''' + ''' Windows username of the user responsible for the request. Defaults to the currently logged in user. + ''' + Public Property Username As String = Environment.UserName + + ''' + ''' Language code of the client responsible for the request. Defaults to the language of the current client. + ''' + ''' + Public Property Language As String = Threading.Thread.CurrentThread.CurrentUICulture.Name + End Class + + ''' + ''' Import options for NewFileAsync. + ''' + Public Class NewFileOptions + Inherits BaseOptions + + ''' + ''' Date when the file was imported. Can be in the past. Defaults to now. + ''' + Public Property DateImported As Date = Date.Now + End Class + + Public Class GetVariableValueOptions + Inherits BaseOptions + End Class + + Public Class SetVariableValueOptions + Inherits BaseOptions + End Class + + Public Class NewObjectOptions + Inherits BaseOptions + End Class +End Class \ No newline at end of file diff --git a/Modules.EDMIAPI/EDMI.API.vbproj b/Modules.EDMIAPI/EDMI.API.vbproj index 5fad9be9..d5ef560c 100644 --- a/Modules.EDMIAPI/EDMI.API.vbproj +++ b/Modules.EDMIAPI/EDMI.API.vbproj @@ -73,6 +73,7 @@ +