EDMI: Update Service and Client to Use Messages for EDMI Methods
This commit is contained in:
@@ -4,22 +4,19 @@ Imports DigitalData.Modules.EDMI.API
|
||||
Imports DevExpress.XtraEditors
|
||||
Imports DevExpress.XtraEditors.Controls
|
||||
Imports System.IO
|
||||
Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
|
||||
|
||||
Public Class Form1
|
||||
Private _Channel As EDMIServiceReference.IEDMIServiceChannel
|
||||
Private _LogConfig As LogConfig
|
||||
Private _Logger As Logger
|
||||
Private _Client As Client
|
||||
|
||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
Try
|
||||
_LogConfig = New LogConfig(LogConfig.PathType.Temp, Nothing, "EDMIBenschmark")
|
||||
_Logger = _LogConfig.GetLogger()
|
||||
|
||||
Dim oChannelFactory As New ChannelFactory(Of EDMIServiceReference.IEDMIServiceChannel)(
|
||||
Channel.GetBinding(TcpClientCredentialType.Windows),
|
||||
"net.tcp://172.24.12.39:9000/DigitalData/Services/Main")
|
||||
_Channel = oChannelFactory.CreateChannel()
|
||||
_Channel.Open()
|
||||
_Client = New Client(_LogConfig, "net.tcp://172.24.12.39:9000/DigitalData/Services/Main")
|
||||
_Client.Connect()
|
||||
|
||||
DocumentViewer1.Init(_LogConfig, "21182889975216572111813147150675976632")
|
||||
Catch ex As Exception
|
||||
@@ -61,18 +58,8 @@ Public Class Form1
|
||||
|
||||
AddLogMessage($"Importing {oFileInfo.Name}... ({FormatBytes(oFileInfo.Length)})")
|
||||
|
||||
Dim oContents As Byte() = New Byte(oFileInfo.Length) {}
|
||||
|
||||
Using oStream As New FileStream(oFileName, FileMode.Open)
|
||||
Await oStream.ReadAsync(oContents, 0, oFileInfo.Length)
|
||||
End Using
|
||||
|
||||
Dim oResult As EDMIServiceReference.DocumentResult = Await _Channel.ImportFileAsync(oFileInfo.Name, oContents, 1, "WichtigesDokument", 0)
|
||||
If oResult.OK Then
|
||||
AddLogMessage($"File [{oFileInfo.Name}] with Id [{oResult.Document.FileId}] imported!")
|
||||
Else
|
||||
AddLogMessage($"Import Error: {oResult.ErrorMessage}")
|
||||
End If
|
||||
Dim oObjectId As Long = Await _Client.ImportFileAsync(oFileInfo.Name, "WichtigesDokument", 1, 0)
|
||||
AddLogMessage($"File with Id [{oObjectId}] imported!")
|
||||
oSW.Stop()
|
||||
AddLogMessage($"Import Time: {FormatTime(oSW.ElapsedMilliseconds)}")
|
||||
AddLogMessage("")
|
||||
@@ -135,18 +122,14 @@ Public Class Form1
|
||||
Dim oSWTotal As New Stopwatch()
|
||||
oSWTotal.Start()
|
||||
|
||||
If TextboxObejctId.EditValue = "" Then
|
||||
If TextboxObjectId.EditValue = "" Then
|
||||
MsgBox("Please enter an object id!", MsgBoxStyle.Exclamation, "Uh oh!")
|
||||
End If
|
||||
|
||||
Dim oObjectId As Integer = TextboxObejctId.EditValue
|
||||
Dim oObjectId As Integer = TextboxObjectId.EditValue
|
||||
Dim oResponse As Client.StreamedFile = Await _Client.GetFileByObjectIdAsync(oObjectId)
|
||||
|
||||
Dim oResponse = Await _Channel.GetFileByObjectIdAsync(New EDMIServiceReference.DocumentStreamRequest() With {.ObjectId = oObjectId})
|
||||
Dim oMemoryStream As New MemoryStream()
|
||||
oResponse.FileContents.CopyTo(oMemoryStream)
|
||||
oMemoryStream.Position = 0
|
||||
|
||||
DocumentViewer1.LoadFile(oResponse.FileName, oMemoryStream)
|
||||
DocumentViewer1.LoadFile(oResponse.FileName, oResponse.Stream)
|
||||
|
||||
oSWTotal.Stop()
|
||||
AddLogMessage($"File [{oResponse.FileName}] loaded: [{FormatTime(oSWTotal.ElapsedMilliseconds)}]")
|
||||
@@ -159,7 +142,7 @@ Public Class Form1
|
||||
|
||||
Private Async Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
|
||||
Try
|
||||
Dim oResult = Await _Channel.ListFilesForUserAsync()
|
||||
Dim oResult As Client.FileList = Await _Client.ListFilesForUserAsync()
|
||||
BindingSource1.DataSource = oResult.Datatable
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, "Uh oh!")
|
||||
@@ -177,13 +160,10 @@ Public Class Form1
|
||||
Dim oSWTotal As New Stopwatch()
|
||||
oSWTotal.Start()
|
||||
|
||||
Dim oObjectId As Int64 = oRow.Item("IDB_OBJ_ID")
|
||||
Dim oResponse = Await _Channel.GetFileByObjectIdAsync(New EDMIServiceReference.DocumentStreamRequest() With {.ObjectId = oObjectId})
|
||||
Dim oMemoryStream As New MemoryStream()
|
||||
oResponse.FileContents.CopyTo(oMemoryStream)
|
||||
oMemoryStream.Position = 0
|
||||
Dim oObjectId As Long = oRow.Item("IDB_OBJ_ID")
|
||||
Dim oResponse As Client.StreamedFile = Await _Client.GetFileByObjectIdAsync(oObjectId)
|
||||
|
||||
DocumentViewer1.LoadFile(oResponse.FileName, oMemoryStream)
|
||||
DocumentViewer1.LoadFile(oResponse.FileName, oResponse.Stream)
|
||||
|
||||
oSWTotal.Stop()
|
||||
AddLogMessage($"File [{oResponse.FileName}] loaded: [{FormatTime(oSWTotal.ElapsedMilliseconds)}]")
|
||||
@@ -199,14 +179,11 @@ Public Class Form1
|
||||
Dim oSWTotal As New Stopwatch()
|
||||
oSWTotal.Start()
|
||||
|
||||
Dim oObjectId As Integer = TextboxObejctId.EditValue
|
||||
Dim oObjectId As Integer = TextboxObjectId.EditValue
|
||||
|
||||
Dim oResponse = Await _Channel.GetFileByObjectIdAsync(New EDMIServiceReference.DocumentStreamRequest() With {.ObjectId = oObjectId})
|
||||
Dim oMemoryStream As New MemoryStream()
|
||||
oResponse.FileContents.CopyTo(oMemoryStream)
|
||||
oMemoryStream.Position = 0
|
||||
Dim oResponse As Client.StreamedFile = Await _Client.GetFileByObjectIdAsync(oObjectId)
|
||||
|
||||
DocumentViewer1.LoadFile(oResponse.FileName, oMemoryStream)
|
||||
DocumentViewer1.LoadFile(oResponse.FileName, oResponse.Stream)
|
||||
|
||||
oSWTotal.Stop()
|
||||
AddLogMessage($"File [{oResponse.FileName}] loaded: [{FormatTime(oSWTotal.ElapsedMilliseconds)}]")
|
||||
@@ -217,7 +194,7 @@ Public Class Form1
|
||||
|
||||
Private Sub BarToggleSwitchItem1_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarToggleSwitchItem1.CheckedChanged
|
||||
If BarToggleSwitchItem1.Checked Then
|
||||
If TextboxObejctId.EditValue = "" Then
|
||||
If TextboxObjectId.EditValue = "" Then
|
||||
Timer1.Stop()
|
||||
MsgBox("Please set a ObjectId!", MsgBoxStyle.Critical, Text)
|
||||
Else
|
||||
|
||||
Reference in New Issue
Block a user