Example #1
0
        public void Create(TranslationProviderServer tmServer)
        {
            TranslationMemoryContainer container = new TranslationMemoryContainer(tmServer);

            DatabaseServer dbServ = tmServer.GetDatabaseServer("DB01", GetDbServProperties());

            container.DatabaseServer = dbServ;
            container.DatabaseName   = "DbName";
            container.Name           = "NiceName";
            container.Save();
        }
        private TranslationMemoryContainer CreateContainer(string newContainerName)
        {
            ReadOnlyCollection <DatabaseServer> dbs = TMServer.GetDatabaseServers(DatabaseServerProperties.Containers);

            if (dbs.Count == 0)
            {
                throw new Exception("No DB server registered.");
            }

            //pick first DB server and check if the new container name already exists
            foreach (var cnt in dbs[0].Containers)
            {
                if (cnt.Name == newContainerName)
                {
                    //container exists so let use it
                    return(cnt);
                }
            }
            //set a parent organization variable, all operations will be performed in this organization
            ParentOrganizationPath = dbs[0].ParentResourceGroupPath;

            //now create a new container and add to the server
            TranslationMemoryContainer container = new TranslationMemoryContainer(TMServer);

            container.DatabaseServer          = dbs[0];
            container.DatabaseName            = newContainerName + "DB";
            container.Name                    = newContainerName;
            container.ParentResourceGroupPath = ParentOrganizationPath;
            container.Save();

            //now verify that the container was created sucessfully
            if (TMServer.GetContainer(ParentOrganizationPath + "/" + container.Name, ContainerProperties.None) == null)
            {
                throw new Exception("Container wasn't created.");
            }

            WriteResult("Container " + newContainerName + " was created successfully.\r\n");

            return(container);
        }
Example #3
0
        public void CreateAdvanced(TranslationProviderServer tmServer, string organization, string newContainerName)
        {
            #region "count"
            ReadOnlyCollection <DatabaseServer> dbs = tmServer.GetDatabaseServers(DatabaseServerProperties.Containers);
            if (dbs.Count == 0)
            {
                throw new Exception("No DB server registered.");
            }
            #endregion

            #region "CheckExists"
            foreach (TranslationMemoryContainer item in dbs[0].Containers)
            {
                if (item.Name == newContainerName)
                {
                    throw new Exception("Container with that name already exists.");
                }
            }
            #endregion

            #region "CreateContainer"
            TranslationMemoryContainer container = new TranslationMemoryContainer(tmServer);
            container.DatabaseServer          = dbs[0];
            container.DatabaseName            = newContainerName + "DB";
            container.Name                    = newContainerName;
            container.ParentResourceGroupPath = organization;
            container.Save();
            #endregion

            #region "CheckCreated"
            if (!dbs[0].Containers.Contains(container))
            {
                throw new Exception("Container was not created.");
            }
            #endregion
        }