Return package throws an exception once it is returned more than once

Hi,

I do have an automated package import, however it throws an exception when vendor does try to deliver package more than once. Here is my code:

List<ProgressEventArgs> test_progress_args = new List<ProgressEventArgs>();
            List<MessageEventArgs> test_messages = new List<MessageEventArgs>();
            ReturnPackageImport rpi_test = p_test.ImportReturnPackage(packageFile,(sender,progresarg)=>test_progress_args.Add(progresarg),(sender,messagearg)=>test_messages.Add(messagearg));
            if (rpi_test.Status != PackageStatus.Completed)
            {
                throw new Exception("Package test: SDL Trados could not import vendor translation package. " + rpi_test.StatusMessage);
            }
            if (test_messages.Count > 0)
            {
                string body = "";
                foreach (MessageEventArgs message in test_messages)
                {
                    body += String.Format(" {0} </br>", message.Message.Message);
                }
                string subject = String.Format("Job: {0}, Language: {1}, WO: {2}", wr.Job.Number,
                    wr.TargetLanguageAsString, wr.WorkRequestId);
                string final_body =
                    String.Format(
                        "Hello {0}, <br>Vendor {1} is trying to upload translation package but following error does occur: <br>{2}<br>" +
                        "This error is displayed on vendor WO page.<br>If you have received this message several times please follow up with vendor or log DocEng support ticket",
                        wr.InternalContactPerson.FirstName, wr.ContactPerson.Company.CompanyName, body);
                List<string> to = new List<string>();
                to.Add(wr.InternalContactPerson.Email);
                List<string> cc_package_test= new List<string>();
                cc_package_test.Add(wr.Job.ProjectManager.Email);
            SendMailNoAttachments(subject,final_body,MailPriority.High,to,cc_package_test);
                throw new Exception(body);
            }

It does work well when vendor upload package first time, but line:

ReturnPackageImport rpi_test = p_test.ImportReturnPackage(packageFile,(sender,progresarg)=>test_progress_args.Add(progresarg),(sender,messagearg)=>test_messages.Add(messagearg));

throws an exception below when you will try to import it one more time:

Subject: Sdl.ProjectApi.Implementation
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 Trados2011.Tools.ImportTranslationPackage(String projectFile, String packageFile, List`1 emails, String job_number, String client_name, String work_order_id, String language, String pm_firstname, String pc_firstname, TradosWorkQueue q) in c:\code\iTrac\Client\Trados2011\Tools.cs:line 727
at TradosQueueProcessor.Program.ImportWorkRequestPackage(TradosWorkQueue q) in c:\code\iTrac\Client\TradosQueueProcessor\Program.cs:line 658
at TradosQueueProcessor.Program.ProcessQueue() in c:\code\iTrac\Client\TradosQueueProcessor\Program.cs:line 94

Does anyone have any idea how i can:
a) Check if package is already imported

b) reset previous import.

I'm using Trados 2011

Thanks in advance!

Parents
  • I'm not aware of such features but my guess at the moment would an issue with the internal project GUID. Looking at your StackTrace I've seen that you are using the ImportReturnPackage with EventHandlers. In order to validated or invalidated my assumption can you please let me know what status you have in the statusEventHandler ? This event should be raised a couple of times.

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

  • Hi Romulus,

    Unfortunately, exception is thrown in Sdl.ProjectApi.Implementation.PackageOperation.get_Files() . that means functions actually terminates there and returns nothing in event handlers

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

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