| Retrieving TM Containers |
In this chapter you will learn how to get programmatic access to TM containers. Containers are the actual physical databases that contain one or more TMs. Technically speaking TMs are tables within a container database. Depending on the number of TMs used you may consolidate all TMs in a single container database, or split the TMs among several container databases. This may be a consideration driven by the maximum physical size of a database. For example, Microsoft SQL Express versions only support databases up to a maximum size (4 GB).
Start by adding a new class called ServerContainers to your project. Then implement a public function called GetDBContainers in the class, which takes a TranslationProviderServer object as parameter. This function can be called from the connector class as shown below:
ServerContainers containers = new ServerContainers();
containers.GetDBContainers(tmServer);The GetDBContainers function loops through the containers that are associated with the TM Server object and outputs various information in a message box:
public void GetDBContainers(TranslationProviderServer tmServer) { string dbInfo = string.Empty; foreach (TranslationMemoryContainer container in tmServer.GetContainers(ContainerProperties.None)) { dbInfo += "DB Name: " + container.DatabaseName + "\n"; dbInfo += "Friendly name: " + container.Name + "\n"; dbInfo += "DB Server: " + container.DatabaseServer + "\n"; dbInfo += "Description: " + container.Description + "\n\n"; dbInfo += "ParentOrganization: " + container.ParentResourceGroupPath + "\n\n"; } MessageBox.Show(dbInfo); }
Below you see an example of a container information box in SDL TM Server Manager:

The complete class looks as shown below:
namespace Sdl.SDK.LanguagePlatform.Samples.TmAutomation { using System.Windows.Forms; using Sdl.LanguagePlatform.TranslationMemoryApi; public class ServerContainers { #region "get" public void GetDBContainers(TranslationProviderServer tmServer) { string dbInfo = string.Empty; foreach (TranslationMemoryContainer container in tmServer.GetContainers(ContainerProperties.None)) { dbInfo += "DB Name: " + container.DatabaseName + "\n"; dbInfo += "Friendly name: " + container.Name + "\n"; dbInfo += "DB Server: " + container.DatabaseServer + "\n"; dbInfo += "Description: " + container.Description + "\n\n"; dbInfo += "ParentOrganization: " + container.ParentResourceGroupPath + "\n\n"; } MessageBox.Show(dbInfo); } #endregion } }