Unable to correctly programmatically declare server-based termbases

I'm having a problem programmatically adding server-based termbases to a project.

I have the following code (C#):

    TermbaseConfiguration termbaseConfig = project.GetTermbaseConfiguration();
    termbaseConfig.TermbaseServerUri = "http://our.server.url/groupshare/";
    termbaseConfig.Termbases.AddRange(termbases.Select(t => new ServerTermbase(t.Name, null, true)));

When I open this project in Trados the termbase is greyed-out, the "Enabled" checkbox is unchecked (even though the .sdlproj file contains <Enabled>true</Enabled>) and there is a red circle with a cross next to the termbase name (instead of a green circle with a tick).

So I compared the programmatically-generated .sdlproj file with one created by Trados and referencing the same TM and termbase.

Trados-generated project file:

    <Termbases>
        <Name>MY_TERMBASE_NAME</Name>
        <SettingsXml>&lt;?xml version="1.0" encoding="utf-16"?&gt;
    &lt;TermbaseSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;Path&gt;sdltb.http://our.server.url/groupshare/\%\MY_TERMBASE_NAME&lt;/Path&gt;
      &lt;IsOpen&gt;false&lt;/IsOpen&gt;
      &lt;Filter&gt;0&lt;/Filter&gt;
      &lt;FilterHighlight&gt;false&lt;/FilterHighlight&gt;
      &lt;Layout&gt;0&lt;/Layout&gt;
      &lt;Local&gt;false&lt;/Local&gt;
      &lt;IsCustom&gt;false&lt;/IsCustom&gt;
    &lt;/TermbaseSettings&gt;</SettingsXml>
        <Enabled>true</Enabled>
    </Termbases>

And here is the programmatically-generated equivalent:

    <Termbases>
        <Name>MY_TERMBASE_NAME</Name>
        <SettingsXml>&lt;?xml version="1.0" encoding="utf-16"?&gt;
    &lt;TermbaseSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
      &lt;Path&gt;our.server.url\%\MY_TERMBASE_NAME&lt;/Path&gt;
      &lt;IsOpen&gt;false&lt;/IsOpen&gt;
      &lt;Filter&gt;0&lt;/Filter&gt;
      &lt;FilterHighlight&gt;false&lt;/FilterHighlight&gt;
      &lt;Layout&gt;0&lt;/Layout&gt;
      &lt;Local&gt;false&lt;/Local&gt;
      &lt;IsCustom&gt;false&lt;/IsCustom&gt;
    &lt;/TermbaseSettings&gt;</SettingsXml>
        <Enabled>true</Enabled>
    </Termbases>

In case it's not obvious, the difference is the "Path" node in the escaped XML...

Trados-generated:

    &lt;Path&gt;sdltb.http://our.server.url/groupshare/\%\MY_TERMBASE_NAME&lt;/Path&gt;

programmatically-generated:

    &lt;Path&gt;our.server.url\%\MY_TERMBASE_NAME&lt;/Path&gt;

The Trados-generated code has the correct URL.

Note that the .sdlproj file also contains the following nodes, which are correct in both the Trados-generated and programmatically-generated versions:

    <TermbaseServer>
        <ServerConnectionUri>http://our.server.url/groupshare/</ServerConnectionUri>
    </TermbaseServer>

I've found that even if I force the TermbaseServerUri property with

    termbaseConfig.TermbaseServerUri = "sdltb.http://our.server.url/groupshare/";

the output is still the same. It uses the correct value for the <ServerConnectionUri> node but not inside the <SettingsXml> nodes.

Can anyone explain why my code results in the termbase being declared differently in the project file? And does this explain why the termbase is greyed-out and not enabled when the project is viewed in Trados?

Parents
  • Hi Andrew,
    I can confirm this problem. I mentioned this on github last week to regarding the applystudioprojecttemplate plugin. The function UpdateTermbaseConfiguration(targetTermbaseConfig) does not the job correctly.
    As a workaround, until this function gets repaired, I make a search/replace correction directly in the sdlproj file.
    Kind regards
    Sébastien
  • Hi Andrew

    The workaround from Sébastian is OK if you create packages. If you use GroupShare you have to change the Uri in the table.

    ConcurrentDictionary<int, string> oCD_TermBaseId__SettingsXml = new ConcurrentDictionary<int, string>();
    using (TTN_Con oTTN_Con = new TTN_Con(SDL_oTTN_J_Master_CatProject_SDL.PR_oTTN_Monitor, SDL_oTTN_SDL_Cat.CAT_oTTN_Common_TTN.CO_oTTN_Common))
    {
    string sqls = "Select TermBaseId, SettingsXml from [proj].[Termbase]";
    using (SqlCommand oCmd = new SqlCommand(sqls, oTTN_Con.SDL_Trados.oCon))
    {
    using (SqlDataReader oDr = oCmd.ExecuteReader())
    {
    while (oDr.Read())
    {
    int intTermBaseId = Convert.ToInt32(oDr["TermBaseId"]);
    string strSettingsXml = Convert.ToString(oDr["SettingsXml"]);
    if (!strSettingsXml.Contains("gt;194.209.25.14"))
    continue;

    //Change Uri and add to collection
    strSettingsXml = strSettingsXml.Replace(@"gt;194.209.25.14", @"gt;sdltb.http://194.209.25.14/");
    oCD_TermBaseId__SettingsXml.TryAdd(intTermBaseId, strSettingsXml);
    }
    }
    }
    }

    //Save corrected Uri in Table
    foreach(KeyValuePair<int, string> oKVP_SettingsXml in oCD_TermBaseId__SettingsXml)
    {
    using (TTN_Con oTTN_Con = new TTN_Con(SDL_oTTN_J_Master_CatProject_SDL.PR_oTTN_Monitor SDL_oTTN_SDL_Cat.CAT_oTTN_Common_TTN.CO_oTTN_Common))
    {
    string sqls = "Update [proj].[Termbase] set SettingsXml = @SettingsXml where TermBaseId = " + oKVP_SettingsXml.Key;
    using (SqlCommand oCmd = new SqlCommand(sqls, oTTN_Con.SDL_Trados.oCon))
    {
    oCmd.Parameters.Add("@SettingsXml", System.Data.SqlDbType.Xml);
    oCmd.Parameters["@SettingsXml"].Value = oKVP_SettingsXml.Value;
    oCmd.ExecuteNonQuery();
    }
    }
    }

    R.
    Martin
Reply
  • Hi Andrew

    The workaround from Sébastian is OK if you create packages. If you use GroupShare you have to change the Uri in the table.

    ConcurrentDictionary<int, string> oCD_TermBaseId__SettingsXml = new ConcurrentDictionary<int, string>();
    using (TTN_Con oTTN_Con = new TTN_Con(SDL_oTTN_J_Master_CatProject_SDL.PR_oTTN_Monitor, SDL_oTTN_SDL_Cat.CAT_oTTN_Common_TTN.CO_oTTN_Common))
    {
    string sqls = "Select TermBaseId, SettingsXml from [proj].[Termbase]";
    using (SqlCommand oCmd = new SqlCommand(sqls, oTTN_Con.SDL_Trados.oCon))
    {
    using (SqlDataReader oDr = oCmd.ExecuteReader())
    {
    while (oDr.Read())
    {
    int intTermBaseId = Convert.ToInt32(oDr["TermBaseId"]);
    string strSettingsXml = Convert.ToString(oDr["SettingsXml"]);
    if (!strSettingsXml.Contains("gt;194.209.25.14"))
    continue;

    //Change Uri and add to collection
    strSettingsXml = strSettingsXml.Replace(@"gt;194.209.25.14", @"gt;sdltb.http://194.209.25.14/");
    oCD_TermBaseId__SettingsXml.TryAdd(intTermBaseId, strSettingsXml);
    }
    }
    }
    }

    //Save corrected Uri in Table
    foreach(KeyValuePair<int, string> oKVP_SettingsXml in oCD_TermBaseId__SettingsXml)
    {
    using (TTN_Con oTTN_Con = new TTN_Con(SDL_oTTN_J_Master_CatProject_SDL.PR_oTTN_Monitor SDL_oTTN_SDL_Cat.CAT_oTTN_Common_TTN.CO_oTTN_Common))
    {
    string sqls = "Update [proj].[Termbase] set SettingsXml = @SettingsXml where TermBaseId = " + oKVP_SettingsXml.Key;
    using (SqlCommand oCmd = new SqlCommand(sqls, oTTN_Con.SDL_Trados.oCon))
    {
    oCmd.Parameters.Add("@SettingsXml", System.Data.SqlDbType.Xml);
    oCmd.Parameters["@SettingsXml"].Value = oKVP_SettingsXml.Value;
    oCmd.ExecuteNonQuery();
    }
    }
    }

    R.
    Martin
Children
No Data