Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
Imports DigitalData.Modules.Base.IDB.FileStore

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 <> FILE_STORE_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 oResponse As ImportFileResponse = Await My.Application.Service.Client.Globix_ImportFileAsync(
            txtFile2Import.Text,
            txtProfileId.Text,
            New List(Of UserAttributeValue) From {
                New UserAttributeValue With {
                    .Name = "Attribut String1",
                    .Values = New List(Of String) From {"SchreiberM"}.ToArray
                }
            },
            "WORK",
            "DOC",
            "DEFAULT"
        )

        If oResponse.OK Then
            MsgBox("File Imported!", MsgBoxStyle.Information, Text)
            txtIDB_OBJ_ID.Text = oResponse.ObjectId
        Else
            MsgBox("File was not imported. Check the server logs!", MsgBoxStyle.Critical, Text)
        End If


    End Sub
End Class