Inheritance: MonoBehaviour
Exemplo n.º 1
0
        static void Main(string[] args)
        {
            try
            {
                // Check for 2 files
                if (args.Length < 2)
                {
                    Console.WriteLine("**********ERROR**********");
                    Console.WriteLine("Please enter 2 arguments.");
                    Console.ReadKey();
                    return;
                }
                else if (args.Length > 2)
                {
                    Console.WriteLine("**********ERROR**********");
                    Console.WriteLine("Too many arguments entered.");
                    Console.ReadKey();
                    return;
                }

                TweetManager tweetManager = TweetManager.GetInstance;
                tweetManager.ImportFiles(args[0], args[1]);
                // Print user tweets. Input params for showing user name and to include tweets of following users.
                tweetManager.PrintUserTweets(true, true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("**********ERROR**********");
                Console.WriteLine(ex.Message);
            }

            // Pause the console
            Console.WriteLine("\nPress any key to continue.");
            Console.ReadKey();
        }
Exemplo n.º 2
0
        public void PostTwitterMentionsToRest()
        {
            string result = string.Empty;

            //http://localhost/BIDataAPI/api/twitter/mentions
            requestPost                       = (HttpWebRequest)WebRequest.Create("http://localhost/BIdataApi/api/twitter/mentions");
            requestPost.Method                = "POST";
            requestPost.ContentType           = "application/json";
            requestPost.UseDefaultCredentials = true;

            TweetManager  tm = new TweetManager();
            KeywordStatus ks = new KeywordStatus();

            Twitter.Components.Twitter t = new Twitter.Components.Twitter();
            ks.KeywordId  = 7;
            ks.StatusList = tm.GetTweetsByQuery(20, Uri.EscapeDataString("\"go daddy\" OR godaddy OR go-daddy"), Twitter.Utility.GetOAuthToken(t.Xml));

            string requestData = new JavaScriptSerializer().Serialize(ks);

            byte[] data = Encoding.UTF8.GetBytes(requestData);

            using (Stream dataStream = requestPost.GetRequestStream())
                dataStream.Write(data, 0, data.Length);

            HttpWebResponse response = requestPost.GetResponse() as HttpWebResponse;

            result = new StreamReader(response.GetResponseStream()).ReadToEnd();

            Assert.AreEqual(response.StatusCode, HttpStatusCode.Created);
        }
Exemplo n.º 3
0
        public async Task <ActionResult> Index()
        {
            DateTimeOffset    startDate = new DateTimeOffset(2016, 1, 1, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset    endDate   = new DateTimeOffset(2018, 1, 1, 0, 0, 0, TimeSpan.Zero);
            List <TweetModel> tweets    = await TweetManager.GetAll(startDate, endDate);

            return(View(tweets));
        }
Exemplo n.º 4
0
        public async Task GetJanuary2016()
        {
            DateTimeOffset    startDate = new DateTimeOffset(2016, 1, 1, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset    endDate   = new DateTimeOffset(2016, 1, 31, 0, 0, 0, TimeSpan.Zero);
            List <TweetModel> tweets    = await TweetManager.GetAll(startDate, endDate);

            Assert.AreEqual(473, tweets.Count);
        }
Exemplo n.º 5
0
        /// <summary>
        /// Get all mentions and replies @GoDaddy
        /// Not used
        /// </summary>
        internal List <Mention> GetMentionsReplies()
        {
            int countPerPage; int pageCount;

            XMLUtility.GetPageResultCounts(Xml, "mentionsreplies", out countPerPage, out pageCount, 200, 1);
            TweetManager tm = new TweetManager();

            return(tm.GetMentionsAndReplies(countPerPage, pageCount, Utility.GetOAuthToken(Xml)));
        }
Exemplo n.º 6
0
        static void Main(string[] args)
        {
            var result = TweetManager.GetTweets(new TweetFilter()
            {
                QuerySearch = "#SpbDotNet"
            }).Result;

            Console.ReadLine();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Public exposed method for calling from a webservice.
        /// Querystring will be "q=[paramstring]"
        /// </summary>
        /// <param name="countPerPage"></param>
        /// <param name="keywordID">keyword id from rptTwitterKeywordLookup (1 through 6)</param>
        /// <param name="pagesToReturn"></param>
        /// <param name="paramString">any valid parameters except for count and pageCount.</param>
        public static Dictionary <int, List <Status> > GetAllMentionsByQuery(int keywordID, int countPerPage, int pagesToReturn, string paramString)
        {
            Dictionary <int, List <Status> > allTwitterMentions = new Dictionary <int, List <Status> >();
            TweetManager tm = new TweetManager();
            Twitter      t  = new Twitter();

            allTwitterMentions.Add(keywordID, tm.GetTweetsByQuery(countPerPage, paramString, Utility.GetOAuthToken(t.Xml)));

            return(allTwitterMentions);
        }
Exemplo n.º 8
0
    // Use this for initialization
    void Start()
    {
        ownerNum       = 0;
        fillProportion = 0;
        sr             = GetComponent <SpriteRenderer> ();

        colorManager = GameObject.Find("RoomColorManager");
        rcm          = colorManager.GetComponent <RoomColorManager> ();
        tweetManager = GameObject.FindGameObjectWithTag("TweetManager").GetComponent <TweetManager>();
    }
Exemplo n.º 9
0
        protected void SendTweet(string message)
        {
            var domain = this.Domain;

            if (domain != null && domain.DO_UpdateTwitter && !String.IsNullOrEmpty(message))
            {
                TweetManager tweet = new TweetManager(domain.DO_TwitterToken, domain.DO_TwitterSecret, domain.DO_ConsumerKey, domain.DO_ConsumerSecret);
                tweet.SendTweet(message);
            }
        }
Exemplo n.º 10
0
 static void Main(string[] args)
 {
     // Show all tweets in the local file
     TweetManager.ShowAll();
     // Search for a tag 'Leaf' in the local file
     TweetManager.ShowAll("Leaf");
     // Search for a tag 'LEAF' in the local file - Case Insensitive
     TweetManager.ShowAll("LEAF");
     // Search for a tag 'JAKE', which dose not exist in the local file
     TweetManager.ShowAll("JAKE");
 }
Exemplo n.º 11
0
        public async Task EnsureNotGettingTweetsOutsideDateRange()
        {
            DateTimeOffset    startDate = new DateTimeOffset(2016, 1, 1, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset    endDate   = new DateTimeOffset(2016, 1, 3, 0, 0, 0, TimeSpan.Zero);
            List <TweetModel> tweets    = await TweetManager.GetAll(startDate, endDate);

            IOrderedEnumerable <TweetModel> ordered = tweets.OrderBy(t => t.Stamp);

            Assert.IsTrue(ordered.Last().Stamp <= endDate);
            Assert.IsTrue(ordered.First().Stamp >= startDate);
        }
Exemplo n.º 12
0
 private void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else
     {
         Debug.LogWarning("Multiple TweetManagers present, disabling: {0}", this.gameObject);
         enabled = false;
     }
 }
Exemplo n.º 13
0
        public async Task CheckGettingOver100IsStillInValidRange()
        {
            DateTimeOffset    startDate = new DateTimeOffset(2016, 1, 2, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset    endDate   = new DateTimeOffset(2016, 1, 12, 0, 0, 0, TimeSpan.Zero);
            List <TweetModel> tweets    = await TweetManager.GetAll(startDate, endDate);

            IOrderedEnumerable <TweetModel> ordered = tweets.OrderBy(t => t.Stamp);

            Assert.IsTrue(tweets.Count > 100);
            Assert.IsTrue(ordered.Last().Stamp <= endDate);
            Assert.IsTrue(ordered.First().Stamp >= startDate);
        }
Exemplo n.º 14
0
 void Start()
 {
     button
     .OnClickAsObservable()
     .TakeUntilDestroy(this)
     .ThrottleFirst(System.TimeSpan.FromMilliseconds(1000))
     .Subscribe(x =>
     {
         StartCoroutine(TweetManager.TweetWithScreenShot(tweetMessage));
         SEManager.Instance.Play(SEPath.KURAGEKOUBOU_BUTTON79);
     }).AddTo(this);
 }
Exemplo n.º 15
0
        public async Task CheckJsonParser()
        {
            DateTimeOffset    startDate = new DateTimeOffset(2016, 1, 1, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset    endDate   = new DateTimeOffset(2016, 1, 2, 0, 0, 0, TimeSpan.Zero);
            List <TweetModel> tweets    = await TweetManager.GetAll(startDate, endDate);

            foreach (TweetModel tweet in tweets)
            {
                Assert.IsNotNull(tweet.Id);
                Assert.IsNotNull(tweet.Text);
                Assert.IsNotNull(tweet.Stamp);
            }
        }
Exemplo n.º 16
0
        public async Task CheckTotalAndEnsureNoDuplicates()
        {
            DateTimeOffset    startDate = new DateTimeOffset(2016, 1, 1, 0, 0, 0, TimeSpan.Zero);
            DateTimeOffset    endDate   = new DateTimeOffset(2018, 1, 1, 0, 0, 0, TimeSpan.Zero);
            List <TweetModel> tweets    = await TweetManager.GetAll(startDate, endDate);

            //found this by going one day at a time initially to find total number of tweets i should be expecting.
            Assert.AreEqual(11693, tweets.Count);

            IEnumerable <IGrouping <decimal, TweetModel> > grouped = tweets.GroupBy(t => t.Id);

            //there are not any groups with the same ids that have more than one in the group
            Assert.IsTrue(!grouped.Any(g => g.Count() > 1));
        }
Exemplo n.º 17
0
    void OnClick()
    {
        string strTweet;

        strTweet  = "種目:" + PlayingManager.gameMaster.gameMode.name;
        strTweet += cr;
        strTweet += "記録:" + PlayingManager.playingManager.resultDistance.ToString("F2") + "m";
        strTweet += cr;
        var acquiredTitles = PlayingManager.playingManager.titleMonitor.acquiredTitles;
        var strTitle       = "";
        var idTitle        = acquiredTitles[acquiredTitles.Count - 1];

        if (acquiredTitles.Count > 0)
        {
            strTitle  = PlayingManager.gameMaster.titles.allTitles.FirstOrDefault(t => t.id == idTitle).name;
            strTweet += "称号:" + strTitle;
            strTweet += cr;
        }
        StartCoroutine(TweetManager.TweetWithScreenShot(strTweet));
    }
Exemplo n.º 18
0
        public async Task <ActionResult> Regist(TweetResult tt)
        {
            //nullのタスクを削除
            tt.tasks.RemoveAll(x => x.task == null);
            //Tweet用文字列生成
            var tweet = CreateTask(tt);

            var tm  = new TweetManager();
            var res = await tm.PostTweet(tweet);

            tt.tweetId = res.Id;
            tt.userId  = User.Identity.GetUserId();

            if (tsm.CreateTask(tt))
            {
                return(View("Index", await tm.EmbedTweetGet(tt.tweetId)));    //DBへの登録が正常終了
            }
            //失敗の時
            return(View("Index"));
        }
Exemplo n.º 19
0
        // GET: Tweet
        public async Task <ActionResult> Index()
        {
            var id = User.Identity.GetUserId();

            if (null == id)
            {
                var res = tsm.ReadTask(id);
                if (null == res)
                {
                    //ログイン中 かつ タスクが存在しない場合
                    return(View());
                }

                var tm  = new TweetManager();
                var emb = await tm.EmbedTweetGet(res.tweetId);

                //ログイン中 かつ タスクが存在した場合の表示
                return(View(emb));
            }
            //ログインしていない場合の初期表示
            return(View());
        }
Exemplo n.º 20
0
        public async Task <ActionResult> Update(TweetResult tt)
        {
            //Tweet用文字列生成
            var tweet = UpdateTask(tt);

            var id = User.Identity.GetUserId();
            var tr = tsm.ReadTask(id);

            var tm  = new TweetManager();
            var res = await tm.ReplyTweet(tweet, tr.tweetId);

            tt.userId  = tr.userId;
            tt.id      = tr.id;
            tt.tweetId = res.Id;

            if (tsm.UpdateTask(tt))
            {
                return(View("Index", await tm.EmbedTweetGet(tt.tweetId)));    //DBへの登録が正常終了
            }
            //失敗の時
            return(View("Index"));
        }
 private void Awake()
 {
     if (_instance == null)
     {
         _instance = this;
     }
     else
     {
         Debug.LogWarning ("Multiple TweetManagers present, disabling: {0}", this.gameObject);
         enabled = false;
     }
 }
Exemplo n.º 22
0
        //*******************************************************************
        // Public method: GetAllTweets()
        // Arguments: None
        // Returns: List<AllTweets>
        // Description: Retrive a generic list of all tweets from a text file
        // Revision: 1.01a
        // Revision date: 2016/05/25
        // ******************************************************************
        public List <AllTweets> GetAllTweets()
        {
            // Initilize List to store Users
            List <Users> usersList = new List <Users>();
            // Initilize List to store Followsers
            List <Followers> followersList = new List <Followers>();
            // Initilize List to store Tweets
            List <Tweets> tweetsList = new List <Tweets>();
            // Initilize List to store AllTweets
            List <AllTweets> allTweetsList = new List <AllTweets>();

            // Initilize instance of UserManager
            UserManager userManager = new UserManager();
            // Initilize instance of TweetManager
            TweetManager tweetManager = new TweetManager();
            // Initilize instance of AllTweets
            AllTweets allTweets = null;

            try
            {
                // Get a list of all users from user.txt file
                usersList = userManager.GetTweetOwnersFromStream();
                // Get a list of all followers from user.txt file
                followersList = userManager.GetTweetFollowersFromStream();
                // Get list of all tweets from tweet.txt file
                tweetsList = tweetManager.GetTweetsByOwnerFromStream();

                // Iterate through all user in usersList
                foreach (Users user in usersList)
                {
                    // Initilize instance of AllTweets
                    allTweets = new AllTweets();
                    // Store sender of tweet
                    allTweets.Owner = user.Owner;
                    // Initilize List to store all tweets from followers
                    allTweets.Tweet = new List <string>();

                    // Check if user has any followers
                    var hasFollowers = followersList.Find(item => item.Owner == user.Owner);

                    // Validate if follows is not null
                    if (hasFollowers != null)
                    {
                        // Check if user has any tweets from followers
                        var hasTweets = tweetsList.Find(item => item.Owner == hasFollowers.Owner);

                        // Validate if tweets is not null
                        if (hasTweets != null)
                        {
                            // Iterate through all the tweets stred in tweetsList
                            foreach (Tweets tweets in tweetsList)
                            {
                                // Check is there are any tweets from sender
                                if (user.Owner == tweets.Owner)
                                {
                                    // Add tweets from sender to allTweets List
                                    allTweets.Tweet.Add("\t@" + tweets.Owner + ": " + tweets.Tweet);
                                }// Check is there are any tweets from gollowers
                                else if (tweets.Owner == hasFollowers.Follower)
                                {
                                    // Add tweets from followers to allTweets List
                                    allTweets.Tweet.Add("\t@" + tweets.Owner + ": " + tweets.Tweet);
                                }
                            }
                        }
                    }

                    // Add tweet transation to allTweetsList
                    allTweetsList.Add(allTweets);
                }
            }catch (Exception ex)
            {
                Console.WriteLine("HelpLink = {0}", ex.HelpLink);
                Console.WriteLine("Message = {0}", ex.Message);
                Console.WriteLine("Source = {0}", ex.Source);
                Console.WriteLine("StackTrace = {0}", ex.StackTrace);
                Console.WriteLine("TargetSite = {0}", ex.TargetSite);
            }

            // Return all tweets stored in allTweetsList
            return(allTweetsList);
        }
Exemplo n.º 23
0
 public ActionResult GetTweets(int count = 3)
 {
     List<string> tweets = null;
     var domain = this.Domain;
     if (domain != null)
     {
         TweetManager tweet = new TweetManager(domain.DO_TwitterToken, domain.DO_TwitterSecret, domain.DO_ConsumerKey, domain.DO_ConsumerSecret);
         tweets = tweet.GetLatestTweets(count);
     }
     return PartialView("/Views/Partials/GetTweets.cshtml", tweets);
 }
    public static void Main(string[] args)
    {
        TweetManager tweetManager = new TweetManager();

        tweetManager.SeeAllTweeters();
    }
Exemplo n.º 25
0
 protected void SendTweet(string message)
 {
     var domain = this.Domain;
     if (domain != null && domain.DO_UpdateTwitter && !String.IsNullOrEmpty(message))
     {
         TweetManager tweet = new TweetManager(domain.DO_TwitterToken, domain.DO_TwitterSecret, domain.DO_ConsumerKey, domain.DO_ConsumerSecret);
         tweet.SendTweet(message);
     }
 }
Exemplo n.º 26
0
        /// <summary>
        /// Get all tweets with "GoDaddy" in them.
        /// 100 per page, up to 15 pages if we loop and make seperate calls for each page
        /// </summary>
        internal Dictionary <int, List <Status> > GetAllMentionsByQuery(TwitterContext cont)
        {
            Dictionary <int, List <Status> > allTwitterMentions = new Dictionary <int, List <Status> >();

            if (XMLUtility.IsComponentEnabled(Xml, ProcessorName))
            {
                int countPerPage; int pageCount;
                TwitterDataSource data = new TwitterDataSource();
                TweetManager      tm   = new TweetManager();

                XMLUtility.GetPageResultCounts(Xml, ProcessorName, out countPerPage, out pageCount, 100, 3);
                List <Keyword> queries    = data.GetTweetQueries();
                bool           useSinceId = XMLUtility.UseSinceId(Xml, ProcessorName);

                //create backup of current keys in case of failure at db level
                lock (cont) cont.prevRunLatestTweetIDs = cont.LatestTweetIDs.ToDictionary(entry => entry.Key, entry => entry.Value);

                foreach (Keyword item in queries)
                {
                    try
                    {
                        long sinceId = 0;
                        if (useSinceId)
                        {
                            //get the last recorded id for this query and use it
                            if (!Object.Equals(cont, null))
                            {
                                lock (cont)
                                {
                                    if (cont.LatestTweetIDs.ContainsKey(item.KeywordId))
                                    {
                                        cont.LatestTweetIDs.TryGetValue(item.KeywordId, out sinceId);
                                    }
                                }
                            }
                        }

                        //call the mention object in the API wrapper
                        TwitterDataComponent _dataComponent = DroneDataComponent as TwitterDataComponent;
                        KeywordStatus        ks             = new KeywordStatus();
                        ks.KeywordId = item.KeywordId;

                        ks.StatusList = tm.GetTweetsByQuery(countPerPage, item.KeywordValue + (sinceId > 0 ? "&since_id=" + sinceId : string.Empty), Utility.GetOAuthToken(Xml));
                        allTwitterMentions.Add(ks.KeywordId, ks.StatusList);

                        _dataComponent.KeywordStatus = ks;
                        DroneDataSource.Process(_dataComponent);

                        //if there was a failure saving to the db, reset the since id to gather and try again
                        if (_dataComponent.SaveFailure)
                        {
                            lock (cont) cont.LatestTweetIDs = cont.prevRunLatestTweetIDs.ToDictionary(entry => entry.Key, entry => entry.Value);
                        }

                        //get the last id for this query and store it
                        if (!Object.Equals(cont, null) && allTwitterMentions.ContainsKey(item.KeywordId) && allTwitterMentions[item.KeywordId].Count > 0)
                        {
                            long latestID;
                            long.TryParse(allTwitterMentions[item.KeywordId][0].id.ToString(), out latestID);

                            lock (cont)
                            {
                                if (cont.LatestTweetIDs.ContainsKey(item.KeywordId))
                                {
                                    cont.LatestTweetIDs[item.KeywordId] = latestID;
                                }
                                else
                                {
                                    cont.LatestTweetIDs.Add(item.KeywordId, latestID);
                                }
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        ExceptionExtensions.LogError(e, "Twitter.GetAllMentionsByQuery()", "Keyword name: " + item.KeywordName);
                    }
                }
            }
            return(allTwitterMentions);
        }
Exemplo n.º 27
0
 public HomeController(TweetManager tweetManager)
 {
     _tweets = tweetManager;
 }