コード例 #1
0
        /// <summary>
        /// Publishes the last 5 achievements added within the last 5 minutes for the given user.
        /// </summary>
        /// <param name="facebookUserId">The facebook user id.</param>
        /// <param name="steamUserId">The steam user id.</param>
        /// <returns>true if successful, else false.</returns>
        public bool PublishLatestAchievements(long facebookUserId, string steamUserId)
        {
            if (steamUserId == null)
            {
                throw new ArgumentNullException("steamUserId");
            }

            IEnumerable <Data.Achievement> dataAchievements = _achievementManager.GetLatestAchievements(steamUserId);
            IEnumerable <Game>             games            = _communityService.GetGames(steamUserId);

            if (dataAchievements.Any())
            {
                IEnumerable <Achievement> achievements =
                    from achievement in dataAchievements
                    from game in games
                    where achievement.GameId == game.Id
                    select new Achievement
                {
                    Name        = achievement.Name,
                    Description = achievement.Description,
                    ImageUrl    = new Uri(achievement.ImageUrl, UriKind.Absolute),
                    Closed      = true,
                    Game        = game
                };

                AchievementsPublisher publisher = new AchievementsPublisher();
                publisher.Publish(achievements, steamUserId, facebookUserId);
            }

            return(true);
        }
        /// <summary>
        /// Publishes the last 5 achievements added within the last 5 minutes for the given user.
        /// </summary>
        /// <param name="facebookUserId">The facebook user id.</param>
        /// <param name="steamUserId">The steam user id.</param>
        /// <returns>true if successful, else false.</returns>
        public bool PublishLatestAchievements(long facebookUserId, string steamUserId)
        {
            if (steamUserId == null)
            {
                throw new ArgumentNullException("steamUserId");
            }

            IEnumerable <Achievement> achievements = _service.GetLatestAchievements(steamUserId);

            if (achievements.Any())
            {
                AchievementsPublisher publisher = new AchievementsPublisher();
                publisher.Publish(achievements, steamUserId, facebookUserId);
            }

            return(true);
        }
コード例 #3
0
        /// <summary>
        /// Publishes the last 5 achievements added within the last 5 minutes for the given user.
        /// </summary>
        /// <param name="facebookUserId">The facebook user id.</param>
        /// <param name="steamUserId">The steam user id.</param>
        /// <returns>true if successful, else false.</returns>
        public bool PublishLatestAchievements(long facebookUserId, string steamUserId)
        {
            if (steamUserId == null)
            {
                throw new ArgumentNullException("steamUserId");
            }

            IEnumerable<Data.Achievement> dataAchievements = _achievementManager.GetLatestAchievements(steamUserId);
            IEnumerable<Game> games = from game in _communityService.GetGames(steamUserId)
                                      where game.PlayedRecently
                                      select game;

            if (dataAchievements.Any())
            {
                AchievementsPublisher publisher = new AchievementsPublisher();
                publisher.Publish(dataAchievements.ToAchievements(games), steamUserId, facebookUserId);

                _achievementManager.UpdatePublished(steamUserId, dataAchievements.Select(achievement => achievement.Id));
            }

            return true;
        }