Hi everyone
I find myself stuck with two different options for retrieving all indexes from a MultiTerm termbase:
Option 1 (Sdl.MultiTerm.TMO.Interop):
Multiterm.Application application = new Multiterm.Application();
Multiterm.TermbaseRepository repository = application.LocalRepository;
repository.Connect(NO_USER, NO_PASSWORD);
repository.Termbases.Add(termbasePath, NO_NAME, NO_DESCRIPTION);
IList<string> result = new List<string>();
try { foreach (Multiterm.Termbase termbase in repository.Termbases) { foreach (Multiterm.Index index in termbase.Definition.Indexes) { result.Add(index.Locale); } termbase.Close(); } }
finally { repository.Disconnect(); }
return result;
Option 2 (Sdl.MultiTerm.Client.Api):
var repository = new LocalRepository();
if (!(from tb in repository.Termbases where tb.PhysicalName == termbasePath select tb.Location).Any()) { repository.Add(termbasePath); }
var termbase = repository.GetTermbaseByPhysicalName(termbasePath);
IList<string> result = new List<string>();
if (!termbase.IsConnected) { termbase.Connect(); }
try { foreach (var index in termbase.Indices) { result.Add(index.Locale); } }
finally { termbase.Disconnect(); }
return result;
Option 1 has the unfortunate habit of keeping my process from terminating as soon as I construct an "Sdl.MultiTerm.TMO.Interop.Application" object, while option 2 sometimes raises the following error:
[ERROR] 2013-05-11 22:21:36,784: ProjectSettingsView - System.Runtime.InteropServices.COMException (0x800A0E78): Operation is not allowed when the object is closed.
at Sdl.MultiTerm.Server.Interop.MtTermbaseClass.Name(String Cookie)
at Sdl.MultiTerm.Core.Connectors.InlineConnector.TermbaseName(String cookie)
at Sdl.MultiTerm.Client.Connectors.TermbaseProxy.Name(String physicalDBName)
at Sdl.MultiTerm.Client.Adapters.MultiTermServer2010Adapter.AddLocalTermbase(String filePath)
at Sdl.MultiTerm.Client.Api.LocalRepository.Add(String path)
Which option is the preferred one and how can I avoid either one of these issues?
Thanks for any feedback and best regards
Pascal