Hi guys,
I am developing a batch task. My goal is to write a placeholder string into all targets of segments that have a unspecified confirmation level.
Before that i tried to just print all the sub items of a target segment for practice.
I was able to create and run the batch task on a file but after reopening the file all the segments were gone.
I use the OnFileComplete method because I want to change stuff later.
public override bool OnFileComplete(ProjectFile projectFile, IMultiFileConverter multiFileConverter) { return true; }
My gut feeling tells me that this is the culprit and I need to write the segments manually again after looking at them?
Here is my complete code:
using Sdl.FileTypeSupport.Framework.IntegrationApi; using Sdl.ProjectAutomation.AutomaticTasks; using Sdl.ProjectAutomation.Core; using KI18NBatchTask.KI18NBatchTask; namespace KI18NBatchTask { [AutomaticTask("Test", "Test", "Test", GeneratedFileType = AutomaticTaskFileType.BilingualTarget)] [AutomaticTaskSupportedFileType(AutomaticTaskFileType.BilingualTarget)] [RequiresSettings(typeof(KI18NBatchTaskSettings), typeof(KI18NBatchTaskSettingsPage))] internal class KI18NBatchTaskClass : AbstractFileContentProcessingAutomaticTask { protected override void OnInitializeTask() { base.OnInitializeTask(); } protected override void ConfigureConverter(ProjectFile projectFile, IMultiFileConverter multiFileConverter) { FileProcessor _task = new FileProcessor(); multiFileConverter.AddBilingualProcessor(_task); multiFileConverter.Parse(); } public override void TaskComplete() { base.TaskComplete(); } public override bool OnFileComplete(ProjectFile projectFile, IMultiFileConverter multiFileConverter) { return true; } } }
using Sdl.FileTypeSupport.Framework.BilingualApi; using System.Diagnostics; using System.Linq; namespace KI18NBatchTask.KI18NBatchTask { internal class FileProcessor : AbstractBilingualContentProcessor { public override void ProcessParagraphUnit(IParagraphUnit paragraphUnit) { //base.ProcessParagraphUnit(paragraphUnit); if (paragraphUnit.IsStructure) { return; } foreach (var segmentPair in paragraphUnit.SegmentPairs.ToList()) { segmentPair.Target.AllSubItems.ToList().ForEach(item => { Debug.WriteLine(item); }); } } } }
Addtional question:
Why is it sometimes necessary to call "base.ProcessParagraphUnit(paragraphUnit);" in my AbstractBilingualContentProcessor?
The Anonymizer Batch Task that is often referenced as an example does it.
The Clean Up Batch task does not do it. But this one is messy and I also don't understand why it uses a combination of AbstractBilingualContentHandler wraped into a BilingualContentHandlerAdapter instead of a AbstractBilingualContentProcessor.
Sorry for the messy question. Hope anybody could help me with the deleting issue!
Best
Lukas
changed wording
[edited by: Lukas Ley at 3:23 PM (GMT 1) on 30 Jul 2025]