Esempio n. 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text != string.Empty && txtPassword.Text != string.Empty)
            {

                TweetStreamParameters param = new TweetStreamParameters(txtUsername.Text, txtPassword.Text);

                if (txtFilter.Text != string.Empty)
                    param.Filters = txtFilter.Text.Split(',').ToList();

                if(txtUsers.Text != string.Empty)
                    param.Filters = txtFilter.Text.Split(',').ToList();

                stream = new TweetStream(param);
                Task task = new Task(() => stream.Stream(t => AddTweet(t)));
                task.Start();
            }
        }
Esempio n. 2
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (txtUsername.Text != string.Empty && txtPassword.Text != string.Empty)
            {

                TweetStreamParameters param = new TweetStreamParameters(txtUsername.Text, txtPassword.Text);

                if (txtFilter.Text != string.Empty)
                    param.Filters = txtFilter.Text.Split(',').ToList();

                if (txtUsers.Text != string.Empty)
                    param.Filters = txtFilter.Text.Split(',').ToList();

                if (txtLatSw.Text != string.Empty && txtLatNe.Text != string.Empty)
                {
                    try
                    {
                        float swX = Convert.ToSingle(txtLatSw.Text.Split(',').First());
                        float swY = Convert.ToSingle(txtLatSw.Text.Split(',').Last());

                        float neX = Convert.ToSingle(txtLatNe.Text.Split(',').First());
                        float neY = Convert.ToSingle(txtLatNe.Text.Split(',').Last());

                        param.Locations.Add(new TweetLocation { SouthWestCorner = new PointF(swX, swY), NorthEastCorner = new PointF(neX, neY) });
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show("Fix your locations chump!", "You're a chump!");
                        return;
                    }
                }

                EnableUi(false);

                stream = new TweetStream(param);
                stream.OnException = (ex) => Log.Instance.ErrorException("Error Reading TweetStream", ex);

                var persistance = GetPersistance();

                Task task = new Task(() => stream.Stream(t =>
                    {
                        UpdateStreamStatus(stream.Status);

                        if (persistance.PersistTweet(t))
                        {
                            tweets++;
                            UpdatePersisted(tweets);
                        }
                    }));

                task.Start();
            }
            else
            {
                MessageBox.Show("Error!", "You need a username and password!");
            }
        }
Esempio n. 3
0
 private void UpdateStreamStatus(TweetStream.StreamStatus status)
 {
     if (this.lblTweetsGrabbed.InvokeRequired || lblErrors.InvokeRequired || lblTweetsMissed.InvokeRequired)
     {
         SetStreamStatusCallback d = new SetStreamStatusCallback(UpdateStreamStatus);
         this.Invoke(d, new object[] { status });
     }
     else
     {
         lblTweetsGrabbed.Text = status.TweetsGrabbed.ToString();
         lblTweetsMissed.Text = status.MissedTweets.ToString();
         lblErrors.Text = status.Error.ToString();
     }
 }