Imports System.Threading.Tasks
Imports DigitalData.Modules.ZooFlow
Public Class frmFileflow_Duplicate
    Dim omessagetext As String
    Private Search As Search.SearchRunner
    Private Property Environment As Environment
    Public Sub New(pFilename As String, pDate As String)

        ' Dieser Aufruf ist für den Designer erforderlich.
        InitializeComponent()

        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
        ' Fügen Sie Initialisierungen nach dem InitializeComponent()-Aufruf hinzu.
        If My.Application.User.Language = "de-DE" Then
            omessagetext = $"Die Datei [{pFilename}] wurde bereits" & vbNewLine & "am [{pDate}] verarbeitet." & vbNewLine & "Wollen Sie die gleiche Datei noch einmal verarbeiten?"
        Else
            omessagetext = $"The file [{pFilename}] has already been processed at [{pDate}]. Do you want to process the same file again?"
        End If
        Environment = My.Application.GetEnvironment()

        Search = New Search.SearchRunner(My.LogConfig, Environment, "FlowSearch") With {
             .BaseSearchSQL = SQL_FLOW_SEARCH_BASE
         }
    End Sub

    Private Async Sub SimpleButton3_Click(sender As Object, e As EventArgs) Handles SimpleButton3.Click
        Await GetResult("DOCID")

    End Sub
    Private Async Function GetResult(oVariant As String) As Task
        Dim oSql As String
        Try
            If oVariant = "DOCID" Then
                oSql = My.Queries.Common.DOCRESULT_DocID(My.Application.Globix.DOCUMENT_ID)
            ElseIf oVariant = "TODAY" Then
                oSql = My.Queries.Common.DOCRESULT_TODAY
            ElseIf oVariant = "TODAY_ME" Then
                oSql = My.Queries.Common.DOCRESULT_TODAY_ME
            End If
            If oSql IsNot Nothing Then
                Dim oResultDT = Await My.Database.GetDatatableIDBAsync(oSql)
                If Not IsNothing(oResultDT) Then
                    Search.RunWithDataTable(oResultDT, "FileFlow Duplicate File")
                End If

            End If

        Catch ex As Exception
            MsgBox("Unexpected error in getResult: " & vbNewLine & ex.Message, MsgBoxStyle.Critical)
        End Try
    End Function

    Private Async Sub SimpleButton4_Click(sender As Object, e As EventArgs) Handles SimpleButton4.Click
        Await GetResult("TODAY")
    End Sub

    Private Async Sub SimpleButton5_Click(sender As Object, e As EventArgs) Handles SimpleButton5.Click
        Await GetResult("TODAY_ME")
    End Sub

    Private Sub frmFileflow_Duplicate_Load(sender As Object, e As EventArgs) Handles Me.Load
        LabelControlMessage.Text = omessagetext
    End Sub
End Class