How to use AnalyzeFiles/PreTranslate tasks with server-based translation memory?

Hi,
 
We want to use AnalyzeFiles/PreTranslate task with server-based translation memory.
However, these tasks failed with message : System.Collections.Generic.KeyNotFoundException: No identity information found for server (server-name).
 
How to use AnalyzeFiles/PreTranslate task with server-based translation memory?
 
 
SDL Trados Studio Version 14.0.5889.5
Microsoft Visual Studio Express 2015 for Windows Desktop Version 14.0.25420.1
 

Analyze Code (C#):
using System;
using System.IO;
using System.Linq;
using Sdl.Core.Globalization;
using Sdl.ProjectAutomation.Core;
using Sdl.ProjectAutomation.FileBased;
class Program
{
    private const string ServerUri = "http://example.com/";
    private const string UserName = "my_username";
    private const string Password = "my_password";
    private const string Organization = "my_organization";
    private const string TmName = "my_tm_name";
    private const string SourceCultureName = "en-US";
    private const string TargetCultureName = "ja-JP";
    private const string SourceFileName = @"my_source_file.xml";
    static void Main()
    {
        var info = new ProjectInfo
        {
            Name = Path.GetFileName(SourceFileName),
            LocalProjectFolder = Path.Combine(Path.GetDirectoryName(SourceFileName), "Project"),
            SourceLanguage = new Language(SourceCultureName),
            TargetLanguages = new[] { new Language(TargetCultureName) }
        };
        if (Directory.Exists(info.LocalProjectFolder))
        {
            Directory.Delete(info.LocalProjectFolder, true);
        }
        var project = new FileBasedProject(info);
        project.AddFiles(new[] { SourceFileName });
        project.RunAutomaticTask(project.GetSourceLanguageFiles().GetIds(), AutomaticTaskTemplateIds.Scan);
        project.RunAutomaticTask(project.GetSourceLanguageFiles().GetIds(), AutomaticTaskTemplateIds.ConvertToTranslatableFormat);
        project.RunAutomaticTask(project.GetSourceLanguageFiles().GetIds(), AutomaticTaskTemplateIds.CopyToTargetLanguages);
        var projectConfig = project.GetTranslationProviderConfiguration();
        projectConfig.Entries.Add(new TranslationProviderCascadeEntry(new TranslationProviderReference(new Uri($"sdltm.{ServerUri}{Organization}{(Organization != "" ? "/" : "")}{TmName}")), true, true, false));
        project.Credentials.AddCredential(new Uri(ServerUri), $"user={UserName};password={Password};type=CustomUser");
        project.UpdateTranslationProviderConfiguration(projectConfig);
        project.Save();
        // Expected task's Status is "Completed", but actual is "Failed"
        AutomaticTask analyzeTask = project.RunAutomaticTask(
            project.GetTargetLanguageFiles().GetIds(),
            AutomaticTaskTemplateIds.AnalyzeFiles);
        Console.WriteLine($"AnalyzeFiles : {analyzeTask.Status}");
        Console.WriteLine(String.Join("\n", analyzeTask.Messages.Select(m => m.Exception)));
        project.Save();
    }
}

Analyze Exception Message (locale: ja-JP):

Sdl.ProjectAutomation.Core.ProjectAutomationException: Unexpected exception when initializing task 'ファイルの解析': 翻訳プロバイダ 'sdltm.example.com/.../my_tm_name' のインスタンスを作成できませんでした。. ---> Sdl.ProjectApi.ProjectApiException: Unexpected exception when initializing task 'ファイルの解析': 翻訳プロバイダ 'sdltm.example.com/.../my_tm_name' のインスタンスを作成できませんでした。. ---> Sdl.ProjectAutomation.Core.ProjectAutomationException: 翻訳プロバイダ 'sdltm.example.com/.../my_tm_name' のインスタンスを作成できませんでした。 ---> System.Collections.Generic.KeyNotFoundException: No identity information found for server 'http://example.com/'.
   場所 Sdl.Enterprise2.Platform.Client.IdentityModel.IdentityInfoCache.ValidateKey(String key)
   場所 Sdl.Enterprise2.Platform.Client.IdentityModel.IdentityInfoCache.GetIdentityInfo(String key)
   場所 Sdl.LanguagePlatform.TranslationMemoryApi.IdentityInfoCacheCredentialStore.GetCredential(Uri uri)
   場所 Sdl.LanguagePlatform.TranslationMemoryApi.TranslationProviderCredentialStore.GetCredential(Uri uri)
   場所 Sdl.LanguagePlatform.TranslationMemoryApi.ServerBasedTranslationMemoryFactory.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
   場所 Sdl.LanguagePlatform.TranslationMemoryApi.TranslationProviderManager.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
   場所 Sdl.ProjectApi.TranslationProviderCache.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
   場所 Sdl.ProjectApi.TranslationProviderCache.GetTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore, Boolean performUpdate, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.ProjectCascadeFactory.GetTranslationProviderLanguageDirection(TranslationProviderItem translationProviderItem, LanguagePair languageDirection, Boolean performUpdate, Boolean refreshCache)
   --- 内部例外スタック トレースの終わり ---
   場所 Sdl.ProjectAutomation.FileBased.Internal.AutomationServerEvents.HandleTranslationProviderException(TranslationProviderItem translationProviderItem, Exception exception)
   場所 Sdl.ProjectApi.Helpers.ProjectCascadeFactory.GetTranslationProviderLanguageDirection(TranslationProviderItem translationProviderItem, LanguagePair languageDirection, Boolean performUpdate, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.ProjectCascadeFactory.CreateProjectCascadeEntries(IList`1 projectCascadeEntryDataList, LanguagePair languagePair, Boolean readOnly, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.ProjectCascadeFactory.CreateCascade(ProjectCascadeSettings projectCascadeSettings, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.LanguageDirectionHelper.CreateCascade(ILanguageDirection languageDirection, ProjectCascadeEntryDataFilterFunction filter, IComparer`1 sort, Boolean readOnly, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.<>c__DisplayClass4.<GetRecognizers>b__3()
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetOrCreateObject(String key, Func`1 createObject)
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetRecognizers(ILanguageDirection languageDirection)
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetLanguageTools(ILanguageDirection languageDirection)
   場所 Sdl.ProjectApi.AutomaticTasks.Analysis.AnalysisDataCollectorX.CreateAnalysisDataStorage(ILanguageDirection languageDirection, AnalysisTaskSettings analysisSettings, TranslationMemorySettings translationMemorySettings, ILanguageObjectsCache objectsCache)
   場所 Sdl.ProjectApi.AutomaticTasks.Analysis.AnalysisDataCollectorX.Initialize(IList`1 files)
   場所 Sdl.ProjectApi.AutomaticTasks.Analysis.AnalysisTask.CreateAnalysisDataCollectors()
   場所 Sdl.ProjectApi.AutomaticTasks.Analysis.AnalysisTask.InitializeTask(IExecutingAutomaticTask task)
   場所 Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.InitializeTaskImplementations()
   --- 内部例外スタック トレースの終わり ---
   場所 Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.InitializeTaskImplementations()
   場所 Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.Execute()
   場所 Sdl.ProjectApi.Implementation.AutomaticTaskExecuter.Execute()
   --- 内部例外スタック トレースの終わり ---

PreTranslate Exception Message (locale: ja-JP): (change "AutomaticTaskTemplateIds.AnalyzeFiles" to "AutomaticTaskTemplateIds.PreTranslateFiles")
Sdl.ProjectAutomation.Core.ProjectAutomationException: Unexpected exception when configuring file multiFileConverter for task '一括翻訳': Failed to create an instance of translation provider 'sdltm.example.com/.../my_tm_name'.. ---> Sdl.ProjectApi.ProjectApiException: Unexpected exception when configuring file multiFileConverter for task '一括翻訳': Failed to create an instance of translation provider 'sdltm.example.com/.../my_tm_name'.. ---> Sdl.ProjectAutomation.Core.ProjectAutomationException: Failed to create an instance of translation provider 'sdltm.example.com/.../my_tm_name'. ---> System.Collections.Generic.KeyNotFoundException: No identity information found for server 'http://example.com/'.
   場所 Sdl.Enterprise2.Platform.Client.IdentityModel.IdentityInfoCache.ValidateKey(String key)
   場所 Sdl.Enterprise2.Platform.Client.IdentityModel.IdentityInfoCache.GetIdentityInfo(String key)
   場所 Sdl.LanguagePlatform.TranslationMemoryApi.IdentityInfoCacheCredentialStore.GetCredential(Uri uri)
   場所 Sdl.LanguagePlatform.TranslationMemoryApi.TranslationProviderCredentialStore.GetCredential(Uri uri)
   場所 Sdl.LanguagePlatform.TranslationMemoryApi.ServerBasedTranslationMemoryFactory.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
   場所 Sdl.LanguagePlatform.TranslationMemoryApi.TranslationProviderManager.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
   場所 Sdl.ProjectApi.TranslationProviderCache.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
   場所 Sdl.ProjectApi.TranslationProviderCache.GetTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore, Boolean performUpdate, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.ProjectCascadeFactory.GetTranslationProviderLanguageDirection(TranslationProviderItem translationProviderItem, LanguagePair languageDirection, Boolean performUpdate, Boolean refreshCache)
   --- 内部例外スタック トレースの終わり ---
   場所 Sdl.ProjectAutomation.FileBased.Internal.AutomationServerEvents.HandleTranslationProviderException(TranslationProviderItem translationProviderItem, Exception exception)
   場所 Sdl.ProjectApi.Helpers.ProjectCascadeFactory.GetTranslationProviderLanguageDirection(TranslationProviderItem translationProviderItem, LanguagePair languageDirection, Boolean performUpdate, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.ProjectCascadeFactory.CreateProjectCascadeEntries(IList`1 projectCascadeEntryDataList, LanguagePair languagePair, Boolean readOnly, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.ProjectCascadeFactory.CreateCascade(ProjectCascadeSettings projectCascadeSettings, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.LanguageDirectionHelper.CreateCascade(ILanguageDirection languageDirection, ProjectCascadeEntryDataFilterFunction filter, IComparer`1 sort, Boolean readOnly, Boolean refreshCache)
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetLanguageResources(ILanguageDirection languageDirection)
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.<>c__DisplayClass1.<GetLanguageResources>b__0()
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetOrCreateObject(String key, Func`1 createObject)
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetLanguageResources(IProject project, Language language)
   場所 Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetLanguageResources(ITranslatableFile file)
   場所 Sdl.ProjectApi.AutomaticTasks.AbstractContentProcessorTaskImplementation.AddSegmentorToConverter(IExecutingTaskFile executingTaskFile, IBilingualProcessorContainer multiFileConverter)
   場所 Sdl.ProjectApi.AutomaticTasks.AbstractTmContentProcessorTaskImplementation.ConfigureConverter(IExecutingTaskFile executingTaskFile, IMultiFileConverter multiFileConverter)
   場所 Sdl.ProjectApi.AutomaticTasks.Translate.TranslateTask.ConfigureConverter(IExecutingTaskFile executingTaskFile, IMultiFileConverter multiFileConverter)
   場所 Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.TaskFileExecuter.ConfigureConverter(IMultiFileConverter multiFileConverter, Language targetLanguage)
   --- 内部例外スタック トレースの終わり ---
   場所 Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.TaskFileExecuter.ConfigureConverter(IMultiFileConverter multiFileConverter, Language targetLanguage)
   場所 Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.TaskFileExecuter.CreateMultiFileConverter(IProjectFile tf, String filePath)
   場所 Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.TaskFileExecuter.Parse(String targetFilePath)
   --- 内部例外スタック トレースの終わり ---
Parents Reply Children
  • Romulus,

    Thanks for your support, and it solved my issue.

     

    diff --git a/Program.cs b/Program.cs
    index 9f2b26e..7f9523e 100644
    --- a/Program.cs
    +++ b/Program.cs
    @@ -40,8 +40,9 @@ class Program
             project.RunAutomaticTask(project.GetSourceLanguageFiles().GetIds(), AutomaticTaskTemplateIds.CopyToTargetLanguages);
             var projectConfig = project.GetTranslationProviderConfiguration();
    -        projectConfig.Entries.Add(new TranslationProviderCascadeEntry(new TranslationProviderReference(new Uri($"sdltm.{ServerUri}{Organization}{(Organization != "" ? "/" : "")}{TmName}")), true, true, false));
    -        project.Credentials.AddCredential(new Uri(ServerUri), $"user={UserName};password={Password};type=CustomUser");
    +        var tmUri = new Uri($"sdltm.{ServerUri}{Organization}{(Organization != "" ? "/" : "")}{TmName}");
    +        projectConfig.Entries.Add(new TranslationProviderCascadeEntry(new TranslationProviderReference(tmUri), true, true, false));
    +        project.Credentials.AddCredential(tmUri, $"user={UserName};password={Password};type=CustomUser");
             project.UpdateTranslationProviderConfiguration(projectConfig);
             project.Save();