Пример #1
0
        /// <summary>
        /// Add Player to Friends Manager Cache
        /// </summary>
        /// <param name="Player">Gameplayer to Add</param>
        public void AddPlayerFriendsListToCache(GamePlayer Player)
        {
            if (Player == null)
            {
                throw new ArgumentNullException("Player");
            }

            var friends = Player.SerializedFriendsList;

            if (!PlayersFriendsListsCache.AddIfNotExists(Player, friends))
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat("Gameplayer ({0}) is already registered in Friends Manager Cache while adding!", Player);
                }
            }

            var offlineFriends = new FriendStatus[0];

            if (friends.Any())
            {
                offlineFriends = Database.SelectObjects <DOLCharacters>("`Name` = @Name", friends.Select(name => new[] { new QueryParameter("@Name", name) })).SelectMany(chars => chars)
                                 .Select(chr => new FriendStatus(chr.Name, chr.Level, chr.Class, chr.LastPlayed)).ToArray();
            }

            if (!PlayersFriendsStatusCache.AddIfNotExists(Player, offlineFriends))
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat("Gameplayer ({0}) is already registered in Friends Manager Status Cache while adding!", Player);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// Add Player to Friends Manager Cache
        /// </summary>
        /// <param name="Player">Gameplayer to Add</param>
        public void AddPlayerFriendsListToCache(GamePlayer Player)
        {
            if (Player == null)
            {
                throw new ArgumentNullException("Player");
            }

            var friends = Player.SerializedFriendsList;

            if (!PlayersFriendsListsCache.AddIfNotExists(Player, friends))
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat("Gameplayer ({0}) is already registered in Friends Manager Cache while adding!", Player);
                }
            }

            var offlineFriends = Array.Empty <FriendStatus>();

            if (friends.Any())
            {
                offlineFriends = Database.SelectObjects <DOLCharacters>(DB.Column(nameof(DOLCharacters.Name)).IsIn(friends))
                                 .Select(chr => new FriendStatus(chr.Name, chr.Level, chr.Class, chr.LastPlayed)).ToArray();
            }

            if (!PlayersFriendsStatusCache.AddIfNotExists(Player, offlineFriends))
            {
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat("Gameplayer ({0}) is already registered in Friends Manager Status Cache while adding!", Player);
                }
            }
        }