EDMIAPI: Adjust client to new service methods
This commit is contained in:
parent
785b138c57
commit
f95e058121
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
''' <summary>
|
||||
@ -122,11 +122,11 @@ Public Class Client
|
||||
''' <exception cref="FileNotFoundException">When local filepath was not found</exception>
|
||||
''' <exception cref="ApplicationException">When there was a error in the Service</exception>
|
||||
''' <returns>The ObjectId of the newly generated filesystem object</returns>
|
||||
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
|
||||
''' <param name="pValue"></param>
|
||||
''' <param name="pOptions"></param>
|
||||
''' <returns></returns>
|
||||
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
|
||||
''' <param name="pAttributeName"></param>
|
||||
''' <param name="pOptions"></param>
|
||||
''' <returns></returns>
|
||||
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"
|
||||
''' <summary>
|
||||
''' Import options for NewFileAsync.
|
||||
''' </summary>
|
||||
Public Class NewFileOptions
|
||||
''' <summary>
|
||||
''' Windows username of the user responsible for the import. Defaults to the currently logged in user.
|
||||
''' </summary>
|
||||
Public Property Username As String = Environment.UserName
|
||||
''' <summary>
|
||||
''' Date when the file was imported. Can be in the past. Defaults to now.
|
||||
''' </summary>
|
||||
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
|
||||
|
||||
39
Modules.EDMIAPI/Client/Options.vb
Normal file
39
Modules.EDMIAPI/Client/Options.vb
Normal file
@ -0,0 +1,39 @@
|
||||
Public Class Options
|
||||
|
||||
Public MustInherit Class BaseOptions
|
||||
''' <summary>
|
||||
''' Windows username of the user responsible for the request. Defaults to the currently logged in user.
|
||||
''' </summary>
|
||||
Public Property Username As String = Environment.UserName
|
||||
|
||||
''' <summary>
|
||||
''' Language code of the client responsible for the request. Defaults to the language of the current client.
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Property Language As String = Threading.Thread.CurrentThread.CurrentUICulture.Name
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' Import options for NewFileAsync.
|
||||
''' </summary>
|
||||
Public Class NewFileOptions
|
||||
Inherits BaseOptions
|
||||
|
||||
''' <summary>
|
||||
''' Date when the file was imported. Can be in the past. Defaults to now.
|
||||
''' </summary>
|
||||
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
|
||||
@ -73,6 +73,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Client\NewFile.vb" />
|
||||
<Compile Include="Client\Options.vb" />
|
||||
<Compile Include="Client\Rights.vb" />
|
||||
<Compile Include="Client\Channel.vb" />
|
||||
<Compile Include="Connected Services\EDMIServiceReference\Reference.vb">
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user