Ejemplo n.º 1
0
        //比對
        public void Compare(string productFilePath, int num, string saveFileName, string saveFileName2)
        {
            int count = 0;
            Search s = new Search();

            var Fi = from rline in File.ReadLines(productFilePath)
                     select new { Line = rline };

            Parallel.ForEach(Fi, f =>
            {
                string desc = GetKeyword(f.Line);

                bool isMatch = false;

                foreach (var ss in s.Searcher(num, desc, "n")) //比對
                {
                    isMatch = true;
                    lock (syncHandle)
                    {
                        saveData.Save(saveFileName, string.Format("{0}\t{1}\t{2}\t{3}\t{4}\t{5}",
                                ss,
                                f.Line.Split('\t')[2].Replace(",", " "),//description
                                f.Line.Split('\t')[1],//price
                                f.Line.Split('\t')[3],//user_id
                                f.Line.Split('\t')[0],//gd_id
                                f.Line.Substring(f.Line.IndexOf("http"))));//url
                    }
                    count++;
                }
                if (!isMatch)//若沒對應到則印出原本文字
                {
                    lock (syncHandle)
                        saveData.Save(saveFileName2, f.Line);
                }
            });

            saveData.Save("Number.txt", saveFileName + "\t" + count);
        }
Ejemplo n.º 2
0
        private void btnSearch_Click(object sender, EventArgs e)
        {
            txtResult.Text = "";
            Search s = new Search();

            string str = GetKeyword(txtInput1.Text.ToLower());

            foreach (string ss in s.Searcher(3, str, "n"))
                txtResult.Text += ss;
            txtResult.Text += "\r\n";
            foreach (string ss in s.Searcher(2, str, "n"))
                txtResult.Text += ss;
            txtResult.Text += "\r\n";
            foreach (string ss in s.Searcher(1, str, "n"))
                txtResult.Text += ss;
        }