Exemplo n.º 1
0
 Inline CreateHashtagLink(TwitterHashTag Hashtag)
 {
     MenuItem item = new MenuItem
     {
         Header = Localization.Resources.MuteHashtag,
         Foreground = new SolidColorBrush(Colors.Black)
     };
     item.Click += (sender, e) =>
     {
         var filter = FilterManager.SetupMute(FilterType.Text, "#" + Hashtag.Text);
         Dependency.Resolve<IMessageService>().ShowMessage(String.Format(Localization.Resources.MutedUntil, filter.IsValidUntil.ToString("f")), "");
     };
     return CreateBaseLink("#" + Hashtag.Text, Localization.Resources.CopyHashtag, "#" + Hashtag.Text, item);
 }
Exemplo n.º 2
0
        Inline CreateHashtagLink(TwitterHashTag Hashtag)
        {
            MenuItem item = new MenuItem
            {
                Header     = Localization.Resources.MuteHashtag,
                Foreground = new SolidColorBrush(Colors.Black)
            };

            item.Click += (sender, e) =>
            {
                var filter = FilterManager.SetupMute(FilterType.Text, "#" + Hashtag.Text);
                Dependency.Resolve <IMessageService>().ShowMessage(String.Format(Localization.Resources.MutedUntil, filter.IsValidUntil.ToString("f")), "");
            };
            return(CreateBaseLink("#" + Hashtag.Text, Localization.Resources.CopyHashtag, "#" + Hashtag.Text, item));
        }
        public bool AddBoardTwitterHashTagFeeds(string HashTag, string BoardTagid, string LastTweetId, Helper.AppSettings settings, ILogger _logger)
        {
            MongoRepository           mongorepo    = new MongoRepository("MongoBoardTwtFeeds", settings);
            bool                      output       = false;
            List <MongoBoardTwtFeeds> twtFeedsList = new List <MongoBoardTwtFeeds>();
            string                    timeline     = TwitterHashTag.TwitterBoardHashTagSearch(HashTag, LastTweetId);
            int i = 0;

            if (!string.IsNullOrEmpty(timeline) && !timeline.Equals("[]"))
            {
                foreach (JObject obj in JArray.Parse(timeline))
                {
                    MongoBoardTwtFeeds twitterfeed = new MongoBoardTwtFeeds();
                    twitterfeed.Id = ObjectId.GenerateNewId();

                    i++;
                    try
                    {
                        twitterfeed.Feedurl = JArray.Parse(obj["extended_entities"]["media"].ToString())[0]["url"].ToString();
                    }
                    catch
                    {
                        try
                        {
                            twitterfeed.Feedurl = JArray.Parse(obj["entities"]["urls"].ToString())[0]["expanded_url"].ToString();
                        }
                        catch (Exception e)
                        {
                            _logger.LogError(e.Message);
                            _logger.LogError(e.StackTrace);
                        }
                    }
                    try
                    {
                        twitterfeed.Imageurl = JArray.Parse(obj["extended_entities"]["media"].ToString())[0]["media_url"].ToString();
                    }
                    catch
                    {
                        try
                        {
                            twitterfeed.Imageurl = JArray.Parse(obj["entities"]["media"].ToString())[0]["media_url"].ToString();
                        }
                        catch (Exception e)
                        {
                            _logger.LogError(e.Message);
                            _logger.LogError(e.StackTrace);
                        }
                    }
                    try
                    {
                        foreach (JObject tag in JArray.Parse(obj["entities"]["hashtags"].ToString()))
                        {
                            try
                            {
                                twitterfeed.Hashtags = tag["text"].ToString() + ",";
                            }
                            catch (Exception e)
                            {
                                _logger.LogError(e.Message);
                                _logger.LogError(e.StackTrace);
                            }
                        }
                    }
                    catch { }
                    try
                    {
                        twitterfeed.Text = obj["text"].ToString();
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e.Message);
                        _logger.LogError(e.StackTrace);
                    }
                    try
                    {
                        twitterfeed.Retweetcount = Convert.ToInt32(obj["retweet_count"].ToString());
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e.Message);
                        _logger.LogError(e.StackTrace);
                    }
                    try
                    {
                        twitterfeed.Favoritedcount = Convert.ToInt32(obj["favorite_count"].ToString());
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e.Message);
                        _logger.LogError(e.StackTrace);
                    }
                    try
                    {
                        string Const_TwitterDateTemplate = "ddd MMM dd HH:mm:ss +ffff yyyy";
                        twitterfeed.Publishedtime = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.ParseExact((string)obj["created_at"], Const_TwitterDateTemplate, new System.Globalization.CultureInfo("en-US")));
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e.Message);
                        _logger.LogError(e.StackTrace);
                    }
                    try
                    {
                        twitterfeed.Feedid = obj["id_str"].ToString();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            twitterfeed.Feedid = obj["id"].ToString();
                        }
                        catch (Exception e)
                        {
                            _logger.LogError(e.Message);
                            _logger.LogError(e.StackTrace);
                        }
                    }
                    try
                    {
                        twitterfeed.FromId = obj["user"]["id_str"].ToString();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            twitterfeed.FromId = obj["user"]["id"].ToString();
                        }
                        catch (Exception e)
                        {
                            _logger.LogError(e.Message);
                            _logger.LogError(e.StackTrace);
                        }
                    }
                    try
                    {
                        twitterfeed.FromName = obj["user"]["screen_name"].ToString();
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e.Message);
                        _logger.LogError(e.StackTrace);
                    }
                    try
                    {
                        twitterfeed.FromPicUrl = obj["user"]["profile_image_url"].ToString();
                    }
                    catch (Exception e)
                    {
                        _logger.LogError(e.Message);
                        _logger.LogError(e.StackTrace);
                    }
                    twitterfeed.Isvisible        = true;
                    twitterfeed.Twitterprofileid = BoardTagid;
                    try
                    {
                        mongorepo.Add <MongoBoardTwtFeeds>(twitterfeed);
                    }
                    catch (Exception e) { }

                    output = true;
                }
            }
            return(output);
        }
        public bool AddTwittertrendingHashTagFeedsFBPlugin(string HashTag, string trendingTagid, string LastTweetId, Helper.AppSettings _appSettings)
        {
            //Helper.AppSettings _appSettings;
            MongoRepository           mongorepo    = new MongoRepository("MongoBoardTwtFeeds", _appSettings);
            bool                      output       = false;
            List <MongoBoardTwtFeeds> twtFeedsList = new List <MongoBoardTwtFeeds>();
            string                    timeline     = TwitterHashTag.TwitterBoardHashTagSearch(HashTag, LastTweetId);
            int i = 0;

            if (!string.IsNullOrEmpty(timeline) && !timeline.Equals("[]"))
            {
                foreach (JObject obj in JArray.Parse(timeline))
                {
                    MongoBoardTwtFeeds twitterfeed = new MongoBoardTwtFeeds();
                    twitterfeed.Id = ObjectId.GenerateNewId();

                    i++;
                    try
                    {
                        twitterfeed.Feedurl = JArray.Parse(obj["extended_entities"]["media"].ToString())[0]["url"].ToString();
                    }
                    catch
                    {
                        try
                        {
                            twitterfeed.Feedurl = JArray.Parse(obj["entities"]["urls"].ToString())[0]["expanded_url"].ToString();
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    try
                    {
                        twitterfeed.Imageurl = JArray.Parse(obj["extended_entities"]["media"].ToString())[0]["media_url"].ToString();
                    }
                    catch
                    {
                        try
                        {
                            twitterfeed.Imageurl = JArray.Parse(obj["entities"]["media"].ToString())[0]["media_url"].ToString();
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    try
                    {
                        foreach (JObject tag in JArray.Parse(obj["entities"]["hashtags"].ToString()))
                        {
                            try
                            {
                                twitterfeed.Hashtags = tag["text"].ToString() + ",";
                            }
                            catch (Exception e)
                            {
                            }
                        }
                    }
                    catch { }
                    try
                    {
                        twitterfeed.Text = obj["text"].ToString();
                    }
                    catch (Exception e)
                    {
                    }
                    try
                    {
                        twitterfeed.Retweetcount = Convert.ToInt32(obj["retweet_count"].ToString());
                    }
                    catch (Exception e)
                    {
                    }
                    try
                    {
                        twitterfeed.Favoritedcount = Convert.ToInt32(obj["favorite_count"].ToString());
                    }
                    catch (Exception e)
                    {
                    }
                    try
                    {
                        string Const_TwitterDateTemplate = "ddd MMM dd HH:mm:ss +ffff yyyy";
                        twitterfeed.Publishedtime = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.ParseExact((string)obj["created_at"], Const_TwitterDateTemplate, new System.Globalization.CultureInfo("en-US")));
                    }
                    catch (Exception e)
                    {
                    }
                    try
                    {
                        twitterfeed.Feedid = obj["id_str"].ToString();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            twitterfeed.Feedid = obj["id"].ToString();
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    try
                    {
                        twitterfeed.FromId = obj["user"]["id_str"].ToString();
                    }
                    catch (Exception ex)
                    {
                        try
                        {
                            twitterfeed.FromId = obj["user"]["id"].ToString();
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    try
                    {
                        twitterfeed.FromName = obj["user"]["screen_name"].ToString();
                    }
                    catch (Exception e)
                    {
                    }
                    try
                    {
                        twitterfeed.FromPicUrl = obj["user"]["profile_image_url"].ToString();
                    }
                    catch (Exception e)
                    {
                    }
                    twitterfeed.Isvisible        = true;
                    twitterfeed.Twitterprofileid = trendingTagid;
                    var ret  = mongorepo.Find <MongoBoardTwtFeeds>(t => t.Feedid == twitterfeed.Feedid);
                    var task = Task.Run(async() =>
                    {
                        return(await ret);
                    });
                    int count = task.Result.Count;
                    if (count < 1)
                    {
                        try
                        {
                            mongorepo.Add <MongoBoardTwtFeeds>(twitterfeed);
                        }
                        catch (Exception e) { }
                    }
                    else
                    {
                        FilterDefinition <BsonDocument> filter = new BsonDocument("Feedid", twitterfeed.Feedid);
                        var update = Builders <BsonDocument> .Update
                                     .Set("Favoritedcount", twitterfeed.Favoritedcount)
                                     .Set("FromPicUrl", twitterfeed.FromPicUrl)
                                     .Set("Retweetcount", twitterfeed.Retweetcount);

                        mongorepo.Update <Domain.Socioboard.Models.Mongo.MongoBoardTwtFeeds>(update, filter);
                    }
                    output = true;
                }
            }
            return(output);
        }
Exemplo n.º 5
0
        private void ProcessTwitterTweets(string blobText, T_CollectionTask t_newTask)
        {
            //1-Deserialize
            List <T_TwitterTweet>       t_tweets       = new List <T_TwitterTweet>();
            List <T_TwitterGeoLocation> t_geoLocations = new List <T_TwitterGeoLocation>();
            List <T_TwitterPlace>       t_places       = new List <T_TwitterPlace>();
            List <T_TwitterHashTag>     t_hashTags     = new List <T_TwitterHashTag>();
            List <T_TwitterMedia>       t_medias       = new List <T_TwitterMedia>();
            List <T_TwitterMention>     t_mentions     = new List <T_TwitterMention>();
            List <T_TwitterUrl>         t_urls         = new List <T_TwitterUrl>();

            List <TwitterStatus> tweets = JsonConvert.DeserializeObject <List <TwitterStatus> >(blobText);

            #region Tweets
            foreach (TwitterStatus tweet in tweets)
            {
                T_TwitterTweet t_tweet = new T_TwitterTweet();
                t_tweet.CollectionTaskId    = t_newTask.Id;
                t_tweet.CreatedDate         = tweet.CreatedDate;
                t_tweet.InReplayToTweetId   = tweet.InReplyToStatusId;
                t_tweet.InReplayToUserId    = tweet.InReplyToUserId;
                t_tweet.InReplyToScreenName = tweet.InReplyToScreenName;
                t_tweet.IsFavorited         = tweet.IsFavorited;
                t_tweet.IsPossiblySensitive = tweet.IsPossiblySensitive;
                t_tweet.IsTruncated         = tweet.IsTruncated;
                t_tweet.RetweetCount        = tweet.RetweetCount;
                t_tweet.Source            = tweet.Source;
                t_tweet.Text              = tweet.Text;
                t_tweet.TweeterId         = tweet.User.Id;
                t_tweet.TweeterScreenName = tweet.User.ScreenName;
                t_tweet.TweetId           = tweet.Id;

                t_tweets.Add(t_tweet);

                if (tweet.Location != null)
                {
                    T_TwitterGeoLocation t_geoLocation = new T_TwitterGeoLocation();
                    t_geoLocation.CollectionTaskId = t_newTask.Id;
                    t_geoLocation.TweetId          = t_tweet.TweetId;
                    t_geoLocation.TweeterUserId    = t_tweet.TweeterId;

                    t_geoLocation.Longitude = Math.Round(Convert.ToDecimal(tweet.Location.Coordinates.Longitude), 6);
                    t_geoLocation.Latitude  = Math.Round(Convert.ToDecimal(tweet.Location.Coordinates.Latitude), 6);

                    t_geoLocations.Add(t_geoLocation);
                }

                if (tweet.Place != null)
                {
                    T_TwitterPlace t_place = new T_TwitterPlace();
                    t_place.CollectionTaskId = t_newTask.Id;
                    t_place.TweetId          = t_tweet.TweetId;
                    t_place.TweeterUserId    = t_tweet.TweeterId;

                    t_place.Country     = tweet.Place.Country;
                    t_place.CountryCode = tweet.Place.CountryCode;
                    t_place.FullName    = tweet.Place.FullName;
                    t_place.Name        = tweet.Place.Name;
                    t_place.PlaceId     = tweet.Place.Id;
                    t_place.PlaceType   = tweet.Place.PlaceType.ToString();
                    t_place.Url         = tweet.Place.Url;

                    t_places.Add(t_place);
                }

                if (tweet.Entities != null)
                {
                    if (tweet.Entities.Count <TwitterEntity>() > 0)
                    {
                        foreach (TwitterEntity entity in tweet.Entities)
                        {
                            switch (entity.EntityType)
                            {
                            case TwitterEntityType.HashTag:
                                TwitterHashTag   hashTag   = (TwitterHashTag)entity;
                                T_TwitterHashTag t_hashTag = new T_TwitterHashTag();
                                t_hashTag.CollectionTaskId = t_newTask.Id;
                                t_hashTag.TweetId          = t_tweet.TweetId;
                                t_hashTag.TweeterUserId    = t_tweet.TweeterId;

                                t_hashTag.Text = hashTag.Text;

                                t_hashTags.Add(t_hashTag);
                                break;

                            case TwitterEntityType.Media:
                                TwitterMedia   media   = (TwitterMedia)entity;
                                T_TwitterMedia t_media = new T_TwitterMedia();
                                t_media.CollectionTaskId = t_newTask.Id;
                                t_media.TweetId          = t_tweet.TweetId;
                                t_media.TweeterUserId    = t_tweet.TweeterId;

                                t_media.DisplayUrl  = media.DisplayUrl;
                                t_media.ExpandedUrl = media.ExpandedUrl;
                                t_media.MediaId     = media.Id;
                                t_media.MediaType   = media.MediaType.ToString();
                                t_media.MediaUrl    = media.MediaUrl;
                                t_media.Url         = media.Url;

                                t_medias.Add(t_media);
                                break;

                            case TwitterEntityType.Mention:
                                TwitterMention   mention   = (TwitterMention)entity;
                                T_TwitterMention t_mention = new T_TwitterMention();
                                t_mention.CollectionTaskId = t_newTask.Id;
                                t_mention.TweetId          = t_tweet.TweetId;
                                t_mention.TweeterUserId    = t_tweet.TweeterId;

                                t_mention.MentionId  = mention.Id;
                                t_mention.Name       = mention.Name;
                                t_mention.ScreenName = mention.ScreenName;

                                t_mentions.Add(t_mention);
                                break;

                            case TwitterEntityType.Url:
                                TwitterUrl   url   = (TwitterUrl)entity;
                                T_TwitterUrl t_url = new T_TwitterUrl();
                                t_url.CollectionTaskId = t_newTask.Id;
                                t_url.TweetId          = t_tweet.TweetId;
                                t_url.TweeterUserId    = t_tweet.TweeterId;

                                t_url.ExpandedValue = url.ExpandedValue;
                                t_url.Value         = url.Value;

                                t_urls.Add(t_url);
                                break;

                            default:
                                throw new NotImplementedException();
                            }
                        }
                    }
                }
            }
            #endregion

            //2-Validate

            //3-Update
            LinqToSqlAzureHaystackDataContext context = new LinqToSqlAzureHaystackDataContext();
            context.T_TwitterTweets.InsertAllOnSubmit <T_TwitterTweet>(t_tweets);

            context.T_TwitterGeoLocations.InsertAllOnSubmit <T_TwitterGeoLocation>(t_geoLocations);

            context.T_TwitterPlaces.InsertAllOnSubmit <T_TwitterPlace>(t_places);

            context.T_TwitterHashTags.InsertAllOnSubmit <T_TwitterHashTag>(t_hashTags);

            context.T_TwitterMedias.InsertAllOnSubmit <T_TwitterMedia>(t_medias);

            context.T_TwitterMentions.InsertAllOnSubmit <T_TwitterMention>(t_mentions);

            context.T_TwitterUrls.InsertAllOnSubmit <T_TwitterUrl>(t_urls);
            context.SubmitChanges();
        }
Exemplo n.º 6
0
        public static IEnumerable<TwitterHashTag> ParseTwitterageToHashTags(this string input)
        {
            if (input.IsNullOrBlank())
            {
                yield break;
            }

            foreach (Match match in ParseHashtags.Matches(input))
            {
                var hashtag = new TwitterHashTag
                                  {
                                      Text = match.Value.Substring(1),
                                      Indices = new[] { match.Index, match.Index + match.Value.Length }
                                  };

                yield return hashtag;
            }
        }
Exemplo n.º 7
0
        public static void addContentfeedsdata(string keyword)
        {
            MongoRepository mongorepo = new MongoRepository("RssNewsContentsFeeds");
            string          timeline  = TwitterHashTag.TwitterBoardHashTagSearch(keyword, null);
            int             i         = 0;

            if (!string.IsNullOrEmpty(timeline) && !timeline.Equals("[]"))
            {
                foreach (JObject obj in JArray.Parse(timeline))
                {
                    RssNewsContentsFeeds contentFeedsDet = new RssNewsContentsFeeds();
                    contentFeedsDet.Id = ObjectId.GenerateNewId();
                    i++;
                    try
                    {
                        contentFeedsDet.Link = JArray.Parse(obj["entities"]["expanded_url"].ToString())[0]["url"].ToString();
                    }
                    catch
                    {
                        try
                        {
                            contentFeedsDet.Link = JArray.Parse(obj["entities"]["urls"].ToString())[0]["expanded_url"].ToString();
                        }
                        catch (Exception e)
                        {
                        }
                    }
                    try
                    {
                        contentFeedsDet.Image = JArray.Parse(obj["extended_entities"]["media"].ToString())[0]["media_url"].ToString();
                    }
                    catch
                    {
                        try
                        {
                            contentFeedsDet.Image = JArray.Parse(obj["entities"]["media"].ToString())[0]["media_url"].ToString();
                        }
                        catch (Exception e)
                        {
                        }
                    }

                    try
                    {
                        contentFeedsDet.Title = obj["text"].ToString();
                    }
                    catch (Exception e)
                    {
                    }

                    try
                    {
                        string Const_TwitterDateTemplate = "ddd MMM dd HH:mm:ss +ffff yyyy";
                        contentFeedsDet.PublishingDate = Domain.Socioboard.Helpers.SBHelper.ConvertToUnixTimestamp(DateTime.ParseExact((string)obj["created_at"], Const_TwitterDateTemplate, new System.Globalization.CultureInfo("en-US"))).ToString();
                    }
                    catch (Exception e)
                    {
                    }
                    contentFeedsDet.keywords = keyword;

                    var ret  = mongorepo.Find <RssNewsContentsFeeds>(t => t.Image == contentFeedsDet.Image);
                    var task = Task.Run(async() =>
                    {
                        return(await ret);
                    });
                    int count = task.Result.Count;
                    if (count < 1)
                    {
                        try
                        {
                            mongorepo.Add <RssNewsContentsFeeds>(contentFeedsDet);
                        }
                        catch (Exception e) { }
                    }
                    else
                    {
                    }
                }
            }
        }