SDL Studio 2017 API: GetTranslationMemories() takes ages

Hi

We have upgraded GroupShare to 2017 SR1 and are using the newest SDL Studio 2017 client.

The following code does not work: Credentials are correct, I am using sa user. I can get the ResourceGroups and Resources, but not the TMs.

TranslationProviderServer transProvider = new TranslationProviderServer(new Uri(Host), false, this.Credentials.UserName, this.Credentials.Password);

// it takes ages and nothing happens. The same code when connecting to GroupShare 2014 works as expected.
transProvider.GetTranslationMemories(TranslationMemoryProperties.None);

 

I also tried to get the TMs using a query: But I get an empty Array

TranslationMemoryQuery query = new TranslationMemoryQuery();
query.Properties = TranslationMemoryProperties.None;
query.IsMain = true;
query.IncludeChildResourceGroups = true;
var partTMs = transProvider.GetTranslationMemoriesByQuery(query).TranslationMemories;

Thanks for your help.

best

 

Arben

  • Hi Arben,

    There does seem to be a problem with the TM API GetTranslationMemories call which we will investigate and fix as soon as possible.

    Studio itself uses the GetTranslationMemoriesByQuery for the GroupShare TM browser dialog. It is designed to be used in a loop. The application sets the TranslationMemoryQuery Index and PageSize properties (e.g. Index = 0 to start from the 1st TM, and PageSize is the number of TMs to return). After each call the Index should be incremented by the page size until no TMs are returned. You could set the PageSize high to return all TMs in one call but this may result in HTTP timeouts depending on the performance of the GroupShare server. Studio uses a page size of 25. The paging of TUs allows the application more control of how the TMs are returned.

    The GetTranslationMemories is a wrapper around GetTranslationMemoriesByQuery and as you have found out, in the latest CU, the Index property does not seem to be incremented correctly.

    Best Regards,

    Iain.
  • Hi Iain

    Thanks for your answer. I already tried to use GetTranslationMemoriesByQuery before making this post. However I am getting an empty array and I know that on our GroupShare instance there are a lot of TMs.

    Am I missing anything?

    Example code:

    TranslationMemoryQuery query = new TranslationMemoryQuery();
    query.IsMain = true;
    query.Size = 500;
    query.IncludeChildResourceGroups = true;
    var page = tmManager2017.TmServer.GetTranslationMemoriesByQuery(query);

    -> page doesn't contain any TMs (independent of the query.Size or of any other query options). The user I am using is the "sa" user, so permissions shouldn't be a problem.

    And here the output from Fiddler:

    /api/tm-service/v1/tms?$count=true&$top=500&$skip=0&$orderby=Name%20asc&$filter=(tolower(OwnerId)%20eq%20'/')%20and%20(not%20Metadata/any()%20or%20Metadata/any(m:%20m/Key%20eq%20'IsProjectTm'%20and%20m/Value%20eq%20'false')%20or%20Metadata/any(m:%20m/Key%20ne%20'IsProjectTm

    What I do not understand is the $filter that is passed with the query. How can I modify this filter options?

    And what does this mean: tolower(OwnerId)%20eq%20'/' 

    -> is OwnerId the ResourceGroupPath? Cause as OwnerId the ResouceGroupPath i passed and in my query it is the Root Oragnization with path "/". 

    If OwnerId is something different then I think a wrong value is passed to the query.

     

    best

     

    arben

  • Hi Arben,

    For getting all TMs, try setting the query.ResourceGroupPath to null or empty string for GroupShare 2017?

    Changing certain TranslationMemoryQuery properties (e.g languages) will change the filter string.

    Best Regards,

    Iain.
  • Hi Iain
    Having the very same Problem with listing server TMs from a Studio 2017 SR1 Installation programmatically I would like to ask you if you could post a code snippet that does exactly what you have stated above. I simply don't know how to implement it.
    Thank you in advance
    Victor
  • Hi Victor

    This is my implementation:

    var translationprovider = new TranslationProviderServer(new Uri(Host), false, userName, password);
    TranslationMemoryQuery query = new TranslationMemoryQuery();
    query.IsMain = true;
    query.ResourceGroupPath = "";
    query.Size = 500;
    query.IncludeChildResourceGroups = true;
    List<ServerBasedTranslationMemory> tempList = new List<ServerBasedTranslationMemory>();
    List<ServerBasedTranslationMemory> allTMs = new List<ServerBasedTranslationMemory>();
    do {

    tempList = translationprovider.GetTranslationMemoriesByQuery(query).TranslationMemories.ToList();
    allTMs.AddRange(tempList);
    query.Index += query.Size;
    }
    while (tempList.Count > 0);

    Hope it helps.

  • Hi  ,

     for us this workaround does not work, because we haven 7,700 TMs on the server and when I call all (by setting query.ResourceGroupPath = "" ) then I get an exception "One or more errors occured". Therefore, I need to restrict my query to certain organizations by setting query.ResourceGroupPath = "/foo/bar". However, then again I get an empty array back as described above by  (even though the organization exists with TMs).

    (When I set query.Size = 2500 then I successfully get the first 2500 TMs with query.ResourceGroupPath = "" , but of course this does not help, because I need to have the full list of TMs to compare the existing names against the TM name pattern of my TM search query).


    Any hints how to work around this? Any fix in sight?

    Best wishes,
    Simon