private void FetchServiceData(string host, string port, string modeltag)
        {
            StringBuilder connectionResult = new StringBuilder();

            try
            {
                ConnectionControl.MtServiceLanguagePairs = OpusCatMTServiceHelper.ListSupportedLanguages(host, port);
                IEnumerable <string> modelTagLanguagePairs;
                if (this.LanguagePairs != null)
                {
                    var projectLanguagePairsWithMt = ConnectionControl.MtServiceLanguagePairs.Intersect(this.LanguagePairs);
                    modelTagLanguagePairs = projectLanguagePairsWithMt;
                    if (projectLanguagePairsWithMt.Count() == 0)
                    {
                        connectionResult.Append("No MT models available for the language pairs of the project");
                    }
                    else if (this.LanguagePairs.Count == projectLanguagePairsWithMt.Count())
                    {
                        connectionResult.Append("MT models available for all the language pairs of the project");
                    }
                    else
                    {
                        connectionResult.Append($"MT models available for some of the language pairs of the project: {String.Join(", ", projectLanguagePairsWithMt)}");
                    }

                    //Get the detailed status for each project language pair
                    foreach (var pair in this.LanguagePairs)
                    {
                        connectionResult.Append(Environment.NewLine);
                        var sourceTarget = pair.Split('-');
                        connectionResult.Append(OpusCatMTServiceHelper.CheckModelStatus(host, port, sourceTarget[0], sourceTarget[1], modeltag));
                    }
                }
                else
                {
                    //This options is used with the batch task, where there's no easy way of getting
                    //the project language pairs, so all pairs are assumed.
                    modelTagLanguagePairs = ConnectionControl.MtServiceLanguagePairs;
                    connectionResult.Append($"MT models available for following language pairs: {String.Join(", ", ConnectionControl.MtServiceLanguagePairs)}");
                }

                //Get a list of model tags that are supported for these language pairs
                List <string> modelTags = new List <string>();
                foreach (var languagePair in modelTagLanguagePairs)
                {
                    var pairSplit = languagePair.Split('-');
                    modelTags.AddRange(OpusCatMTServiceHelper.GetLanguagePairModelTags(host, port, pairSplit[0], pairSplit[1]));
                }

                this.NoConnection = false;

                Dispatcher.Invoke(() => UpdateModelTags(modelTags, modeltag));
            }
            catch (Exception ex) when(ex is OpusCatEngineConnectionException)
            {
                connectionResult.Append($"No connection to OPUS-CAT MT Engine at {host}:{port}." + Environment.NewLine);
                connectionResult.Append("Make sure OPUS-CAT MT Engine application has been installed on your computer(check help link below) and is running and that it uses the same connection settings as the plugin (default settings should work).");
                this.NoConnection = true;
            }

            Dispatcher.Invoke(() => this.ConnectionStatus = connectionResult.ToString());
        }
 public static List <string> GetLanguagePairModelTags(OpusCatOptions options, string srcLangCode, string trgLangCode)
 {
     return(OpusCatMTServiceHelper.GetLanguagePairModelTags(options.mtServiceAddress, options.mtServicePort, srcLangCode, trgLangCode));
 }