Get DocumentObject from DocId or ContainerId

This commit is contained in:
Jonathan Jenne
2019-03-05 12:16:16 +01:00
parent bbd761c0ad
commit ec616ac9b8
14 changed files with 323 additions and 38 deletions

View File

@@ -23,7 +23,11 @@ Partial Class frmFileTest
<System.Diagnostics.DebuggerStepThrough()>
Private Sub InitializeComponent()
Me.Button1 = New System.Windows.Forms.Button()
Me.ListBox1 = New System.Windows.Forms.ListBox()
Me.listboxLog = New System.Windows.Forms.ListBox()
Me.btnDocByDocId = New System.Windows.Forms.Button()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.btnDocByContainerId = New System.Windows.Forms.Button()
Me.TextBox2 = New System.Windows.Forms.TextBox()
Me.SuspendLayout()
'
'Button1
@@ -35,27 +39,69 @@ Partial Class frmFileTest
Me.Button1.Text = "Upload file"
Me.Button1.UseVisualStyleBackColor = True
'
'ListBox1
'listboxLog
'
Me.ListBox1.FormattingEnabled = True
Me.ListBox1.Location = New System.Drawing.Point(12, 45)
Me.ListBox1.Name = "ListBox1"
Me.ListBox1.Size = New System.Drawing.Size(256, 95)
Me.ListBox1.TabIndex = 1
Me.listboxLog.Dock = System.Windows.Forms.DockStyle.Bottom
Me.listboxLog.FormattingEnabled = True
Me.listboxLog.Location = New System.Drawing.Point(0, 225)
Me.listboxLog.Name = "listboxLog"
Me.listboxLog.Size = New System.Drawing.Size(800, 225)
Me.listboxLog.TabIndex = 1
'
'btnDocByDocId
'
Me.btnDocByDocId.Location = New System.Drawing.Point(655, 12)
Me.btnDocByDocId.Name = "btnDocByDocId"
Me.btnDocByDocId.Size = New System.Drawing.Size(133, 32)
Me.btnDocByDocId.TabIndex = 2
Me.btnDocByDocId.Text = "GetDocByDocId"
Me.btnDocByDocId.UseVisualStyleBackColor = True
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(425, 24)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(224, 20)
Me.TextBox1.TabIndex = 3
'
'btnDocByContainerId
'
Me.btnDocByContainerId.Location = New System.Drawing.Point(655, 50)
Me.btnDocByContainerId.Name = "btnDocByContainerId"
Me.btnDocByContainerId.Size = New System.Drawing.Size(133, 32)
Me.btnDocByContainerId.TabIndex = 4
Me.btnDocByContainerId.Text = "GetDocByContainerId"
Me.btnDocByContainerId.UseVisualStyleBackColor = True
'
'TextBox2
'
Me.TextBox2.Location = New System.Drawing.Point(425, 62)
Me.TextBox2.Name = "TextBox2"
Me.TextBox2.Size = New System.Drawing.Size(224, 20)
Me.TextBox2.TabIndex = 3
'
'frmFileTest
'
Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.ClientSize = New System.Drawing.Size(800, 450)
Me.Controls.Add(Me.ListBox1)
Me.Controls.Add(Me.btnDocByContainerId)
Me.Controls.Add(Me.TextBox2)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.btnDocByDocId)
Me.Controls.Add(Me.listboxLog)
Me.Controls.Add(Me.Button1)
Me.Name = "frmFileTest"
Me.Text = "frmFileTest"
Me.ResumeLayout(False)
Me.PerformLayout()
End Sub
Friend WithEvents Button1 As Button
Friend WithEvents ListBox1 As ListBox
Friend WithEvents listboxLog As ListBox
Friend WithEvents btnDocByDocId As Button
Friend WithEvents TextBox1 As TextBox
Friend WithEvents btnDocByContainerId As Button
Friend WithEvents TextBox2 As TextBox
End Class

View File

@@ -17,24 +17,72 @@ Public Class frmFileTest
Private Async Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim oDialog = New OpenFileDialog()
Dim oResult = oDialog.ShowDialog()
Dim oDialogResult = oDialog.ShowDialog()
If oResult <> DialogResult.OK Then
If oDialogResult <> DialogResult.OK Then
Exit Sub
End If
Try
Dim oDocObject = Await _fileOp.ImportFileAsync(oDialog.FileName)
Dim oResult = Await _fileOp.ImportFileAsync(oDialog.FileName)
If oDocObject.OK = False Then
MsgBox(oDocObject.ErrorMessage)
If oResult.OK = False Then
MsgBox(oResult.ErrorMessage)
Exit Sub
End If
ListBox1.Items.Add(oDocObject)
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