示例#1
0
        protected void tag_Click(object sender, EventArgs e)
        {
            Label  temp    = sender as Label;
            string hashtag = temp.Text;
            int    index   = hashtag.IndexOf('(');
            int    index2  = hashtag.IndexOf(')');

            int sayi = Convert.ToInt32(hashtag.Substring(index + 1, (index2 - index - 1)));

            hashtag = hashtag.Substring(0, index).Trim();
            DataAccess     db  = new DataAccess();
            List <TweetDB> tw  = new List <TweetDB>();
            DbResults      dbR = null;

            tw = db.GetTweetsByHastag(hashtag);
            if (tw.ToArray().Length == 0)
            {
                MessageBox.Show("Please Select Another Hashtag");
            }
            else
            {
                Maps.DeleteTweetTable();
                Maps.createLiveTweetsTable();
                List <ResultsObj> rdb = new List <ResultsObj>();
                ResultsObj        rb  = new ResultsObj {
                    sayi = sayi, hastag = hashtag
                };
                rdb.Add(rb);
                dbR = new DbResults(rdb);
                Maps.PutTweetsOnMap(tw);
            }
        }
示例#2
0
        // search button to find all tweets by chiritizied
        private void searchButton_Click(object sender, EventArgs e)
        {
            DeleteTweetTable();
            createLiveTweetsTable();

            string hashtag    = null;
            string timePeriod = null;
            int    sayi       = 0;

            if (hashtagSearch.SelectedItem != null && hashtagSearch.SelectedIndex != 0)
            {
                hashtag = hashtagSearch.SelectedItem.ToString();
                int index  = hashtag.IndexOf('(');
                int index2 = hashtag.IndexOf(')');

                sayi    = Convert.ToInt32(hashtag.Substring(index + 1, (index2 - index - 1)));
                hashtag = hashtag.Substring(0, index).Trim();
            }
            if (searchTimePer.SelectedItem != null && searchTimePer.SelectedIndex != 0)
            {
                timePeriod = searchTimePer.SelectedItem.ToString();
            }

            List <TweetDB> tw  = new List <TweetDB>();
            DbResults      dbR = null;

            if (hashtag == null && timePeriod == null)
            {
                MessageBox.Show("Please Select a Hashtag or Time Period");
                ClearContent();
            }
            else if (hashtag == null && timePeriod != null)
            {
                tw = db.GetTweetsByTime(timePeriod);
                if (tw.ToArray().Length == 0)
                {
                    MessageBox.Show("Please Select Dedicated Time Period");
                }
                else
                {
                    dbR = new DbResults(db.GetTrendTagsByTime(timePeriod));
                    PutTweetsOnMap(tw);
                }

                ClearContent();
            }
            else if (hashtag != null && timePeriod == null)
            {
                tw = db.GetTweetsByHastag(hashtag);
                if (tw.ToArray().Length == 0)
                {
                    MessageBox.Show("Please Select Another Hashtag");
                }
                else
                {
                    List <ResultsObj> rdb = new List <ResultsObj>();
                    ResultsObj        rb  = new ResultsObj {
                        sayi = sayi, hastag = hashtag
                    };
                    rdb.Add(rb);
                    dbR = new DbResults(rdb);
                    PutTweetsOnMap(tw);
                }

                ClearContent();
            }
            else if (hashtag != null && timePeriod != null)
            {
                tw = db.GetTweetsByHastagTime(hashtag, timePeriod);
                if (tw.ToArray().Length == 0)
                {
                    MessageBox.Show("Please Select a Hashtag or Time Period");
                }
                else
                {
                    List <ResultsObj> rdb = new List <ResultsObj>();
                    ResultsObj        rb  = new ResultsObj {
                        sayi = sayi, hastag = hashtag
                    };
                    rdb.Add(rb);
                    dbR = new DbResults(rdb);
                    PutTweetsOnMap(tw);
                }

                ClearContent();
            }

            if (!tags.Contains(dbR) && dbR != null)
            {
                tags.Controls.Add(dbR);
                dbR.Dock = DockStyle.Fill;
                dbR.BringToFront();
            }
        }