Ejemplo n.º 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);
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute Gamification Routine
        /// </summary>
        public override void Execute()
        {
            using (new PerformanceMonitor())
            {
                var application = Application.Default;
                int value;
                var profiles = userCore.PublicProfilesFull(application, true);
                foreach (var profile in profiles)
                {
                    try
                    {
                        value = this.profile.Evaluate(profile);

                        var save = ((IConvert <ProfilePage>)profile).Convert();
                        save.Points = value;
                        save.ApplicationIdentifier = application.Identifier;

                        this.userCore.Save(save);
                    }
                    catch (Exception ex)
                    {
                        log.Log(ex, EventTypes.Critical, (int)ServiceFault.Unknown);
                    }
                }
            }
        }