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
  • Studio doesn't enter anything by itself. It's your code what must actively do something.
    To my best knowledge, there isn't any way to "hook into" anything... e.g. there is no "method or event to be hooked", so that for example your own code is executed before/instead of/after standard "Analyze" task.
    (There are few events available, like progress of the batch task, but that's about it... )
    What exactly are you trying to accomplish?
  • Hi --

    Maybe I am totally misunderstanding, but it seems like Studio must at least be calling the 'AbstractFileLevelAutomaticTask.OnInitializeTask' to launch my batch task. If Studio doesn't call anything, I don't see how the plugin could ever run. This initial call is what I meant by 'entry point'. So I am wondering about the sequence of method calls that occur when a user runs my batch task.

    More specifically, I am trying to make this tutorial work: http://producthelp.sdl.com/SDK/BatchTaskApi/1.0/html/d4c61662-0dc9-4f3c-8bed-f7cfc3b3b27d.htm#!

    When I run the batch task, everything looks OK, but the final step (report generation) causes this error:

    Unexpected exception when configuring file multiFileConverter for task 'Set segment status': Access to the path 'C:\Windows\system32\.txt' is denied.

    Any ideas what that means?

    Thanks, Gary

  • 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

Reply
  • 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

Children