private void buttonCollect_Click(object sender, EventArgs e)
        {
            var entities = new gredbEntities();

            long listNameId = -1;
            if (comboBoxList.Text.Trim().Length > 0)
            {
                var list = entities.ListNames.Where(o => o.Name.ToLower().Equals(comboBoxList.Text.Trim().ToLower())).Select(o => o).FirstOrDefault();
                if (list == null)
                {

                    ListName listName = new ListName();
                    listName.Name = comboBoxList.Text.Trim().ToLower();
                    entities.AddToListNames(listName);
                    entities.SaveChanges();

                    listNameId = listName.Id;
                }
                else
                {
                    listNameId = list.Id;
                }
            }
            else
            {
                listNameId = Convert.ToInt64(comboBoxList.SelectedValue);
            }

            String strWord = textBoxWord.Text.Trim().ToLower();
            ListName ln = (from n in entities.ListNames
                           where n.Id == listNameId
                           select n).FirstOrDefault();

            try
            {
                GreWord word;
                word = (from w in entities.GreWords
                        where w.Word.ToLower() == strWord
                        select w).FirstOrDefault();

                if (word == null)
                {
                    word = new GreWord()
                    {
                        Word = strWord,
                    };
                    entities.AddToGreWords(word);
                    entities.SaveChanges();
                }

                ListedWord lw = (from w in entities.ListedWords
                                 where w.ListName.Id == ln.Id && w.GreWord.Word == word.Word
                                 select w).FirstOrDefault();

                if (lw == null)
                {
                    lw = new ListedWord()
                    {
                        GreWord = word,
                        ListName = ln
                    };
                    entities.AddToListedWords(lw);
                    entities.SaveChanges();
                }
            }
            catch (Exception exp)
            {
                MessageBox.Show(exp.Message);
            }

            ParserHelper parserHelper = new ParserHelper(entities);
            parserHelper.OnLogMessage += (sender2, person) => this.Invoke((MethodInvoker)(() => textBoxInfo.AppendText(person + "\r\n")));

            parserHelper.WordToFetch = strWord;
            var workerThread = new Thread(parserHelper.FetchAndParseSingleWord) {IsBackground = true};
            workerThread.Start();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            long listNameId = -1;
            var entities = new gredbEntities();

            var list = entities.ListNames.Where(o => o.Name.ToLower().Equals(comboBoxList.Text.Trim().ToLower())).Select(o => o).FirstOrDefault();
            if (list == null)
            {

                ListName listName = new ListName { Name = comboBoxList.Text.Trim() };
                entities.AddToListNames(listName);
                entities.SaveChanges();

                listNameId = listName.Id;
            }
            else
            {
                listNameId = list.Id;
            }

            String str = Regex.Replace(textBox1.Text, "([0-9\\.]+|<.+?>)", "");
            Regex regex = new Regex("([^\\s]+)");

            ListName ln = (from n in entities.ListNames
                           where n.Id == listNameId
                           select n).FirstOrDefault();

            try
            {
                MatchCollection mc = regex.Matches(str);

                foreach (Match m in mc)
                {
                    try
                    {
                        GreWord word = (from w in entities.GreWords
                                        where w.Word.ToLower() == m.Value.ToLower()
                                        select w).FirstOrDefault();

                        if (word == null)
                        {
                            word = new GreWord()
                            {
                                Word = m.Value.ToLower(),
                            };
                            entities.AddToGreWords(word);
                            entities.SaveChanges();
                        }

                        ListedWord lw = (from w in entities.ListedWords
                                         where w.ListName.Id == ln.Id && w.GreWord.Word == word.Word
                                         select w).FirstOrDefault();

                        if (lw == null)
                        {
                            lw = new ListedWord()
                            {
                                GreWord = word,
                                ListName = ln
                            };
                            entities.AddToListedWords(lw);
                            entities.SaveChanges();
                        }
                    }
                    catch (Exception exp)
                    {
                        MessageBox.Show(exp.Message);
                    }
                }
                entities.Connection.Close();
            }
            catch (Exception exp)
            {
            }
        }