3

Trying automate translation jobs within workflow from Sites 9.1 to rename process instances to add the translation job name.

        ProcessInstance processInstance = new ProcessInstance(subject.Process.Id, subject.Session);
        processInstance.Title = string.Format("[{0}] [{1}] [{2}]", language, pageName, title);
        processInstance.Save();

Followed steps in solution for Unable to find Translation Manager TmBinaryEndpoint for 8.5

Added App.config and copied <system.serviceModel> section from TcmWorkFlowAgent.exe.config

In OnActivityInstanceStartPre Event Handler I get the tcmid of the item in workflow

        string itemid = "tcm:0-0-0";
        foreach (WorkItem workItem in subject.WorkItems)
        {
            itemid = workItem.Subject.Id;
            break;
        }

Then try to get a tmClient

            using (var tmClient = new SessionAwareTmServiceClient("TmBinaryEndpointV2"))
            {
                TcmItemTranslationInfoData ti = tmClient.GetTcmItemTranslationInfo(itemid);
                jobTitle = ti.ItemTitle;
            }

The code fails with exception

Could not find endpoint element with name 'TmBinaryEndpointV2' and contract 'Tridion.TranslationManager.V2.TmService.Client.ISessionAwareTmService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this name could be found in the client element.

Are there any extra steps required to use the TmClient on Sites 9.1?

2 Answers 2

3

It is much better to use Translation Manager API instead of WCF service inside event handlers.

Reference Tridion.TranslationManager.dll and Tridion.TranslationManager.V2.dll in your project.

Then create ITmSession in your event handler using this example:

private void OnActivityInstanceStartPre(ActivityInstance subject, StartActivityEventArgs e, EventPhases phase)
{
    using (ITmSession tmSession = Tridion.TranslationManager.V2.TmSessionFactory.Create(subject.Session))
    {
        // tmSession will give you full access to TM API
    }
}
1
  • Given that WCF error has 1.97 million results in Google. I am happy to ditch that solution for one that works. Once I found the Tridion.TranslationManager.dll in the GAC and copied to my references, The solution worked. Thanks for a great answer. Oct 20, 2021 at 19:17
0

In general, event handlers are executed in the same process as the one which triggers them. Many events are triggered from the Core Service, meaning that the event handlers will run in either the TcmServiceHost.exe process (for net.tcp-based Core Service endpoints) or w3wp.exe (the TCM AppPool to be precise, for HTTP-based Core Service endpoints).

As of 9.5, events may also be triggered from the new Core Service REST, which also runs in the TCM AppPool in IIS.

Furthermore, events can be triggered from the TCM Publisher Service (TcmPublisher.exe process) and even from the Translation Manager Service (Tridion.TranslationManager.Service.exe process).

So: you see, it's quite challenging to rely on app/web configuration in event handlers: you may have to change several app/web config files (and hopefully you remember which ones you modified after an upgrade). You could consider putting your configuration in machine.config.

In case of Activity Instance Start event: these can be expected to be triggered from TcmServiceHost.exe (most likely) or IIS. That means that the configuration of the TmBinaryEndpointV2 should be either in TcmServiceHost.exe.config or machine.config.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.