Language: Add ToBoolean, EMIBenchmark: try blocks
This commit is contained in:
parent
162485e3f0
commit
d2717b9216
@ -11,16 +11,20 @@ Public Class Form1
|
||||
Private _Logger As Logger
|
||||
|
||||
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
|
||||
_LogConfig = New LogConfig(LogConfig.PathType.Temp, Nothing, "EDMIBenschmark")
|
||||
_Logger = _LogConfig.GetLogger()
|
||||
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()
|
||||
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()
|
||||
|
||||
DocumentViewer1.Init(_LogConfig, "21182889975216572111813147150675976632")
|
||||
DocumentViewer1.Init(_LogConfig, "21182889975216572111813147150675976632")
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub AddLogMessage(Message As String)
|
||||
@ -44,37 +48,41 @@ Public Class Form1
|
||||
End Sub
|
||||
|
||||
Private Async Sub ButtonImportFiles_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles ButtonImportFiles.ItemClick
|
||||
Dim oFiles As New List(Of String)
|
||||
Dim oSWTotal As New Stopwatch()
|
||||
oSWTotal.Start()
|
||||
Try
|
||||
Dim oFiles As New List(Of String)
|
||||
Dim oSWTotal As New Stopwatch()
|
||||
oSWTotal.Start()
|
||||
|
||||
For Each oItem As String In listboxFiles.Items
|
||||
Dim oSW As New Stopwatch()
|
||||
oSW.Start()
|
||||
Dim oFileName As String = oItem
|
||||
Dim oFileInfo As New FileInfo(oFileName)
|
||||
For Each oItem As String In listboxFiles.Items
|
||||
Dim oSW As New Stopwatch()
|
||||
oSW.Start()
|
||||
Dim oFileName As String = oItem
|
||||
Dim oFileInfo As New FileInfo(oFileName)
|
||||
|
||||
AddLogMessage($"Importing {oFileInfo.Name}... ({FormatBytes(oFileInfo.Length)})")
|
||||
AddLogMessage($"Importing {oFileInfo.Name}... ({FormatBytes(oFileInfo.Length)})")
|
||||
|
||||
Dim oContents As Byte() = New Byte(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
|
||||
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
|
||||
oSW.Stop()
|
||||
AddLogMessage($"Import Time: {FormatTime(oSW.ElapsedMilliseconds)}")
|
||||
AddLogMessage("")
|
||||
Next
|
||||
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
|
||||
oSW.Stop()
|
||||
AddLogMessage($"Import Time: {FormatTime(oSW.ElapsedMilliseconds)}")
|
||||
AddLogMessage("")
|
||||
Next
|
||||
|
||||
oSWTotal.Stop()
|
||||
AddLogMessage($"Total Time: {FormatTime(oSWTotal.ElapsedMilliseconds)}")
|
||||
oSWTotal.Stop()
|
||||
AddLogMessage($"Total Time: {FormatTime(oSWTotal.ElapsedMilliseconds)}")
|
||||
Catch ex As Exception
|
||||
MsgBox(ex.Message, MsgBoxStyle.Critical, Text)
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Private Sub buttonClearLog_ItemClick(sender As Object, e As DevExpress.XtraBars.ItemClickEventArgs) Handles buttonClearLog.ItemClick
|
||||
|
||||
@ -22,6 +22,11 @@ Public Class Utils
|
||||
Return [Enum].Parse(GetType(T), value)
|
||||
End Function
|
||||
|
||||
Public Shared Function ToBoolean(input As String) As Boolean
|
||||
If String.IsNullOrEmpty(input) Then Return False
|
||||
Return (input.Trim().ToLower() = "true") OrElse (input.Trim() = "1")
|
||||
End Function
|
||||
|
||||
''' <summary>
|
||||
''' Checks a value for three different `null` values,
|
||||
''' Nothing, Empty String, DBNull
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user