예제 #1
0
        /// <summary>
        /// Execute
        /// </summary>
        public override void Execute()
        {
            using (new PerformanceMonitor())
            {
                var profiles = userCore.PublicProfilesFull(Application.Default);
                foreach (var profile in profiles)
                {
                    var social = new CodeStormSocial()
                    {
                        AbcHandle     = profile.Handle,
                        TwitterHandle = profile.TwitterHandle,
                        GitHubHandle  = profile.GitHubHandle,
                    };

                    try
                    {
                        if (!string.IsNullOrWhiteSpace(social.TwitterHandle))
                        {
                            var tweets   = twitter.ByUser(social.TwitterHandle, 5);
                            var links    = new List <string>();
                            var mentions = new List <string>();
                            foreach (var tweet in tweets)
                            {
                                links.AddRange(tweet.ParseLinks());
                                mentions.AddRange(tweet.ParseMentions().Distinct());
                            }

                            var twitterMentions = new List <Mention>();
                            foreach (var mention in mentions.Distinct())
                            {
                                var userMention = new Mention()
                                {
                                    TwitterHandle = mention,
                                };

                                userMention.AbcHandle = (from data in profiles
                                                         where data.TwitterHandle == mention
                                                         select data.Handle).FirstOrDefault();

                                twitterMentions.Add(userMention);
                            }

                            social.TwitterLinks = links;

                            social.TwitterMentions = twitterMentions;
                        }
                        else
                        {
                            log.Log("Twitter Handle is empty.");
                        }
                    }
                    catch (Exception ex)
                    {
                        base.log.Log(ex, EventTypes.Error, (int)ServiceFault.Unknown);
                    }

                    container.Save(social.AbcHandle, social);
                }
            }
        }
        public void TwitterLinks()
        {
            var item = new CodeStormSocial();
            var data = new List <string>();

            item.TwitterLinks = data;
            Assert.AreEqual <IEnumerable <string> >(data, item.TwitterLinks);
        }
        public void TwitterMentions()
        {
            var item = new CodeStormSocial();
            var data = new List <Mention>();

            item.TwitterMentions = data;
            Assert.AreEqual <IEnumerable <Mention> >(data, item.TwitterMentions);
        }
        public void GitHubHandle()
        {
            var item = new CodeStormSocial();
            var data = StringHelper.ValidString();

            item.GitHubHandle = data;
            Assert.AreEqual <string>(data, item.GitHubHandle);
        }