Entry point into plugin with Batch Tasks API

I am making progress with the Batch Tasks API, but I still don't understand how Studio enters my plugin code. There must be one or more methods that are called, but I don't see where that is defined.

I also wonder exactly what parameters Studio passes to my plugin code? If all batch tasks are designed to operate on files, then there must be a list of input files.

Can anyone point me in the right direction? Here is the Batch Tasks API reference: http://producthelp.sdl.com/SDK/BatchTaskApi/2017/html/cb547244-58ba-f143-931d-b04b3d7f5922.htm

Thanks,

Gary

Parents Reply Children
  • Looks like the path/filename of the report is missing.
    Plus, you might have problem with access rights - the system folders are not writable to standard user, you need to have admin rights to be able to write in there.
    It seems to be related to the - pretty stupid - development assumption/requirement that Studio is run as admin...
  • Hi Gary,

    not knowing more about what your code looks like, here is an example how I achieve this, maybe it helps ("_project" being a FileBasedProject):

     

    var sequence = _project.RunAutomaticTask(tGuids, AutomaticTaskTemplateIds.AnalyzeFiles);
    isDone = false;
    while (!isDone)
    {
        Thread.Sleep(100);
        isDone = (sequence.Status == Sdl.ProjectAutomation.Core.TaskStatus.Completed ||
                  sequence.Status == Sdl.ProjectAutomation.Core.TaskStatus.Failed);
    }

    try
    {
        var reportId = sequence2.Reports[0].Id;
        _project.SaveTaskReportAs(reportId,
            Path.Combine(studioPath, "Reports", $"Analysis_{projNumber}_{DateTime.Now.ToShortDateString()}.xlsx"),
            ReportFormat.Excel);
    }
    catch(Exception ex)
    {
        //Do exceptional stuff
    }

     

    I assume your problem is somewhere in "SaveTaskReportAs" - or maybe you haven't saved at all yet?

     

    Best,

    Andreas

  • Hi Evzen and Andreas,

    Thanks for the suggestions.

    I tried running Studio as admin, and it then produces a different error (I think the problem is that some code is missing from the tutorial -- I need to write code to make the batch task actually do something):

    Unexpected exception when configuring file multiFileConverter for task 'Set segment status': Object reference not set to an instance of a path

    I also found out how to attach the VS debugger to my plugin and step through code / inspect variables, etc. That is an incredible resource that I was not aware of as a VS newbie. I plan to experiment with the debugger this coming week. I think I can figure out the problem using the debugger.

    Cheers,

    Gary

  • Hi , did you try looking at any of the apps in the SDL Community github site? All open source and a few use batch tasks.

    Paul Filkin | RWS

    Design your own training!
    You've done the courses and still need to go a little further, or still not clear? 
    Tell us what you need in our Community Solutions Hub

  • Hi Paul,

    Yes, I did find the apps on github. That is a great resource. I built the "Export to Excel" app and tried it in Studio. I am trying to understand how it works (but so far confused by the many inherited classes -- as a newbie to Visual Studio/C#).

    Do you know offhand which of the apps are batch tasks? I want to try more examples.

    Thanks,
    Gary