Пример #1
0
        private static void ScheduleTweetAction()
        {
            wl("Sweet, we can do that.");
            w("What do you want to tweet: ");
            string tweettxt = rl();

            while (tweettxt.Length > 140)
            {
                w("Um, that's too long. Try again: ");
                tweettxt = rl();
            }

            if (string.Compare(tweettxt, "random", true) == 0)
            {
                string path = filePath;
                tweettxt = GetRandomLine(ref path);
            }

            w("When do you want this Tweet to go out: ");
            string time = rl();

            DateTime tSchedule;
            while (!DateTime.TryParse(time, out tSchedule))
            {
                w("Um, the program didn't understand that date/time: ");
                time = rl();
            }

            JBird db = new JBird(connection);
            dbTweet tweet = new dbTweet();
            tweet.TweetText = tweettxt;
            tweet.Schedule = tSchedule;
            db.dbTweets.InsertOnSubmit(tweet);
            db.SubmitChanges();

            wl("Done.");
            DisplayMenu();
        }
Пример #2
0
        private static void AutoTweet()
        {
            JBird db = new JBird(connection);
            var q = from t in db.dbTweets
                    where t.Schedule <= DateTime.Now
                    select t;

            foreach (dbTweet tw in q)
            {
                var twitter = Tweet(tw.TweetText);
                var response = twitter.Request();
                db.dbTweets.DeleteOnSubmit(tw);
            }

            db.SubmitChanges();
        }