
Imports DigitalData.Modules.Logging
Imports DigitalData.Modules.EDMI.API
Imports System.IO
Imports System.Text
Imports DigitalData.Modules.EDMI.API.Client

Public Class frmtest


    Private Sub frmtest_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cmbObjectStoreType.SelectedIndex = 0
    End Sub

    Private Sub btnOpenFile_Click(sender As Object, e As EventArgs) Handles btnOpenFile.Click
        If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
            txtFile2Import.Text = OpenFileDialog1.FileName
        End If
    End Sub

    Private Async Sub btnNewFile_Click(sender As Object, e As EventArgs) Handles btnNewFile.Click
        Dim oObjectId As Long = Await My.Application.Service.Client.NewFileAsync(
            txtFile2Import.Text,
            "WORK",
            "DOC",
            "DEFAULT"
        )

        If oObjectId <> INVALID_OBEJCT_ID Then
            MsgBox("File Imported!", MsgBoxStyle.Information, Text)
        Else
            MsgBox("File was not imported. Check the server logs!")
        End If
        txtIDB_OBJ_ID.Text = oObjectId
    End Sub


    Private Async Sub btnImportFile_Click_(sender As Object, e As EventArgs) Handles btnImportFile.Click
        Dim oObjectId As Long = Await My.Application.Service.Client.ImportFileAsync(
            txtFile2Import.Text,
            txtProfileId.Text,
            New List(Of EDMIServiceReference.UserAttributeValue) From {
                New EDMIServiceReference.UserAttributeValue With {
                    .AttributeName = "Attribut String1",
                    .AttributeValues = New List(Of String) From {"SchreiberM"}.ToArray
                }
            },
            "WORK",
            "DOC",
            "DEFAULT"
        )

        If oObjectId <> INVALID_OBEJCT_ID Then
            MsgBox("File Imported!", MsgBoxStyle.Information, Text)
        Else
            MsgBox("File was not imported. Check the server logs!")
        End If
        txtIDB_OBJ_ID.Text = oObjectId
    End Sub
End Class