jobRunner.vbs: Function JobInQueue

Returns the found job and deletes it from the Queue
 

Function JobInQueue(ByRef Task, ByRef Name, ByRef Profile)

    Dim objDB, sqlQuery, recordset

    JobInQueue = FALSE

    Task = “”

    Name = “”

    Profile = “”

    Set objDB = CreateObject(“ADODB.Connection”)

    Set recordset = CreateObject(“ADODB.Recordset”)

    objDB.Open DB_CONNECT_STRING

    sqlQuery = “select top 1 * from ” & DB_TABLE_QUEUE & ” order by priority”

    recordset.Open sqlQuery, objDB

    If Not recordset.EOF Then

        Task = recordset.Fields(“Task”)

        Name = recordset.Fields(“Name”)

        Profile = recordset.Fields(“Profile”)

    End If

    objDB.Close

    If Not Task = “” Then

        WriteLog “Found in Queue: ” & Task & “, ” & Name & “, “ & Profile

        JobInQueue = TRUE

        DeleteFromQueue Task, Name, Profile

    End If

End Function