Imports DigitalData.Modules.EDMI.API.EDMIServiceReference
Imports DigitalData.Modules.Base.IDB.FileStore
Imports DigitalData.GUIs.Common
Imports DigitalData.Modules.ZooFlow

Public Class frmtest
    Private Property Environment As Environment
    Private Property AdHoc_Workflow As AdHocWorkflow

    Private Sub frmtest_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        cmbObjectStoreType.SelectedIndex = 0
        Environment = My.Application.GetEnvironment()

    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 oResponse As ImportFileResponse = Await My.Application.Service.Client.ImportFileAsync(
            txtFile2Import.Text,
            New List(Of UserAttributeValue) From {
                New UserAttributeValue With {
                    .Name = "Attribut String1",
                    .Values = New List(Of String) From {"Harry"}.ToArray
                },
                New UserAttributeValue With {
                    .Name = "DisplayFileName",
                    .Values = New List(Of String) From {"DN Textdokument"}.ToArray
                }
            },
            "Work",
            "DOC",
            txtDoctypeID.Text
        )

        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

    Private Async Sub btnImportFile_Click_(sender As Object, e As EventArgs) Handles btnImportFile.Click
        Dim oResponse As Globix_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 {"Harry"}.ToArray
                },
                  New UserAttributeValue With {
                    .Name = "DisplayFileName",
                    .Values = New List(Of String) From {"DN Textdokument"}.ToArray
                }
            },
            "Work",
            "DOC",
            txtDoctypeID.Text
        )

        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

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        AdHoc_Workflow = My.Application.GetAdHocWorkflow(TextBox1.Text)
        Dim oForm As New frmWorkflow_Adhoc_start(My.LogConfig, Environment, AdHoc_Workflow)
        oForm.Show()
        oForm.BringToFront()
        oForm.Focus()
    End Sub


End Class