Grooper 21.00.0082 is available as of 12-12-2023! Check the  Downloads Discussion  for the release notes and to get the latest version.
Grooper 23.00.0042 is available as of 03-22-2024! Check the Downloads Discussion for the release notes and to get the latest version.
Grooper 23.1.0018 is available as of 04-15-2024! Check the  Downloads Discussion  for the release notes and to get the latest version.
Options

Programmatic creation of a new Batch

If during an export script I check my database and find that a record already exists I will not want to save it. I will instead want to write that document (PDF) to a different Batch job called DocumentExceptionBatch.  How do I create the Batch programmatically and move documents into it?

Any assistance is appreciated.

Tagged:

Best Answer

Answers

  • Options
    TonyTony Posts: 23

    This just might do what I need.  I'm off to give it a try . . .

    Thank you for responding.  I will let you know how it works out.

  • Options
    BradleyBradley Posts: 94 ✭✭✭
    Tony,

    Here a code snippet I'm using from another activity. It's not finished(you can tell by the comments in it) but it should get you on the right path for creating one in your script.

    'Created at the beginning of a class declaration
    Private RepositoryId As Guid = Guid.Empty

            Public Sub New(RepositoryId As Guid)
                Me.RepositoryId = RepositoryId
            End Sub
            'some Class code follows to the end of the class
    'End of class

    'Use in your custom subroutine
            Dim gdb As New GrooperDb(RepositoryId)
            If (gdb.Connect(GrooperDb.ConnectOptions.ConnectOnly) = False) Then Return Nothing

            Dim root As GrooperRoot = gdb.Root
            'Dim batch As Batch = root.NewChild(GetType(Batch))
            Dim bch As Batch = root.BatchProcessing.Batches.Production.NewChild(GetType(Batch))

            'Perform your custom work here

            'Assign a batch process and starting step
                Dim bchProcess As BatchProcess = gdb.Root.BatchProcessing.Processes.Published("Name of batch process")
                Dim processStep As BatchProcessStep = bchProcess.Steps(0)
                bch.ApplyBatchProcess(bchProcess, processStep)
                bch.Status = GrooperDb.ProcessingStatus.Ready

            'Set batch status to Processing
             bch.Status = GrooperDb.ProcessingStatus.Ready
            'Save batch to database and kick off process

            gdb.SaveChanges()
    'End of subroutine
Sign In or Register to comment.