Ejemplo 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();

                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!");
            }
        }
Ejemplo 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();

                stream = new TweetStream(param);
                Task task = new Task(() => stream.Stream(t => AddTweet(t)));
                task.Start();
            }
        }
Ejemplo n.º 3
0
        public TweetStream(TweetStreamParameters streamParameters)
        {
            this.streamParameters = streamParameters;

            status = new StreamStatus();
        }