 | CTInterfaceOnBatchOperationsCompleted Event |
Notifies when all batch operations are completed.
After this event, CUSTOMTOOLS shows possible conversion errors
for the user and closes all documents that were opened during
the process by the conversion engine.
In case your add-in collected converted documents for collective post-processing,
now would be good time to post-process them.
Namespace: ATR.CT.CTInterfaceAssembly: CTInterface (in CTInterface.dll) Version: 25.0
Syntax
Example
This example shows how to bind scripts to specific Batch Opearation Templates in order to collect
and post-process all converted documents of that template when the operation has been finished.
This example requires a template named 'My Template' and will attach [Report] -tag on it.
Language: C#
Class name: BatchOpDocCollector
using ATR.CT.CTInterface;
using CTExtensions;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
namespace Example
{
public class BatchOpDocCollector : CTExtension
{
static readonly string ATTACH_TO_TEMPLATE = "My Template";
private bool mbCollectDocuments = false;
private List<string> moCollection;
private int miBatchTemplateID = 0;
public override bool Hook(CTInterface oCTInterface)
{
bool bHooked = false;
if (oCTInterface != null)
{
oCTInterface.OnBatchOperationTemplatePreLoad += HandleBatchOperationTemplatePreLoad;
oCTInterface.OnBatchOperationsLaunched += HandleBatchOperationsLaunched;
oCTInterface.NotifyDialogAccess += HandleNotifyDialogAccess;
oCTInterface.OnBatchOperationsCompleted += HandleBatchOperationsCompleted;
oCTInterface.OnPostFileConversion += HandlePostFileConversion;
bHooked = true;
}
return bHooked;
}
public override void UnHook(CTInterface oCTInterface)
{
if (oCTInterface != null)
{
oCTInterface.OnBatchOperationTemplatePreLoad -= HandleBatchOperationTemplatePreLoad;
oCTInterface.OnBatchOperationsLaunched -= HandleBatchOperationsLaunched;
oCTInterface.NotifyDialogAccess -= HandleNotifyDialogAccess;
oCTInterface.OnBatchOperationsCompleted -= HandleBatchOperationsCompleted;
oCTInterface.OnPostFileConversion -= HandlePostFileConversion;
}
}
private void Init()
{
moCollection = new List<string>();
mbCollectDocuments = false;
miBatchTemplateID = 0;
}
private void HandleNotifyDialogAccess(object sender, NotifyDialogAccessArgs e)
{
if (e.Dialog == DialogAccess.PrintAndConvert)
Init();
}
private void HandleBatchOperationTemplatePreLoad(object sender, CTInterface.BatchOperationTemplatePreLoadArgs e)
{
if (string.Compare(e.BatchOpTemplate.Name, ATTACH_TO_TEMPLATE, true) == 0)
{
e.Tag = "Report";
miBatchTemplateID = e.BatchOpTemplate.ID;
}
}
private void HandleBatchOperationsLaunched(object sender, CTInterface.BatchOperationsLaunchedArgs e)
{
if (e.BatchOpTemplateID != 0 && e.BatchOpTemplateID == miBatchTemplateID)
mbCollectDocuments = true;
else
mbCollectDocuments = false;
}
private void HandlePostFileConversion(object sender, CTInterface.PostFileConversionArgs e)
{
if (mbCollectDocuments)
{
if (moCollection.Find(x => string.Compare(x, e.TargetFileName, true) == 0) == null)
moCollection.Add(e.TargetFileName);
}
}
private void HandleBatchOperationsCompleted(object sender, CTInterface.BatchOperationsCompletedArgs e)
{
if (mbCollectDocuments)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("The process resulted in following converted documents:");
sb.AppendLine();
foreach (var file in moCollection)
{
sb.AppendLine("- " + file);
}
MessageBox.Show(sb.ToString());
Init();
}
}
}
}
Revision HistoryDate | Version | Description |
---|
- | 2021 SP1 | First Release |
See Also