EDMI: Add Testing to EDMIBenchmark, Add ListFiles to EDMIService

This commit is contained in:
Jonathan Jenne
2020-04-16 13:38:01 +02:00
parent 6ee7bd07a3
commit 9095c0cd07
16 changed files with 697 additions and 116 deletions

View File

@@ -19,6 +19,11 @@ Public Class Form1
DocumentViewer1.Init(oLogConfig, "21182889975216572111813147150675976632")
End Sub
Private Sub AddLogMessage(Message As String)
listboxLog.Items.Add(Message)
listboxLog.MakeItemVisible(listboxLog.Items.Count - 1)
End Sub
Private Sub ButtonSelectFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles ButtonSelectFiles.ItemClick
Dim oDialog As New OpenFileDialog() With {
.Multiselect = True,
@@ -44,7 +49,7 @@ Public Class Form1
Dim oFileName As String = oItem
Dim oFileInfo As New FileInfo(oFileName)
listboxLog.Items.Add($"Importing {oFileInfo.Name}... ({FormatBytes(oFileInfo.Length)})")
AddLogMessage($"Importing {oFileInfo.Name}... ({FormatBytes(oFileInfo.Length)})")
Dim oContents As Byte() = New Byte(oFileInfo.Length) {}
@@ -54,18 +59,17 @@ Public Class Form1
Dim oResult As EDMIServiceReference.DocumentResult = Await _Channel.ImportFileAsync(oFileInfo.Name, oContents, Environment.UserName)
If oResult.OK Then
listboxLog.Items.Add($"File [{oFileInfo.Name}] with Id [{oResult.Document.FileId}] imported!")
AddLogMessage($"File [{oFileInfo.Name}] with Id [{oResult.Document.FileId}] imported!")
Else
listboxLog.Items.Add($"Import Error: {oResult.ErrorMessage}")
AddLogMessage($"Import Error: {oResult.ErrorMessage}")
End If
oSW.Stop()
listboxLog.Items.Add($"Import Time: {FormatTime(oSW.ElapsedMilliseconds)}")
listboxLog.Items.Add("")
AddLogMessage($"Import Time: {FormatTime(oSW.ElapsedMilliseconds)}")
AddLogMessage("")
Next
oSWTotal.Stop()
listboxLog.Items.Add($"Total Time: {FormatTime(oSWTotal.ElapsedMilliseconds)}")
listboxLog.MakeItemVisible(listboxLog.Items.Count - 1)
AddLogMessage($"Total Time: {FormatTime(oSWTotal.ElapsedMilliseconds)}")
End Sub
Private Sub buttonClearLog_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles buttonClearLog.ItemClick
@@ -132,11 +136,84 @@ Public Class Form1
DocumentViewer1.LoadFile(oResponse.FileName, oMemoryStream)
oSWTotal.Stop()
listboxLog.Items.Add($"File [{oResponse.FileName}] loaded: [{FormatTime(oSWTotal.ElapsedMilliseconds)}]")
AddLogMessage($"File [{oResponse.FileName}] loaded: [{FormatTime(oSWTotal.ElapsedMilliseconds)}]")
Catch ex As FaultException
MsgBox(ex.Reason.ToString, MsgBoxStyle.Critical, "Error from Service")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Uh oh!")
End Try
End Sub
Private Async Sub BarButtonItem2_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarButtonItem2.ItemClick
Try
Dim oResult = Await _Channel.ListFilesForUserAsync()
BindingSource1.DataSource = oResult.Datatable
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Uh oh!")
End Try
End Sub
Private Async Sub BindingSource1_CurrentChanged(sender As Object, e As EventArgs) Handles BindingSource1.CurrentChanged
Dim oRow As DataRow = GridView1.GetFocusedDataRow()
If oRow Is Nothing Then
Exit Sub
End If
Try
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
DocumentViewer1.LoadFile(oResponse.FileName, oMemoryStream)
oSWTotal.Stop()
AddLogMessage($"File [{oResponse.FileName}] loaded: [{FormatTime(oSWTotal.ElapsedMilliseconds)}]")
Catch ex As FaultException
MsgBox(ex.Reason.ToString, MsgBoxStyle.Critical, "Error from Service")
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Uh oh!")
End Try
End Sub
Private Async Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Try
Dim oSWTotal As New Stopwatch()
oSWTotal.Start()
Dim oObjectId As Integer = TextboxObejctId.EditValue
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)
oSWTotal.Stop()
AddLogMessage($"File [{oResponse.FileName}] loaded: [{FormatTime(oSWTotal.ElapsedMilliseconds)}]")
Catch ex As Exception
AddLogMessage($"Error while getting file: [{ex.Message}]")
End Try
End Sub
Private Sub BarToggleSwitchItem1_CheckedChanged(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles BarToggleSwitchItem1.CheckedChanged
If BarToggleSwitchItem1.Checked Then
If TextboxObejctId.EditValue = "" Then
Timer1.Stop()
MsgBox("Please set a ObjectId!", MsgBoxStyle.Critical, Text)
Else
Timer1.Start()
AddLogMessage("Timer Started!")
End If
Else
Timer1.Stop()
AddLogMessage("Timer Stopped!")
End If
End Sub
End Class