GroupShare 2017 TM Server API issue

Former Member
Former Member

Hi,

 

I need your help about GroupShare 2017 API.

Customer is facing issue about GS 2017 TM server API.

 

Symptom

Code which worked fine with SDL Trados Server 2015 fails with GroupShare 2017.

- Adding Server-based to project and exectuting "AnalyzeFile" task, it ralis and ProjectAutomationExceptionga is throuwn.

- The same error happens on Sdl.SDK.ProjectAutomation.Samples.BatchAnalyze prvided by SDL.

 

Attached files

Code.txt … customer’s code.

Task messages.txt… error message.

 

Question

How can "AnalyzeFiles" task be executed wih SDL Trados Server 2017's server-based TM?

 

Expected Result

- analyzeTask.Status should be "completed".

- The length of analyzeTask.Messages should be 0.

 

Current Result

- analyzeTask.Status indicates "failed".

- analyzeTask.Messages includes ProjectAutomationException alwais.

 

If this issue is due to change of API specification, could you please give me some advice to modify the code so that it can work with GS 2017 TM Server.

Many thanks in advance.

Parents
  • Former Member
    0 Former Member

    Sample Code:

            private const string ServerUri = "http://example.localnet/";
            private const string TmUri = "sdltm." + ServerUri + "TestOrg/TradosSample";
            private const string UserName = "*****";
            private const string Password = "*****";

            var info = new ProjectInfo { /* ... */ };
            var project = new FileBasedProject(info);
            project.AddFiles(new string[] { /* ... */ });
            var scan = project.RunAutomaticTask(
                project.GetSourceLanguageFiles().GetIds(),
                AutomaticTaskTemplateIds.Scan
                );
            Uri tmAddress = new Uri(TmUri);
            TranslationProviderConfiguration config = project.GetTranslationProviderConfiguration();
            TranslationProviderCascadeEntry tm = new TranslationProviderCascadeEntry(
                new TranslationProviderReference(tmAddress),
                true,
                true, // value 'false' causes "ArgumentException" when call project.UpdateTranslationProviderConfiguration
                false);
            config.Entries.Add(tm);
            project.UpdateTranslationProviderConfiguration(config);
    //      project.Credentials.AddCredential(new Uri(ServerUri), false, UserName, Password);
            project.Credentials.AddCredential(new Uri(ServerUri), $"user={UserName};password={Password};type=CustomUser");
            project.UpdateTranslationProviderConfiguration(config);
            ProjectFile[] files = project.GetSourceLanguageFiles();
            foreach (var file in files)
            {
                if (file.Role != FileRole.Translatable)
                {
                    continue;
                }
                Guid[] currentFileId = { file.Id };
                AutomaticTask convertTask = project.RunAutomaticTask(
                    currentFileId,
                    AutomaticTaskTemplateIds.ConvertToTranslatableFormat);
                AutomaticTask copyTask = project.RunAutomaticTask(
                    currentFileId,
                    AutomaticTaskTemplateIds.CopyToTargetLanguages);
            }
            // 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)));

     

    Task messages:

    Sdl.ProjectAutomation.Core.ProjectAutomationException: Unexpected exception when initializing task 'Analyze Files': Translation Provider 'sdltm.example.localnet/.../TradosSample' Couldn't create instance. ---> Sdl.ProjectApi.ProjectApiException: Unexpected exception when initializing task 'Analyze Files': Translation Provider 'sdltm.example.localnet/.../TradosSample' Couldn't create instance. ---> Sdl.ProjectAutomation.Core.ProjectAutomationException: Translation Provider 'sdltm.example.localnet/.../TradosSample' Couldn't create instance ---> System.Collections.Generic.KeyNotFoundException: No identity information found for server 'http://example.localnet/'.
       Location Sdl.Enterprise2.Platform.Client.IdentityModel.IdentityInfoCache.ValidateKey(String key)
       Location Sdl.Enterprise2.Platform.Client.IdentityModel.IdentityInfoCache.GetIdentityInfo(String key)
       Location Sdl.LanguagePlatform.TranslationMemoryApi.IdentityInfoCacheCredentialStore.GetCredential(Uri uri)
       Location Sdl.LanguagePlatform.TranslationMemoryApi.TranslationProviderCredentialStore.GetCredential(Uri uri)
       Location Sdl.LanguagePlatform.TranslationMemoryApi.ServerBasedTranslationMemoryFactory.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
       Location Sdl.LanguagePlatform.TranslationMemoryApi.TranslationProviderManager.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
       Location Sdl.ProjectApi.TranslationProviderCache.CreateTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore)
       Location Sdl.ProjectApi.TranslationProviderCache.GetTranslationProvider(Uri translationProviderUri, String translationProviderState, ITranslationProviderCredentialStore credentialStore, Boolean performUpdate, Boolean refreshCache)
       Location Sdl.ProjectApi.Helpers.ProjectCascadeFactory.GetTranslationProviderLanguageDirection(TranslationProviderItem translationProviderItem, LanguagePair languageDirection, Boolean performUpdate, Boolean refreshCache)
       --- End of inner exception stack trace ---
       Location Sdl.ProjectAutomation.FileBased.Internal.AutomationServerEvents.HandleTranslationProviderException(TranslationProviderItem translationProviderItem, Exception exception)
       Location Sdl.ProjectApi.Helpers.ProjectCascadeFactory.GetTranslationProviderLanguageDirection(TranslationProviderItem translationProviderItem, LanguagePair languageDirection, Boolean performUpdate, Boolean refreshCache)
       Location Sdl.ProjectApi.Helpers.ProjectCascadeFactory.CreateProjectCascadeEntries(IList`1 projectCascadeEntryDataList, LanguagePair languagePair, Boolean readOnly, Boolean refreshCache)
       Location Sdl.ProjectApi.Helpers.ProjectCascadeFactory.CreateCascade(ProjectCascadeSettings projectCascadeSettings, Boolean refreshCache)
       Location Sdl.ProjectApi.Helpers.LanguageDirectionHelper.CreateCascade(ILanguageDirection languageDirection, ProjectCascadeEntryDataFilterFunction filter, IComparer`1 sort, Boolean readOnly, Boolean refreshCache)
       Location Sdl.ProjectApi.Helpers.LanguageObjectsCache.<>c__DisplayClass4.<GetRecognizers>b__3()
       Location Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetOrCreateObject(String key, Func`1 createObject)
       Location Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetRecognizers(ILanguageDirection languageDirection)
       Location Sdl.ProjectApi.Helpers.LanguageObjectsCache.GetLanguageTools(ILanguageDirection languageDirection)
       Location Sdl.ProjectApi.AutomaticTasks.Analysis.AnalysisDataCollectorX.CreateAnalysisDataStorage(ILanguageDirection languageDirection, AnalysisTaskSettings analysisSettings, TranslationMemorySettings translationMemorySettings, ILanguageObjectsCache objectsCache)
       Location Sdl.ProjectApi.AutomaticTasks.Analysis.AnalysisDataCollectorX.Initialize(IList`1 files)
       Location Sdl.ProjectApi.AutomaticTasks.Analysis.AnalysisTask.CreateAnalysisDataCollectors()
       Location Sdl.ProjectApi.AutomaticTasks.Analysis.AnalysisTask.InitializeTask(IExecutingAutomaticTask task)
       Location Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.InitializeTaskImplementations()
       --- End of inner exception stack trace ---
       Location Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.InitializeTaskImplementations()
       Location Sdl.ProjectApi.Implementation.TaskExecution.ContentProcessingTaskImplementation.Execute()
       Location Sdl.ProjectApi.Implementation.AutomaticTaskExecuter.Execute()
       --- End of inner exception stack trace ---

  • Can you please try and save the project before you run the analysis? Also can you please let me know if you have any Trados Studio 2017 updates installed?

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/



  • I started looking into github.com/.../groupsharekit.net with the hopes that it would include some sample on using what you suggested: GS2017 CU4 makes the analysis reports available via the REST API so it might be a better and simpler alternative to just retrieve the analysis using the REST API rather than rely on Trados Studio Project Automation API.
    But, I cannot see where in that code AnalysisReport is used. Can you additional information on how to use AnalysisReport?

    Also, has anyone been able to resolve the issue with ProjectBased API yet?

    Thank you!
    Rieko
  • Hi Rieko,

    The project for what you want to run the Analysis must be created from Groupshare. Is not working for projects created in Studio and published in GS.

    This is a code sample on how you can use Analyse report from GroupShare Kit:

    public async Task AnalysisReports()
    {
    var groupShareClient = await Helper.GetGroupShareClient();
    var report = await groupShareClient.Project.GetAnalysisReports("522dde85-7f5b-4aa5-a4d9-af97d78798f2", "en-US");
    Assert.True(report.Count > 0);
    }

     

    More code sample on how you can use the library you can find here.

    Kind regards,

    Andrea.

  • Hi ,

    Thank you for your answer! The fact that project must be created from groupshare is a big concern for our company because we have heavy projects with millions of words run in parallel in several languages. So, we have to go back to solving the issue with ProjectAutomation API.

    ,
    Have you had a chance to look at error stack trace I submitted a while back in August 9? Will that give you any clue as to what I need to fix?

    Thank you very much!
    Rieko
  • Hi Rieko,

    This seems to be a product in the product. Can you please raise this issue with support?

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • I just made some tests around this issue which where able to reproduce. There are few things to be considered:

    1. For TM address make sure to use this format new Uri($"sdltm.{ServerUri}{Organization}{(Organization != "" ? "/" : "")}{TmName}"); 
    2. When adding credentials make sure the URI from point 1 is used.

    You can also have a look at the sample code here. I used for testing with which I had similar problems before I adjusted it according to above points.

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • Hi 

    I got your sample code to work in our environment!  

    But, your sample code seems to only work with SDL credential.  If I set useWindowsAuthentication to true, and use windows username and password, then, the code comes back with error...

    Invoke Node System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.  Inner Exception: System.ArgumentException: Requested value 'Windows' was not found.  

    Have you ever tested your code using windows credential?

    project.Credentials.AddCredential(tmAddress, true, UserName, Password);

    I have also tried using Uri("http://nicgroupshare-test:80") as tmAddress input (as suggested on this page http://producthelp.sdl.com/SDK/ProjectAutomationApi/3.0/html/388c870e-0e80-4381-a46a-fe57821571f9.htm), but then the analysis automatic task fails with

    Unexpected exception when initializing task 'Analyze Files': Failed to create an instance of translation provider 'sdltm.http://nicgroupshare-test:80/?orgPath=/All Languages/Asian Languages/Japanese&tmName=Japanese RnD Test'..

    What else can I try?

    Thank you!

    Rieko

  • Former Member
    0 Former Member in reply to Rieko Matsunaga
    Hi ,

    I tried to reproduce your problem using windows credentials, but for me the 'Analyze Files' task works fine. I will add my sample code here to see if it works for you. Also, I know you are using CU05 version of GroupShare2017, which is before SR1. We would recommend updating to CU06 and this will include the SR1 release.

    Sample Code:

    private const string ServerUri = "http[s]://HOSTNAME:PORT/";
    private const string UserName = "username";
    private const string Password = "password";
    private const string Organization = "organization name";
    private const string TmName = "tmName";


    private const string SourceCultureName = "en-US";
    private const string TargetCultureName = "de-DE";
    private const string SourceFileName = @"source file path";

    var info = new ProjectInfo
    {
    Name = Path.GetFileName(SourceFileName),
    LocalProjectFolder = @"local project folder",
    SourceLanguage = new Language(SourceCultureName),
    TargetLanguages = new[] { new Language(TargetCultureName) }
    };
    if (Directory.Exists(info.LocalProjectFolder))
    {
    Directory.Delete(info.LocalProjectFolder, true);
    }
    FileBasedProject project = new FileBasedProject(info);

    project.AddFiles(new[] { SourceFileName });

    var scan = project.RunAutomaticTask(
    project.GetSourceLanguageFiles().GetIds(),
    AutomaticTaskTemplateIds.Scan
    );

    Uri tmAddress = new Uri($"sdltm.{ServerUri}{Organization}{(Organization != "" ? "/" : "")}{TmName}");
    TranslationProviderConfiguration config = project.GetTranslationProviderConfiguration();
    TranslationProviderCascadeEntry tm = new TranslationProviderCascadeEntry(
    new TranslationProviderReference(tmAddress),
    true,
    true,
    false);

    config.Entries.Add(tm);
    project.UpdateTranslationProviderConfiguration(config);
    project.Credentials.AddCredential(new Uri("http[s]://HOSTNAME:PORT:80"), true, UserName, Password);
    project.UpdateTranslationProviderConfiguration(config);

    ProjectFile[] files = project.GetSourceLanguageFiles();
    foreach (var file in files)
    {
    if (file.Role != FileRole.Translatable)
    {
    continue;
    }
    Guid[] currentFileId = { file.Id };
    AutomaticTask convertTask = project.RunAutomaticTask(
    currentFileId,
    AutomaticTaskTemplateIds.ConvertToTranslatableFormat);
    AutomaticTask copyTask = project.RunAutomaticTask(
    currentFileId,
    AutomaticTaskTemplateIds.CopyToTargetLanguages);
    }

    // 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)));

    Regards,
    Alexandru-Constantin Pascariu
  • Hi

    It seems that this line is about the only difference from Romulus' code:

    project.Credentials.AddCredential(new Uri("https://HOSTNAME:PORT:80"), true, UserName, Password);

    First, what is the sleep icon that I see after http?
    Second, if that meant https, then why are you using :80? Doesn't :80 only work with http?
    Third, why do you have :PORT and then :80 ?
    Fourth, in your environment do you have https enabled inside your firewall? (We don't)


    I have tried the following address to create Uri:
    http://nicgroupshare-test:80
    https://nicgroupshare-test:80
    https://nicgroupshare-test:443
    But, following is the message I get with analyzeTask.Messages.Select(m => m.Exception)

    Unexpected exception when initializing task 'Analyze Files': Failed to create an instance of translation provider 'sdltm.nicgroupshare-test:80/ Languages/Asian Languages/Japanese&tmName=Japanese RnD Test'..

    What am I doing wrong?

    Thank you!
    Rieko
  • Former Member
    0 Former Member in reply to Rieko Matsunaga

    Hi Rieko Matsunaga (rieko.matsunaga)

    I'm sorry for the confusion, I meant to write http(s)://HostName:Port, for testing I used the "80" port because we had http not https. From what I see, you still receive the same error. Have you considered updating GroupShare to CU06 and check if the error persists?

    Regards,

    Alexandru-Constantin Pascariu

  • Hi  ,

    Updating GroupShare to CU06 did not resolve the problem. So, now, I decided to attempt at creating a project using VC#!
    Building the project was successful, but when I tried to run the executable, I get this error... Can you help me figure out why this error occurs?

    ----------------------------------
    C:\Program Files (x86)\SDL\SDL Trados Studio\Studio5>Samples.BatchAnalyze.exe
    log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />

    ハンドルされていない例外: System.BadImageFormatException: ファイルまたはアセンブリ 'SDLTradosStudio'、またはその依存関係の 1 つが読み込めませんでした。間違ったフォーマットのプログラムを読み込もうとしました。
    場所 System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
    場所 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
    場所 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
    場所 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
    場所 System.Reflection.Assembly.Load(String assemblyString)
    場所 Sdl.Core.Globalization.LocalizableString.LoadResourceString(String embeddedResourceName)
    場所 Sdl.Desktop.Platform.Implementation.Services.UserProfile.ReadHeader()
    場所 Sdl.Desktop.Platform.Implementation.Services.UserSettingsService.EnsureLoaded()
    場所 Sdl.Desktop.Platform.Implementation.Services.UserSettingsService.get_UserSettings()
    場所 Sdl.ProjectAutomation.FileBased.FileBasedProject.GetDefaultProjectTemplateReference()
    場所 Samples.BatchAnalyze.Program.Main(String[] args) 場所 C:\temp\Samples.BatchAnalyze\Samples.BatchAnalyze\Program.cs:行 45
    ------------------------------------

     

    Here is my code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Globalization;
    using System.IO;
    using Sdl.Core.Globalization;
    using Sdl.Core.Settings;
    using Sdl.LanguagePlatform.TranslationMemoryApi;
    using Sdl.ProjectAutomation.Core;
    using Sdl.ProjectAutomation.FileBased;
    using Sdl.ProjectAutomation.Settings;

     

    namespace Samples.BatchAnalyze
    {
    class Program
    {
    private const string ServerUri = "http://nicgroupshare-test:80/";
    private const string UserName = "amer\riekom";
    private const string Password = "mypassword";

    private const string Organization = "/All Languages/Asian Languages/Japanese";
    private const string TmName = "Japanese RnD Test";
    private const string SourceCultureName = "en-US";
    private const string TargetCultureName = "ja-JP";
    private const string SourceFileName = @"C:\SourceFiles\rtapp_0.trsc.strings.xml";
    private const string LocalProjectFolder = @"C:\temp3";
    static void Main(string[] args)
    {
    var info = new ProjectInfo
    {
    Name = Path.GetFileName(SourceFileName),
    LocalProjectFolder = LocalProjectFolder,
    SourceLanguage = new Language(SourceCultureName),
    TargetLanguages = new[] { new Language(TargetCultureName) }
    };


    if (Directory.Exists(info.LocalProjectFolder))
    {
    Directory.Delete(info.LocalProjectFolder, true);
    }
    FileBasedProject project = new FileBasedProject(info);

    project.AddFiles(new[] { SourceFileName });

    var scan = project.RunAutomaticTask(
    project.GetSourceLanguageFiles().GetIds(),
    AutomaticTaskTemplateIds.Scan
    );

    Uri tmAddress = new Uri($"sdltm.{ServerUri}{Organization}{(Organization != "" ? "/" : "")}{TmName}");
    TranslationProviderConfiguration config = project.GetTranslationProviderConfiguration();
    TranslationProviderCascadeEntry tm = new TranslationProviderCascadeEntry(
    new TranslationProviderReference(tmAddress),
    true,
    true,
    false);

    config.Entries.Add(tm);
    project.UpdateTranslationProviderConfiguration(config);
    project.Credentials.AddCredential(new Uri(ServerUri), true, UserName, Password);
    project.UpdateTranslationProviderConfiguration(config);

    ProjectFile[] files = project.GetSourceLanguageFiles();
    foreach (var file in files)
    {
    if (file.Role != FileRole.Translatable)
    {
    continue;
    }
    Guid[] currentFileId = { file.Id };
    AutomaticTask convertTask = project.RunAutomaticTask(
    currentFileId,
    AutomaticTaskTemplateIds.ConvertToTranslatableFormat);
    AutomaticTask copyTask = project.RunAutomaticTask(
    currentFileId,
    AutomaticTaskTemplateIds.CopyToTargetLanguages);
    }

    // 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)));
    }
    }
    }

Reply
  • Hi  ,

    Updating GroupShare to CU06 did not resolve the problem. So, now, I decided to attempt at creating a project using VC#!
    Building the project was successful, but when I tried to run the executable, I get this error... Can you help me figure out why this error occurs?

    ----------------------------------
    C:\Program Files (x86)\SDL\SDL Trados Studio\Studio5>Samples.BatchAnalyze.exe
    log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />

    ハンドルされていない例外: System.BadImageFormatException: ファイルまたはアセンブリ 'SDLTradosStudio'、またはその依存関係の 1 つが読み込めませんでした。間違ったフォーマットのプログラムを読み込もうとしました。
    場所 System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
    場所 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
    場所 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection)
    場所 System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
    場所 System.Reflection.Assembly.Load(String assemblyString)
    場所 Sdl.Core.Globalization.LocalizableString.LoadResourceString(String embeddedResourceName)
    場所 Sdl.Desktop.Platform.Implementation.Services.UserProfile.ReadHeader()
    場所 Sdl.Desktop.Platform.Implementation.Services.UserSettingsService.EnsureLoaded()
    場所 Sdl.Desktop.Platform.Implementation.Services.UserSettingsService.get_UserSettings()
    場所 Sdl.ProjectAutomation.FileBased.FileBasedProject.GetDefaultProjectTemplateReference()
    場所 Samples.BatchAnalyze.Program.Main(String[] args) 場所 C:\temp\Samples.BatchAnalyze\Samples.BatchAnalyze\Program.cs:行 45
    ------------------------------------

     

    Here is my code:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Globalization;
    using System.IO;
    using Sdl.Core.Globalization;
    using Sdl.Core.Settings;
    using Sdl.LanguagePlatform.TranslationMemoryApi;
    using Sdl.ProjectAutomation.Core;
    using Sdl.ProjectAutomation.FileBased;
    using Sdl.ProjectAutomation.Settings;

     

    namespace Samples.BatchAnalyze
    {
    class Program
    {
    private const string ServerUri = "http://nicgroupshare-test:80/";
    private const string UserName = "amer\riekom";
    private const string Password = "mypassword";

    private const string Organization = "/All Languages/Asian Languages/Japanese";
    private const string TmName = "Japanese RnD Test";
    private const string SourceCultureName = "en-US";
    private const string TargetCultureName = "ja-JP";
    private const string SourceFileName = @"C:\SourceFiles\rtapp_0.trsc.strings.xml";
    private const string LocalProjectFolder = @"C:\temp3";
    static void Main(string[] args)
    {
    var info = new ProjectInfo
    {
    Name = Path.GetFileName(SourceFileName),
    LocalProjectFolder = LocalProjectFolder,
    SourceLanguage = new Language(SourceCultureName),
    TargetLanguages = new[] { new Language(TargetCultureName) }
    };


    if (Directory.Exists(info.LocalProjectFolder))
    {
    Directory.Delete(info.LocalProjectFolder, true);
    }
    FileBasedProject project = new FileBasedProject(info);

    project.AddFiles(new[] { SourceFileName });

    var scan = project.RunAutomaticTask(
    project.GetSourceLanguageFiles().GetIds(),
    AutomaticTaskTemplateIds.Scan
    );

    Uri tmAddress = new Uri($"sdltm.{ServerUri}{Organization}{(Organization != "" ? "/" : "")}{TmName}");
    TranslationProviderConfiguration config = project.GetTranslationProviderConfiguration();
    TranslationProviderCascadeEntry tm = new TranslationProviderCascadeEntry(
    new TranslationProviderReference(tmAddress),
    true,
    true,
    false);

    config.Entries.Add(tm);
    project.UpdateTranslationProviderConfiguration(config);
    project.Credentials.AddCredential(new Uri(ServerUri), true, UserName, Password);
    project.UpdateTranslationProviderConfiguration(config);

    ProjectFile[] files = project.GetSourceLanguageFiles();
    foreach (var file in files)
    {
    if (file.Role != FileRole.Translatable)
    {
    continue;
    }
    Guid[] currentFileId = { file.Id };
    AutomaticTask convertTask = project.RunAutomaticTask(
    currentFileId,
    AutomaticTaskTemplateIds.ConvertToTranslatableFormat);
    AutomaticTask copyTask = project.RunAutomaticTask(
    currentFileId,
    AutomaticTaskTemplateIds.CopyToTargetLanguages);
    }

    // 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)));
    }
    }
    }

Children
  • It turns out the below error was occuring because I had Target CPU set to 64-bit 

    ハンドルされていない例外: System.BadImageFormatException: ファイルまたはアセンブリ 'SDLTradosStudio'、またはその依存関係の 1 つが読み込めませんでした。間違ったフォーマットのプログラムを読み込もうとしました。

    Yup, I overlooked the comment made in http://producthelp.sdl.com/SDK/ProjectAutomationApi/2017/html/0d5fd16a-7393-4a22-be62-7ac1722be0f0.htm  Once I changed the Target CPU to x86, and rebuild, other errors came up.

    First, it complains that I need .NET Framework 3.5.  This seems to contradict what's mentioned here:  http://producthelp.sdl.com/SDK/ProjectAutomationApi/2017/html/acb28118-5b68-463b-8366-1dfe02637e7b.htm 

    But reading above page makes me wonder... Does all these work in Windows 10 version 1709?

    If we can ignore above issues, then here's the error I got:

    ----------------------------------

    ハンドルされていない例外: Sdl.ProjectAutomation.FileBased.LicensingException: License check failed, with exception: Sdl.Core.PluginFramework.PluginFrameworkException: Cannot validate SDL plug-in: Sdl.Common.Licensing.Provider.SafeNetRMS.SafeNetRMSicensingProviderFactory, Sdl.Common.Licensing.Provider.SafeNetRMS, Version=5.0.0.0, Culture=neutral, PublicKeyToken=c28cdb26c445c888 : C:\Program Files (x86)\SDL\SDL Trados Studio\Studio5\Sdl.Common.Licensing.Provider.SafeNetRMS.dll
       場所 Sdl.Core.PluginFramework.DefaultPluginTypeLoader.LoadType(IPlugin plugin, String typeName)
       場所 Sdl.Core.PluginFramework.Implementation.Extension.get_ExtensionType()
       場所 Sdl.Core.PluginFramework.Implementation.Extension.CreateInstance()
       場所 Sdl.Core.PluginFramework.ObjectRegistry`2.CreateObjects()
       場所 Sdl.Common.Licensing.Provider.Core.LicensingProviderManager.get_LicensingProviderFactories()
       場所 Sdl.Common.Licensing.Provider.Core.LicensingProviderManager.CreateProvider(ILicensingProviderConfiguration config, String preferredProviderId)
       場所 Sdl.Common.Licensing.Manager.ApplicationLicenseManager.GetCurrentLicensingProvider()
       場所 Sdl.Common.Licensing.Manager.ApplicationLicenseManager.GetProduct()
       場所 Sdl.Common.Licensing.Manager.ApplicationLicenseManager.GetLicenseWithoutConsumingSeatsOrUsages()
       場所 Sdl.ProjectAutomation.FileBased.FileBasedProject.CheckLicense() ---> Sdl.Core.PluginFramework.PluginFrameworkException: Cannot validate SDL plug-in: Sdl.Common.Licensing.Provider.SafeNetRMS.SafeNetRMSicensingProviderFactory, Sdl.Common.Licensing.Provider.SafeNetRMS, Version=5.0.0.0, Culture=neutral, PublicKeyToken=c28cdb26c445c888 : C:\Program Files (x86)\SDL\SDL Trados Studio\Studio5\Sdl.Common.Licensing.Provider.SafeNetRMS.dll
       場所 Sdl.Core.PluginFramework.DefaultPluginTypeLoader.LoadType(IPlugin plugin, String typeName)
       場所 Sdl.Core.PluginFramework.Implementation.Extension.get_ExtensionType()
       場所 Sdl.Core.PluginFramework.Implementation.Extension.CreateInstance()
       場所 Sdl.Core.PluginFramework.ObjectRegistry`2.CreateObjects()
       場所 Sdl.Common.Licensing.Provider.Core.LicensingProviderManager.get_LicensingProviderFactories()
       場所 Sdl.Common.Licensing.Provider.Core.LicensingProviderManager.CreateProvider(ILicensingProviderConfiguration config, String preferredProviderId)
       場所 Sdl.Common.Licensing.Manager.ApplicationLicenseManager.GetCurrentLicensingProvider()
       場所 Sdl.Common.Licensing.Manager.ApplicationLicenseManager.GetProduct()
       場所 Sdl.Common.Licensing.Manager.ApplicationLicenseManager.GetLicenseWithoutConsumingSeatsOrUsages()
       場所 Sdl.ProjectAutomation.FileBased.FileBasedProject.CheckLicense()
       --- 内部例外スタック トレースの終わり ---
       場所 Sdl.ProjectAutomation.FileBased.FileBasedProject.CheckLicense()
       場所 Sdl.ProjectAutomation.FileBased.FileBasedProject..ctor(ProjectInfo projectInfo, ProjectTemplateReference templateReference)
       場所 Samples.BatchAnalyze.Program.Main(String[] args) 場所 C:\temp\Samples.BatchAnalyze\Samples.BatchAnalyze\Program.cs:行 45

    ------------------------------------

    I did not make any change to the code.  Thanks for looking into this!

    Rieko

  • Hi

    Another progress! It seems that things do work a bit better with .NET 3.5 installed on Windows 10. In fact, I run following command with mounted ISO:
    Dism /online /enable-feature /featurename:NetFx3 /All /Source:i:\sources\sxs /LimitAccess
    With above done, I was able to run the app with SDL authentication. But when I used windows authentication, following error occured:
    ------------------------------------
    C:\Program Files (x86)\SDL\SDL Trados Studio\Studio5>Samples.BatchAnalyze.exe
    log4net:ERROR XmlConfigurator: Failed to find configuration section 'log4net' in the application's .config file. Check your .config file for the <log4net> and <configSections> elements. The configuration section should look like: <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net" />
    AnalyzeFiles : Failed
    Sdl.ProjectAutomation.Core.ProjectAutomationException: Unexpected exception when initializing task 'ファイルの解析': 翻 訳プロバイダ 'sdltm.nicgroupshare-test:80/.../All Languages/Asian Languages/Japanese/Japanese RnD Test' のインスタンスを作成できませんでした。. ---> Sdl.ProjectApi.ProjectApiException: Unexpected exception when initializing task 'ファイルの解析': 翻訳プロバイダ 'sdltm.nicgroupshare-test:80/.../All Languages/Asian Languages/Japanese/Japanese RnD Test' のインスタンスを作成できませんでした。. ---> Sdl.ProjectAutomation.Core.ProjectAutomationException: 翻訳プロバイダ 'sdltm.nicgroupshare-test:80/.../All Languages/Asian Languages/Japanese/Japanese RnD Test' のインスタンスを作成できませ んでした。 ---> System.Collections.Generic.KeyNotFoundException: No identity information found for server 'http://nicgroupshare-test/'.
    場所 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__DisplayClass5_0.<GetRecognizers>b__0()
    場所 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()
    --- 内部例外スタック トレースの終わり ---

    C:\Program Files (x86)\SDL\SDL Trados Studio\Studio5>
    ------------------------------------

    So, I'd say even with Visual C# code, the error we are getting is the same. But could this error give you better insight in debugging?

    Thanks!
    Rieko