Re-import Imported Package

In the GUI, if you attempt to import an previously imported return package, the user is prompted to confirm this is what they intend, and the package is then re-imported. Is the same functionality available via the SDK? The regular `.ImportReturnPackage` method on a FileBasedProject doesn't seem to provide any options, and indeed only throws an InvalidOperationException later with the stack trace below. Is there another approach to importing that can be taken?

Is it possible to recreate the functionality exposed in the GUI via the SDK?

Stack Trace:
This property is only available once the package has been imported.
   at Sdl.ProjectApi.Implementation.PackageOperation.get_Files()
   at Sdl.ProjectAutomation.FileBased.FileBasedProject.CreateReturnPackageImportObject(IReturnPackageImport rpi)
   at Sdl.ProjectAutomation.FileBased.FileBasedProject.ImportReturnPackage(String returnPackageFilePath, EventHandler`1 statusEventHandler, EventHandler`1 messageEventHandler)
   at Sdl.ProjectAutomation.FileBased.FileBasedProject.ImportReturnPackage(String returnPackageFilePath)

Parents Reply
  • I manage to reproduce your crash and there are 2 aspects of this issue:

    First of all there is a defect in the SDK because it shouldn't crash as it is. There is specific logic written for setting the failed status but is not working correctly. I will raise this with the development team because this should actually pass the correct status via the status event handler.

    Regardless of the above crash Studio SDK is not allowing to import the same return package more than once and it there is specific logic written for this. The crash is a side effect of this logic. I know that  Studio application is asking if you want to override the previous import but this behavior is not available in the SDK and I can't say if will ever be implemented.

    This leaves us with 2 options:

    1. You ask for a new return package. Every time the return package is generated by the translator it will have a unique identifier so you will not encounter the above issue.

    2. The second option is of last resort and only if the first option is not viable. This is because this is not officially supported in any way. So if you really need to do this you will have to manually parse your *.sdlproj and remove ReturnPackageImport xml element. This xml element has a PackageGuid attribute which you should compare against your return packageGuid and if the same remove ReturnPackageImport xml element from *.sdlproj.

    As I've said the second option is not supported and you might encounter some unexpected behavior.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

Children