private async Task <LanguageDomainSupport> updateConfig(string url, string auth)
        {
            var config = new LanguageDomainSupport();

            try
            {
                // try to get Configuration
                // Do not call any blocking service in the user interface thread; it has to use background threads.
                var engineConf = await Task.Run(() => TartuNLPServiceHelper.getConfig(url, auth));

                if (engineConf == null)
                {
                    //invalid user name or password
                    config.UpdateSuccessful = false;
                }
                else
                {
                    config = loadEngineConf(engineConf);
                }
            }
            catch (Exception ex)
            {
                config.Exception = ex;
            }

            return(config);
        }
Exemplo n.º 2
0
        private async Task <LanguageDomainSupport> updateConfig(string url, string auth)
        {
            var languageDomainSupport = new LanguageDomainSupport()
            {
                URL  = url,
                Auth = auth
            };

            try
            {
                // try to get Configuration
                // Do not call any blocking service in the user interface thread; it has to use background threads.
                languageDomainSupport.JSON = await Task.Run(() => TartuNLPServiceHelper.getConfig(url, auth));

                if (languageDomainSupport.JSON == null)
                {
                    //invalid user name or password
                    languageDomainSupport.UpdateSuccessful = false;
                }
                else
                {
                    //successful login
                    languageDomainSupport.UpdateSuccessful = true;

                    //try to get the list of the Domain in the background
                    languageDomainSupport.SupportedDomains   = new Dictionary <string, string>();
                    languageDomainSupport.SupportedLanguages = new Dictionary <string, string[]>();
                    foreach (string key in languageDomainSupport.JSON.Keys)
                    {
                        languageDomainSupport.SupportedDomains.Add(languageDomainSupport.JSON[key][0], key);
                        languageDomainSupport.SupportedLanguages.Add(languageDomainSupport.JSON[key][0], languageDomainSupport.JSON[key]);
                    }
                }
            }
            catch (Exception ex)
            {
                languageDomainSupport.Exception = ex;
            }

            return(languageDomainSupport);
        }