EDMI: Bring Service and Client up to date
This commit is contained in:
@@ -5,9 +5,12 @@ Imports System.ServiceModel
|
||||
Imports System.IO
|
||||
|
||||
Public Class Client
|
||||
Private Const INVALID_OBEJCT_ID As Long = 0
|
||||
Private Const KIND_TYPE_DOC = "DOC"
|
||||
|
||||
Private ReadOnly _logger As Logger
|
||||
Private ReadOnly _channelFactory As ChannelFactory(Of IEDMIServiceChannel)
|
||||
Private _IPAddressServer As String
|
||||
Private ReadOnly _IPAddressServer As String
|
||||
Private _channel As IEDMIServiceChannel
|
||||
|
||||
Public Class StreamedFile
|
||||
@@ -25,10 +28,10 @@ Public Class Client
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' Creates a new EDMIAPI object
|
||||
''' Creates a new EDMI Client object
|
||||
''' </summary>
|
||||
''' <param name="LogConfig">LogConfig object</param>
|
||||
''' <param name="ServiceAdress">The full service url to connect to</param>
|
||||
''' <param name="ServiceAdress">The full service url to connect to, for example: net.tcp://1.1.1.1:1111/some/path</param>
|
||||
Public Sub New(LogConfig As LogConfig, ServiceAdress As String)
|
||||
_logger = LogConfig.GetLogger()
|
||||
|
||||
@@ -43,6 +46,12 @@ Public Class Client
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
''' <summary>
|
||||
''' Creates a new EDMI Client object
|
||||
''' </summary>
|
||||
''' <param name="LogConfig">LogConfig object</param>
|
||||
''' <param name="IPAddress">The IP address to connect to</param>
|
||||
''' <param name="PortNumber">The Port number to use for the connection</param>
|
||||
Public Sub New(LogConfig As LogConfig, IPAddress As String, PortNumber As Integer)
|
||||
_logger = LogConfig.GetLogger()
|
||||
|
||||
@@ -79,34 +88,33 @@ Public Class Client
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Import options for NewFileAsync
|
||||
''' Import options for NewFileAsync. Contains default values for all options
|
||||
''' </summary>
|
||||
Public Class ImportFileOptions
|
||||
Public KeepExtension As Boolean
|
||||
Public KeepExtension As Boolean = True
|
||||
End Class
|
||||
|
||||
''' <summary>
|
||||
''' TODO: Platzhalter
|
||||
''' TODO: Creates a new object
|
||||
''' </summary>
|
||||
''' <returns></returns>
|
||||
Public Async Function NewObjectAsync() As Task
|
||||
Throw New NotImplementedException()
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Imports a file from a filepath, creating a IDB ObjectId and Filesystem Object
|
||||
''' </summary>
|
||||
''' <param name="pFilePath">Local filepath to a file.</param>
|
||||
''' <param name="pWho">Windows username of the user responsible for the import.</param>
|
||||
''' <param name="pWhen">Date when the file was imported. Can be in the past.</param>
|
||||
''' <param name="pAddedWho">Windows username of the user responsible for the import.</param>
|
||||
''' <param name="pAddedWhen">Date when the file was imported. Can be in the past.</param>
|
||||
''' <param name="pObjectStoreType">Type of ObjectStore. Can be WORK or ARCHIVE.</param>
|
||||
''' <param name="pBusinessEntity">Business entity that the new file object should belong to.</param>
|
||||
''' <param name="ImportOptions">Other file import options</param>
|
||||
''' <returns>The ObjectId of the newly generated filesystem object</returns>
|
||||
''' <param name="pImportOptions">Other file import options</param>
|
||||
''' <exception cref="FileNotFoundException">When local filepath was not found</exception>
|
||||
''' <exception cref="ApplicationException">When there was a error in the Service</exception>
|
||||
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"
|
||||
|
||||
''' <returns>The ObjectId of the newly generated filesystem object</returns>
|
||||
Public Async Function NewFileAsync(pFilePath As String, pAddedWho As String, pAddedWhen As Date, pObjectStoreType As String, pBusinessEntity As String, pImportOptions As ImportFileOptions) As Task(Of Long)
|
||||
Try
|
||||
If File.Exists(pFilePath) = False Then
|
||||
Throw New FileNotFoundException("ImportFileAsync: Path does not exist")
|
||||
@@ -117,8 +125,8 @@ Public Class Client
|
||||
|
||||
Dim oObjectIdResponse = Await _channel.NewObjectIdAsync(New NewObjectIdRequest With {
|
||||
.BusinessEntity = pBusinessEntity,
|
||||
.KindType = oKindType,
|
||||
.Who = pWho
|
||||
.KindType = KIND_TYPE_DOC,
|
||||
.Who = pAddedWho
|
||||
})
|
||||
|
||||
If oObjectIdResponse.ObjectId = Nothing OrElse oObjectIdResponse.ObjectId = 0 Then
|
||||
@@ -126,9 +134,9 @@ Public Class Client
|
||||
End If
|
||||
|
||||
Dim oFilePathResponse = Await _channel.NewFileObjectAsync(New NewFileObjectRequest With {
|
||||
.DateImported = pWhen,
|
||||
.DateImported = pAddedWhen,
|
||||
.Extension = oExtension,
|
||||
.KeepExtension = ImportOptions.KeepExtension,
|
||||
.KeepExtension = pImportOptions.KeepExtension,
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
.StoreType = pObjectStoreType
|
||||
})
|
||||
@@ -146,7 +154,7 @@ Public Class Client
|
||||
.FilePath = oFilePathResponse.FileObjectPath,
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
.ObjectStoreType = pObjectStoreType,
|
||||
.Who = pWho,
|
||||
.Who = pAddedWho,
|
||||
.Contents = oContents
|
||||
})
|
||||
|
||||
@@ -156,24 +164,20 @@ Public Class Client
|
||||
End Using
|
||||
End Using
|
||||
|
||||
Return New FileMeta With {
|
||||
.ObjectId = oObjectIdResponse.ObjectId,
|
||||
.FilePath = oFilePathResponse.FileObjectPath
|
||||
}
|
||||
Return oObjectIdResponse.ObjectId
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
Return Nothing
|
||||
Return INVALID_OBEJCT_ID
|
||||
End Try
|
||||
End Function
|
||||
|
||||
Public Function CreateObjectId(pKindType As String, pWho As String, pBusinessEntity As String) As Long
|
||||
Try
|
||||
Dim oArgs As New NewObjectIdRequest With {
|
||||
Dim oResponse = _channel.NewObjectId(New NewObjectIdRequest With {
|
||||
.KindType = pKindType,
|
||||
.BusinessEntity = pBusinessEntity,
|
||||
.Who = pWho
|
||||
}
|
||||
Dim oResponse = _channel.NewObjectId(oArgs)
|
||||
})
|
||||
Return oResponse.ObjectId
|
||||
Catch ex As Exception
|
||||
_logger.Error(ex)
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
Public Class FileMeta
|
||||
Public FilePath As String
|
||||
Public ObjectId As String
|
||||
End Class
|
||||
@@ -65,27 +65,29 @@ Public Class DataWithFallback
|
||||
End Function
|
||||
|
||||
Public Function GetUserData(UserName As String, ModuleCode As String, Client As Integer) As UserData
|
||||
Dim oSQL = $"SELECT * FROM FNDD_CHECK_USER_MODULE('{UserName}','{ModuleCode}',{Client})"
|
||||
Dim oTable As DataTable = GetDatatable("TBDD_USER_MODULE", $"USERNAME = '{UserName.ToLower}' AND MODULE_SHORT = '{ModuleCode}'", "", oSQL, DatabaseType.ECM)
|
||||
'Dim oSQL = $"SELECT * FROM FNDD_CHECK_USER_MODULE('{UserName}','{ModuleCode}',{Client})"
|
||||
'Dim oTable As DataTable = GetDatatable("TBDD_USER_MODULE", $"USERNAME = '{UserName.ToLower}' AND MODULE_SHORT = '{ModuleCode}'", "", oSQL, DatabaseType.ECM)
|
||||
|
||||
If oTable Is Nothing Then
|
||||
Return Nothing
|
||||
End If
|
||||
'If oTable Is Nothing Then
|
||||
' Return Nothing
|
||||
'End If
|
||||
|
||||
If oTable.Rows.Count = 0 Then
|
||||
Return Nothing
|
||||
End If
|
||||
'If oTable.Rows.Count = 0 Then
|
||||
' Return Nothing
|
||||
'End If
|
||||
|
||||
Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
Dim oUserData As New UserData With {
|
||||
.Id = NotNull(oRow, "USER_ID", -1),
|
||||
.Surname = NotNull(oRow, "USER_SURNAME", String.Empty),
|
||||
.Prename = NotNull(oRow, "USER_PRENAME", String.Empty),
|
||||
.Shortname = NotNull(oRow, "USER_SHORTNAME", String.Empty),
|
||||
.Email = NotNull(oRow, "USER_EMAIL", String.Empty),
|
||||
.Language = NotNull(oRow, "USER_LANGUAGE", "de-DE"),
|
||||
.DateFormat = NotNull(oRow, "USER_DATE_FORMAT", "dd.MM.yyyy")
|
||||
}
|
||||
'Dim oRow As DataRow = oTable.Rows.Item(0)
|
||||
'Dim oUserData As New UserData With {
|
||||
' .Id = NotNull(oRow, "USER_ID", -1),
|
||||
' .Surname = NotNull(oRow, "USER_SURNAME", String.Empty),
|
||||
' .Prename = NotNull(oRow, "USER_PRENAME", String.Empty),
|
||||
' .Shortname = NotNull(oRow, "USER_SHORTNAME", String.Empty),
|
||||
' .Email = NotNull(oRow, "USER_EMAIL", String.Empty),
|
||||
' .Language = NotNull(oRow, "USER_LANGUAGE", "de-DE"),
|
||||
' .DateFormat = NotNull(oRow, "USER_DATE_FORMAT", "dd.MM.yyyy")
|
||||
'}
|
||||
|
||||
Throw New NotImplementedException()
|
||||
End Function
|
||||
|
||||
End Class
|
||||
|
||||
@@ -81,7 +81,6 @@
|
||||
</Compile>
|
||||
<Compile Include="Client.vb" />
|
||||
<Compile Include="DataWithFallback.vb" />
|
||||
<Compile Include="Client\FileMeta.vb" />
|
||||
<Compile Include="My Project\AssemblyInfo.vb" />
|
||||
<Compile Include="My Project\Application.Designer.vb">
|
||||
<AutoGen>True</AutoGen>
|
||||
|
||||
Reference in New Issue
Block a user