88 lines
3.2 KiB
VB.net
88 lines
3.2 KiB
VB.net
Imports System.IO
|
|
Imports DigitalData.Modules.EDMIFileOps
|
|
Imports DigitalData.Modules.Filesystem
|
|
Imports DigitalData.Modules.Logging
|
|
|
|
Public Class frmFileTest
|
|
Private _fileOp As Document
|
|
|
|
Private Sub frmFileTest_Load(sender As Object, e As EventArgs) Handles Me.Load
|
|
Try
|
|
_fileOp = New Document(My.LogConfig, My.Settings.EDM_NetworkService_Adress)
|
|
|
|
Catch ex As Exception
|
|
_Logger.Warn($"Unexpected error in frmFileTest_Load: {ex.Message}")
|
|
End Try
|
|
End Sub
|
|
|
|
Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
|
|
Dim oDialog = New OpenFileDialog()
|
|
Dim oDialogResult = oDialog.ShowDialog()
|
|
|
|
If oDialogResult <> DialogResult.OK Then
|
|
Exit Sub
|
|
End If
|
|
|
|
Try
|
|
Dim oResult = Await _fileOp.ImportFileAsync(oDialog.FileName)
|
|
|
|
If oResult.OK = False Then
|
|
MsgBox(oResult.ErrorMessage)
|
|
Exit Sub
|
|
End If
|
|
|
|
listboxLog.Items.Add($"Document uploaded!")
|
|
listboxLog.Items.Add($"DocId: {oResult.Document.DocumentId}")
|
|
listboxLog.Items.Add($"ContainerId: {oResult.Document.ContainerId}")
|
|
listboxLog.Items.Add($"Filename: {oResult.Document.FileName}")
|
|
listboxLog.Items.Add($"----------------------------------------------------------")
|
|
Catch ex As Exception
|
|
MsgBox(ex.Message)
|
|
_Logger.Error(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub btnDocByDocId_Click(sender As Object, e As EventArgs) Handles btnDocByDocId.Click
|
|
Try
|
|
Dim oDocId As Int64 = Int64.Parse(TextBox1.Text)
|
|
Dim oResult = _fileOp.GetDocumentByDocumentId(oDocId)
|
|
|
|
If Not oResult.OK Then
|
|
MsgBox(oResult.ErrorMessage)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oDocObject = oResult.Document
|
|
|
|
listboxLog.Items.Add($"Document fetched!")
|
|
listboxLog.Items.Add($"DocId: {oDocObject.DocumentId}")
|
|
listboxLog.Items.Add($"ContainerId: {oDocObject.ContainerId}")
|
|
listboxLog.Items.Add($"Filename: {oDocObject.FileName}")
|
|
listboxLog.Items.Add($"----------------------------------------------------------")
|
|
Catch ex As Exception
|
|
_ErrorHandler.ShowErrorMessage(ex)
|
|
End Try
|
|
End Sub
|
|
|
|
Private Sub btnDocByContainerId_Click(sender As Object, e As EventArgs) Handles btnDocByContainerId.Click
|
|
Try
|
|
Dim oContainerId As Int64 = Int64.Parse(TextBox2.Text)
|
|
Dim oResult = _fileOp.GetDocumentByContainerId(oContainerId)
|
|
|
|
If Not oResult.OK Then
|
|
MsgBox(oResult.ErrorMessage)
|
|
Exit Sub
|
|
End If
|
|
|
|
Dim oDocObject = oResult.Document
|
|
|
|
listboxLog.Items.Add($"Document fetched!")
|
|
listboxLog.Items.Add($"DocId: {oDocObject.DocumentId}")
|
|
listboxLog.Items.Add($"ContainerId: {oDocObject.ContainerId}")
|
|
listboxLog.Items.Add($"Filename: {oDocObject.FileName}")
|
|
listboxLog.Items.Add($"----------------------------------------------------------")
|
|
Catch ex As Exception
|
|
_ErrorHandler.ShowErrorMessage(ex)
|
|
End Try
|
|
End Sub
|
|
End Class |