I'm using a custom event handler to generate an email when the status of Translation Jobs changes to InTranslation and Completed.
EventSystem.SubscribeAsync<ITranslationJob, ITranslationJobStateChangeEventArgs>(OnTranslationJobStateChange, EventPhases.Initiated, EventSubscriptionOrder.Early);
When the status is InTranslation I'm able to access the AddedItems property and include TCM & Title of the items from the translation job in my email. Usually bundles are sent to translation so its the bundle TCM & Title.
When the status is Completed, the AddedItems property is empty and I use TmsTranslationJobs.TargetItems to try and generate a list of it TCMs & titles of items that gave completed translated.
var targets = translationJob.TmsTranslationJobs.SelectMany(t => t.TargetItems);
If a bundle was sent originally, TmsTranslationJobs.TargetItems is actually the Component TCMs inside the bundle.
For some reason the API for TargetItems only contains the TCM (via the SourceUri property) of the Components inside a bundle, not titles.
I thought I could use this TCM to load the Component via the TOM.NET API and get its title but the TOM.NET API requires a Session object to be passed to every Component constructor but I'm not sure how to construct that Session object - as I haven't subscribed to a Content Manager object I have no access to a Session?
I see in the Session class it can be instantiated with a username:
var s = new Session(string userName);
Is it safe to get a Session this way?