Example #1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            if (lstItems.Items.Count < 1)
            {
                return;
            }

            var proceed = AddUrlToScannedTable();

            if (proceed == false)
            {
                return;
            }

            int        lineNo     = 0;
            Connection connection = new Connection();

            connection.OpenConnection();
            do
            {
                Debug.WriteLine("LineNo: " + ++lineNo);
                // Send each line, it will be split there
                connection.AddAllWordsToDb(lstItems.Items[0].ToString(), Glob.EnableNearWordsEntry);
                lstItems.Items.RemoveAt(0);
                lstItems.Refresh();
            }while (lstItems.Items.Count > 0);

            connection.CloseConnection();

            MessageBox.Show("Data added successfully!");

            // lstItems.Items.Clear();
        }
Example #2
0
        private void AddBulkText(string bulkText)
        {
            var cleanedText = CleanText(bulkText);

            var result = GetLines(cleanedText);

            //foreach (var item in lines)
            //{
            //    var line = item.Trim().Replace("..", string.Empty);
            //    if (ContainsWrongWords(line)) continue;
            //    lstItems.Items.Add(line);
            //}
            // var result = Regex.Split(cleanedText, "\r\n|\r|\n|.");

            var enumerable = result as string[] ?? result.ToArray();

            if (enumerable.Count() > 10)
            {
                lblStatus.Visible   = true;
                tabControl1.Visible = false;
                this.Refresh();
            }

            Connection connection = new Connection();

            connection.OpenConnection();

            foreach (var line in enumerable)
            {
                connection.AddAllWordsToDb(line, Glob.EnableNearWordsEntry);
                lblStatus.Text = "Adding words to db" + Environment.NewLine + Environment.NewLine + line;
                this.Refresh();
            }

            connection.CloseConnection();

            if (enumerable.Count() > 10)
            {
                lblStatus.Visible   = false;
                tabControl1.Visible = true;
            }
        }