Exemplo n.º 1
0
        public bool downloadDictionary(Language language, string url)
        {
            if (DatabaseController.getInstance().checkTableExists(language.ToString()))
            {
                return(false);
            }

            List <Word> words = new List <Word>();

            try
            {
                using (var client = new WebClient())
                {
                    using (System.IO.StringReader reader = new System.IO.StringReader(client.DownloadString(new Uri(url))))
                    {
                        string line;
                        while ((line = reader.ReadLine()) != null)
                        {
                            if (Word.isVaild(line))
                            {
                                words.Add(new Word(line));
                            }
                            else
                            {
                                log.Info(String.Format("{0} was not added to database, because it is not forged only from letters", line));
                            }
                        }
                    }
                }
            } catch (WebException ex)
            {
                throw new Exceptions.WordControllerWebException(url, ex);
            }

            return(WordService.getInstance().saveList(words, language));
        }