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,
|
txtFile2Import.Text,
|
||||||
"WORK",
|
"WORK",
|
||||||
"DOC",
|
"DOC",
|
||||||
"DEFAULT",
|
"DEFAULT"
|
||||||
New NewFileOptions With {
|
|
||||||
.Username = Environment.UserName,
|
|
||||||
.DateImported = DateTimePicker1.Value
|
|
||||||
}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
If oObjectId <> INVALID_OBEJCT_ID Then
|
If oObjectId <> INVALID_OBEJCT_ID Then
|
||||||
|
|||||||
@ -17,7 +17,7 @@ Public Class Client
|
|||||||
|
|
||||||
Private _dummy_table_attributes As DataTable
|
Private _dummy_table_attributes As DataTable
|
||||||
Private _channel As IEDMIServiceChannel
|
Private _channel As IEDMIServiceChannel
|
||||||
Private _FileEx As FileSystem.File
|
Private _FileEx As Filesystem.File
|
||||||
|
|
||||||
|
|
||||||
''' <summary>
|
''' <summary>
|
||||||
@ -122,11 +122,11 @@ Public Class Client
|
|||||||
''' <exception cref="FileNotFoundException">When local filepath was not found</exception>
|
''' <exception cref="FileNotFoundException">When local filepath was not found</exception>
|
||||||
''' <exception cref="ApplicationException">When there was a error in the Service</exception>
|
''' <exception cref="ApplicationException">When there was a error in the Service</exception>
|
||||||
''' <returns>The ObjectId of the newly generated filesystem object</returns>
|
''' <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
|
Try
|
||||||
' Set default options
|
' Set default options
|
||||||
If pImportOptions Is Nothing Then
|
If pImportOptions Is Nothing Then
|
||||||
pImportOptions = New NewFileOptions()
|
pImportOptions = New Options.NewFileOptions()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Check if file exists
|
' Check if file exists
|
||||||
@ -161,6 +161,7 @@ Public Class Client
|
|||||||
.KindType = pObjectKind,
|
.KindType = pObjectKind,
|
||||||
.StoreName = pObjectStoreName,
|
.StoreName = pObjectStoreName,
|
||||||
.User = New UserState With {
|
.User = New UserState With {
|
||||||
|
.Language = pImportOptions.Language,
|
||||||
.UserName = pImportOptions.Username
|
.UserName = pImportOptions.Username
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -178,11 +179,11 @@ Public Class Client
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
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
|
Try
|
||||||
' Set default options
|
' Set default options
|
||||||
If pImportOptions Is Nothing Then
|
If pImportOptions Is Nothing Then
|
||||||
pImportOptions = New NewFileOptions()
|
pImportOptions = New Options.NewFileOptions()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
' Check if file exists
|
' Check if file exists
|
||||||
@ -217,8 +218,9 @@ Public Class Client
|
|||||||
},
|
},
|
||||||
.KindType = pObjectKind,
|
.KindType = pObjectKind,
|
||||||
.StoreName = pObjectStoreName,
|
.StoreName = pObjectStoreName,
|
||||||
.User = New UserState With {
|
.User = New UserState() With {
|
||||||
.UserName = pImportOptions.Username
|
.UserName = pImportOptions.Username,
|
||||||
|
.Language = pImportOptions.Language
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
If oFileImportResponse.OK = False Then
|
If oFileImportResponse.OK = False Then
|
||||||
@ -242,18 +244,16 @@ Public Class Client
|
|||||||
''' <param name="pValue"></param>
|
''' <param name="pValue"></param>
|
||||||
''' <param name="pOptions"></param>
|
''' <param name="pOptions"></param>
|
||||||
''' <returns></returns>
|
''' <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
|
Try
|
||||||
' Set default options
|
' Set default options
|
||||||
If pOptions Is Nothing Then
|
If pOptions Is Nothing Then
|
||||||
pOptions = New SetVariableValueOptions()
|
pOptions = New Options.SetVariableValueOptions()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oLanguage = GetUserLanguage(pOptions.UserLanguage)
|
Dim oOptions As New Options.GetVariableValueOptions With {
|
||||||
Dim oUsername = GetUserName(pOptions.UserName)
|
.Language = pOptions.Language,
|
||||||
Dim oOptions As New GetVariableValueOptions With {
|
.Username = pOptions.Username
|
||||||
.UserLanguage = oLanguage,
|
|
||||||
.UserName = oUsername
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Try
|
Try
|
||||||
@ -331,9 +331,9 @@ Public Class Client
|
|||||||
End If
|
End If
|
||||||
|
|
||||||
For Each oNewValueRow As DataRow In oValueTable.Rows
|
For Each oNewValueRow As DataRow In oValueTable.Rows
|
||||||
Dim oResult As Boolean = NewObjectData(pObjectId, pAttributeName, pValue, New NewObjectOptions With {
|
Dim oResult As Boolean = NewObjectData(pObjectId, pAttributeName, pValue, New Options.NewObjectOptions With {
|
||||||
.UserLanguage = oLanguage,
|
.Language = pOptions.Language,
|
||||||
.UserName = oUsername
|
.Username = pOptions.Username
|
||||||
})
|
})
|
||||||
|
|
||||||
If oResult = False Then
|
If oResult = False Then
|
||||||
@ -342,9 +342,9 @@ Public Class Client
|
|||||||
Next
|
Next
|
||||||
Return True
|
Return True
|
||||||
Else
|
Else
|
||||||
Return NewObjectData(pObjectId, pAttributeName, pValue, New NewObjectOptions With {
|
Return NewObjectData(pObjectId, pAttributeName, pValue, New Options.NewObjectOptions With {
|
||||||
.UserLanguage = oLanguage,
|
.Language = pOptions.Language,
|
||||||
.UserName = oUsername
|
.Username = pOptions.Username
|
||||||
})
|
})
|
||||||
End If
|
End If
|
||||||
|
|
||||||
@ -361,14 +361,11 @@ Public Class Client
|
|||||||
''' <param name="pAttributeName"></param>
|
''' <param name="pAttributeName"></param>
|
||||||
''' <param name="pOptions"></param>
|
''' <param name="pOptions"></param>
|
||||||
''' <returns></returns>
|
''' <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
|
If pOptions Is Nothing Then
|
||||||
pOptions = New GetVariableValueOptions()
|
pOptions = New Options.GetVariableValueOptions()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
pOptions.UserLanguage = GetUserLanguage(pOptions.UserLanguage)
|
|
||||||
pOptions.UserName = GetUserName(pOptions.UserName)
|
|
||||||
|
|
||||||
' Check if ObjectId exists
|
' Check if ObjectId exists
|
||||||
Try
|
Try
|
||||||
Dim oResponse = _channel.TestObjectIdExists(New TestObjectIdExistsRequest With {.ObjectId = pObjectId})
|
Dim oResponse = _channel.TestObjectIdExists(New TestObjectIdExistsRequest With {.ObjectId = pObjectId})
|
||||||
@ -385,7 +382,7 @@ Public Class Client
|
|||||||
|
|
||||||
Try
|
Try
|
||||||
' Get Attributes and Values from Database
|
' 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
|
If oAttributes Is Nothing Then
|
||||||
Return New VariableValue()
|
Return New VariableValue()
|
||||||
@ -498,13 +495,13 @@ Public Class Client
|
|||||||
End Try
|
End Try
|
||||||
End Function
|
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
|
If pOptions Is Nothing Then
|
||||||
pOptions = New NewObjectOptions()
|
pOptions = New Options.NewObjectOptions()
|
||||||
End If
|
End If
|
||||||
|
|
||||||
Dim oLanguage = GetUserLanguage(pOptions.UserLanguage)
|
Dim oLanguage = GetUserLanguage(pOptions.Language)
|
||||||
Dim oUsername = GetUserName(pOptions.UserName)
|
Dim oUsername = GetUserName(pOptions.Username)
|
||||||
|
|
||||||
Dim oSql = $"DECLARE @NEW_OBJ_MD_ID BIGINT
|
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)"
|
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
|
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"
|
#Region "Response Classes"
|
||||||
Public Class StreamedFile
|
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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Client\NewFile.vb" />
|
<Compile Include="Client\NewFile.vb" />
|
||||||
|
<Compile Include="Client\Options.vb" />
|
||||||
<Compile Include="Client\Rights.vb" />
|
<Compile Include="Client\Rights.vb" />
|
||||||
<Compile Include="Client\Channel.vb" />
|
<Compile Include="Client\Channel.vb" />
|
||||||
<Compile Include="Connected Services\EDMIServiceReference\Reference.vb">
|
<Compile Include="Connected Services\EDMIServiceReference\Reference.vb">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user