I was wondering if you could offer a few precisions about the AutomatedTasks (the overriden version, with Event Handlers). Ive seen something pretty close to the code that Im posting now, and was wondering:
1. What is preventing the code from reaching the "string strErrorMessage line (line 9)? Are the automated tasks blocking operations (in an async wait type of way)? Or, before I move on the the strErrorMsg line, should I do a Task.Status check? do a while loop until its reached the "completed" status, and then check for errors.
2. The "List<Sdl.ProjectAutomation.Core.MessageEventArgs> ConversionErrorMessages" object: is this an object that will capture error messages only? or will it get any type of messages from sub operations?
Sample code:
1 #region Automated task: convert the files to a translatable format
2 AutomaticTask atScan = fpbNewProject.RunAutomaticTask(gSourceFileGuid,
3 AutomaticTaskTemplateIds.ConvertToTranslatableFormat,
4 (sender, TaskStatus) => { ConversionTaskStatus.Add(TaskStatus); },
5 (sender, ScanMessage) => { ConversionErrorMessages.Add(ScanMessage); });
6 #endregion
7
8 #region Check for errors from the automated task operation
9 string strErrorMessage = "";
10
11 if (ConversionErrorMessages.Count > 0)
12 {
13 strErrorMessage = string.Format("Errors in automated task {0}", "AutomaticTaskTemplateIds.ConvertToTranslatableFormat");
14
15 foreach (Sdl.ProjectAutomation.Core.MessageEventArgs mArgs in ConversionErrorMessages)
16 {
17 ProjectFile pfFile = fpbNewProject.GetFile(mArgs.Message.ProjectFileId.Value);
18 strErrorMessage += string.Format("\nFile: {0}, \nMessage: {1}, \nSource {2}", pfFile.Name, mArgs.Message.Message, mArgs.Message.Source);
19 }