Example #1
0
        /// <summary>
        /// Persists the tweet to our in-memory mechanism.
        /// </summary>
        /// <param name="tweet">The tweet.</param>
        /// <returns></returns>
        public bool PersistTweet(TweetV2 tweet)
        {
            var isPersisted = false;

            if (this.TweetList == null)
            {
                this.TweetList       = new List <TweetV2>();
                this.StreamStartTime = DateTime.UtcNow;
            }

            try
            {
                this.TweetList.Add(tweet);
                if (this.TweetList.Count % 1000 == 0 && this.TweetList.Count <= 5000)
                {
                    Console.WriteLine($"We have received {this.TweetList.Count} tweets");
                    this.WriteTweetsToFile(this.TweetList.Count - 1000, 500);
                }
                isPersisted = true;
            }
            catch (Exception e)
            {
            }

            return(isPersisted);
        }
Example #2
0
 public IEnumerable <string> Resolve(TweetV2 source, Tweet destination,
                                     IEnumerable <string> destMember, ResolutionContext context)
 {
     return(source.Entities?.Urls?
            .Select(url => url?.ExpandedUrl ??
                    url?.Url).ToArray() ??
            Array.Empty <string>());
 }
Example #3
0
 public bool PersistTweet(TweetV2 tweet)
 {
     try
     {
         return(this.TwitterResults.PersistTweet(tweet));
     }
     catch (Exception e)
     {
     }
     return(false);
 }
        /// <summary>
        ///     This is the main entrypoint for collecting info on tweets.
        /// </summary>
        /// <param name="tweet"></param>
        public void ProcessTweet(TweetV2 tweet)
        {
            _tweetInfoRepository.IncrementCount();

            ProcessEmoji(tweet.Text);

            if (tweet.Entities?.Hashtags != null && tweet.Entities.Hashtags.Any())
            {
                ProcessHashtags(tweet.Entities.Hashtags);
            }

            if (tweet.Entities?.Urls != null && tweet.Entities.Urls.Any())
            {
                ProcessUrls(tweet.Entities.Urls);
            }
        }
Example #5
0
 public IEnumerable <string> Resolve(TweetV2 source, Tweet destination,
                                     IEnumerable <string> destMember, ResolutionContext context)
 {
     if (source.Entities?.Urls == null)
     {
         return(Array.Empty <string>());
     }
     return(source.Entities.Urls
            .Select(entity =>
     {
         var urlToUse = entity?.ExpandedUrl ??
                        entity?.Url ??
                        entity?.DisplayUrl;
         return urlToUse == null
                 ? string.Empty
                 : new Uri(urlToUse, UriKind.Absolute).DnsSafeHost;
     }));
 }
        public IEnumerable <string> Resolve(TweetV2 source, Tweet destination,
                                            IEnumerable <string> destMember, ResolutionContext context)
        {
            if (source.Entities?.Urls == null)
            {
                return(Array.Empty <string>());
            }

            return(source.Entities.Urls
                   .Where(entity => PhotoUrlMatches
                          .Any(match =>
            {
                var matchString = entity?.ExpandedUrl ??
                                  entity?.Url ??
                                  entity?.DisplayUrl;
                return matchString != null &&
                matchString.Contains(match,
                                     StringComparison.CurrentCultureIgnoreCase);
            }))
                   .Select(src => src.ExpandedUrl));
        }
 public TweetV2EventArgs(TweetV2 tweet, TweetIncludesV2 includes, string json)
 {
     Tweet    = tweet;
     Includes = includes;
     Json     = json;
 }
Example #8
0
 public bool PersistTweet(TweetV2 tweet)
 {
     return(this.TwitterResults.PersistTweet(tweet));
 }
Example #9
0
 public IEnumerable <string> Resolve(TweetV2 source, Tweet destination,
                                     IEnumerable <string> destMember, ResolutionContext context)
 {
     return(source.Entities?.Hashtags?
            .Select(src => src.Tag).ToArray() ?? Array.Empty <string>());
 }
Example #10
0
 public bool PersistTweet(TweetV2 tweet)
 {
     throw new NotImplementedException();
 }
Example #11
0
        /// <summary>
        /// Persists the tweet.
        /// </summary>
        /// <param name="tweet">The tweet.</param>
        /// <returns></returns>
        public bool PersistTweet(TweetV2 tweet)
        {
            var isPersisted = this.Repository.PersistTweet(tweet);

            return(isPersisted);
        }
Example #12
0
 public FilteredStreamTweetV2EventArgs(TweetV2 tweet, TweetIncludesV2 includes, FilteredStreamMatchingRuleV2[] matchingRules, string json) : base(tweet, includes, json)
 {
     MatchingRules = matchingRules;
 }