コード例 #1
0
        /// <summary>
        /// Clones indicator without session data
        /// </summary>
        /// <returns></returns>
        public SessionCacheStatistic Clone()
        {
            var clonePlayerData = new HudIndicators();

            clonePlayerData.AddIndicator(PlayerData);

            // clone heat map
            foreach (var heatMapKeyValue in clonePlayerData.HeatMaps)
            {
                if (!PlayerData.HeatMaps.ContainsKey(heatMapKeyValue.Key))
                {
                    continue;
                }

                var heatMapDto = PlayerData.HeatMaps[heatMapKeyValue.Key];

                heatMapKeyValue.Value.OccuredByCardRange = new Dictionary <string, int>(heatMapDto.OccuredByCardRange);
            }

            var clone = new SessionCacheStatistic
            {
                IsHero     = IsHero,
                GameFormat = GameFormat,
                PlayerData = clonePlayerData
            };

            return(clone);
        }
コード例 #2
0
        private void LoadIndicators(int seats, ReplayerViewModel viewModel, IEnumerable <Stat> heatMapStats)
        {
            var tasksToLoad = new List <Task>();

            var selectedPlayer = storageModel.PlayerSelectedItem;

            var players = viewModel.PlayersCollection.Select(x => x.Name).ToArray();

            for (var i = 0; i < seats; i++)
            {
                var player = players[i];

                if (playerIndicators.ContainsKey(player))
                {
                    continue;
                }

                var playerData = new HudIndicators(heatMapStats);

                // read data from statistic
                var taskToReadPlayerStats = Task.Run(() =>
                {
                    if (selectedPlayer != null &&
                        player == selectedPlayer.Name &&
                        (short?)selectedPlayer.PokerSite == viewModel.CurrentHand.PokersiteId)
                    {
                        storageModel
                        .GetStatisticCollection()
                        .Where(stat => (stat.PokersiteId == (short)viewModel.CurrentGame.GameDescription.Site) &&
                               stat.IsTourney == viewModel.CurrentGame.GameDescription.IsTournament &&
                               GameTypeUtils.CompareGameType((GameType)stat.PokergametypeId, viewModel.CurrentGame.GameDescription.GameType))
                        .ForEach(stat => playerData.AddStatistic(stat));

                        playerIndicators.AddOrUpdate(player, playerData, (key, old) => playerData);
                        return;
                    }

                    playerStatisticRepository
                    .GetPlayerStatistic(player, (short)viewModel.CurrentGame.GameDescription.Site)
                    .Where(stat => (stat.PokersiteId == (short)viewModel.CurrentGame.GameDescription.Site) &&
                           stat.IsTourney == viewModel.CurrentGame.GameDescription.IsTournament &&
                           GameTypeUtils.CompareGameType((GameType)stat.PokergametypeId, viewModel.CurrentGame.GameDescription.GameType))
                    .ForEach(stat => playerData.AddStatistic(stat));

                    playerIndicators.AddOrUpdate(player, playerData, (key, old) => playerData);
                });

                tasksToLoad.Add(taskToReadPlayerStats);
            }

            Task.WhenAll(tasksToLoad).Wait();
        }
コード例 #3
0
        // [TestCase(203)]
        public void Test(int userId)
        {
            ResourceRegistrator.Initialization();

            var hudIndicator  = new HudIndicators(new List <Stat>());
            var advIndicator  = new AdvancedIndicator();
            var advIndicator2 = new AdvancedIndicator();

            var cycles = 1;

            using (var pf = new PerformanceMonitor("Old way"))
            {
                for (var i = 0; i < cycles; i++)
                {
                    var repository = new PlayerStatisticRepository();
                    repository.SetPlayerStatisticPath(statisticPath);
                    repository.GetPlayerStatistic(userId).ForEach(x => hudIndicator.AddStatistic(x));
                }
            }

            //using (var pf = new PerformanceMonitor("New way"))
            //{
            //    for (var i = 0; i < cycles; i++)
            //    {
            //        var repository = new PlayerStatisticRepository();
            //        repository.SetPlayerStatisticPath(statisticPath);
            //        var stats = repository.GetPlayerStatistic(13078).ToList();

            //        Parallel.ForEach(stats, x => advIndicator.ProcessStatistic(x));
            //    }
            //}

            //using (var pf = new PerformanceMonitor("New way2"))
            //{
            //    for (var i = 0; i < cycles; i++)
            //    {
            //        var repository = new PlayerStatisticRepository();
            //        repository.SetPlayerStatisticPath(statisticPath);
            //        repository.GetPlayerStatistic(13078).ForEach(x => advIndicator2.ProcessStatistic(x));
            //    }
            //}
        }