Esempio n. 1
0
 //select all list
 private void buttonSelectAll_Click_1(object sender, EventArgs e)
 {
     for (int i = 0; i < MatchesList.Items.Count; i++)
     {
         MatchesList.SetItemChecked(i, true);
     }
 }
        public void TestNormalUse()
        {
            var list = new MatchesList(5);

            list.Count.Should().Be(0);
            list.Add("one", "two", null);
            list.Count.Should().Be(1);
            list.Add("three", "four", null);
            list.Count.Should().Be(2);
            var iterator = list.GetEnumerator();
            var next     = iterator.MoveNext();

            next.Should().BeTrue();
            var match1 = iterator.Current;

            next = iterator.MoveNext();
            next.Should().BeTrue();
            var match2 = iterator.Current;

            next = iterator.MoveNext();
            next.Should().BeFalse();
            match1.Key.Should().Be("one");
            match1.Value.Should().Be("two");
            match1.Result.Should().BeNull();
            match2.Key.Should().Be("three");
            match2.Value.Should().Be("four");
            match2.Result.Should().BeNull();
        }
        public async Task <List <MatchDetail> > GetSummonerMatchesAsync(string summonerName, int page, int[] queues, int[] seasons)
        {
            // In case of not sending any queue all valid queues are used.
            queues = (queues.Length == 0 ? validQueues : queues);

            var summonerData = await _riotService.GetSummoner(summonerName);

            int beginIndex = page;
            int endIndex   = page * _maxMatchesPerRequest;

            if (beginIndex == 1)
            {
                endIndex   = _maxMatchesPerRequest;
                beginIndex = 0;
            }
            else
            {
                endIndex   = page * _maxMatchesPerRequest;
                beginIndex = endIndex - _maxMatchesPerRequest;
            }

            var result = new MatchesList
            {
                Matches = new List <Match>()
            };

            foreach (int queue in queues)
            {
                if (seasons.Length > 0)
                {
                    foreach (int season in seasons)
                    {
                        MatchesList summonerMatches;
                        if (season == 14)
                        {
                            summonerMatches = await _riotService.GetSummonerMatches(summonerData.AccountId, queue, 13, 1578668400000, beginIndex, endIndex);
                        }
                        else
                        {
                            summonerMatches = await _riotService.GetSummonerMatches(summonerData.AccountId, queue, season, beginIndex, endIndex);
                        }
                        result.Matches.AddRange(summonerMatches.Matches);
                        result.TotalGames += summonerMatches.TotalGames;
                    }
                }
                else
                {
                    MatchesList summonerMatches = await _riotService.GetSummonerMatches(queue, summonerData.AccountId, beginIndex, endIndex);

                    result.Matches.AddRange(summonerMatches.Matches);
                    result.TotalGames += summonerMatches.TotalGames;
                }
            }
            result.Matches = new List <Match>(result.Matches.OrderByDescending(c => c.Timestamp));
            var matchesDetails = await GetMatchDetailsListAsync(result);

            await _matchDetailDao.InsertMany(matchesDetails);

            return(matchesDetails);
        }
        /// <summary>
        /// Obtiene los detalles de una lista de matches
        /// </summary>
        /// <param name="matchesList"></param>
        /// <returns></returns>
        private async Task <List <MatchDetail> > GetMatchDetailsListAsync(MatchesList matchesList)
        {
            var result = new List <MatchDetail>();

            foreach (Match match in matchesList.Matches)
            {
                result.Add(await _riotService.GetMatchDetail(match.GameId));
            }
            return(result);
        }
Esempio n. 5
0
        //deleting the selected items from checkboxlist
        //in the fouture will not delete- will save in "todelete" list
        private void buttonDeleteSelected_Click_1(object sender, EventArgs e)
        {
            Boolean degel;

            degel = true;
            //---------(new)----------------adding all items to delete into list----
            if (MatchesList.Items.Count == MatchesList.CheckedItems.Count)
            {
                //MessageBox.Show("You chose all the copys of the picture to delete,\n it means you will lose that picture completely\n ");
                const string message = "You chose all the copys of the picture to delete,\n it means you will lose that picture completely. \n\nARE YOU SURE THAT YOU WANT TO DO THESE?";
                const string caption = "Form Closing";
                var          result  = MessageBox.Show(message, caption,
                                                       MessageBoxButtons.YesNo,
                                                       MessageBoxIcon.Warning);

                // If the no button was pressed ...
                if (result == DialogResult.No)
                {
                    return;
                }
            }

            for (int i = 0; i < MatchesList.Items.Count; i++)
            {
                degel = true;
                if (MatchesList.GetItemChecked(i))
                {
                    foreach (string item in itemsToDelete)
                    {
                        if (item == MatchesList.Items[i].ToString())
                        {
                            degel = false;
                        }
                    }
                    if (degel == true)
                    {
                        itemsToDelete.Add(MatchesList.Items[i].ToString());
                    }
                }
            }
            if (degel == true)
            {
                MessageBox.Show("The files moved to a delete list, to be deleted on next step.");
            }

            //----------------------------------------------------------------------
        }
        public void TestTooMany()
        {
            var list = new MatchesList(5)
            {
                { "one", "two", null },
                { "three", "four", null }
            };
            var iterator = list.GetEnumerator();

            iterator.MoveNext().Should().BeTrue();
            iterator.Current.Should().NotBeNull();
            iterator.MoveNext().Should().BeTrue();
            iterator.Current.Should().NotBeNull();
            iterator.MoveNext().Should().BeFalse();
            var a = new Action(() => { var c = iterator.Current; });

            a.Should().Throw <IndexOutOfRangeException>();
        }
Esempio n. 7
0
        public void Update(int drainscore, int toLevelScore, int matches, int seasons, int rank)
        {
            if (toLevelScore != _lastLevel)
            {
                _lastLevel = toLevelScore;

                ToLevelScoreList.Clear();
                ToLevelScoreList = UpdateNumberList(toLevelScore.ToString().ToCharArray());
            }

            if (drainscore != _lastDrain)
            {
                _lastDrain = drainscore;

                DrainScoreList.Clear();
                DrainScoreList = UpdateNumberList(drainscore.ToString().ToCharArray());
            }

            if (seasons != _lastSeason)
            {
                _lastSeason = seasons;

                SeasonsList.Clear();
                SeasonsList = UpdateNumberList(seasons.ToString().ToCharArray());
            }

            if (matches != _lastMatches)
            {
                _lastMatches = matches;

                MatchesList.Clear();
                MatchesList = UpdateNumberList(matches.ToString().ToCharArray());
            }

            if (rank != _lastRank)
            {
                _lastRank = rank;

                RankList.Clear();
                RankList = UpdateNumberList(rank.ToString().ToCharArray());
            }
        }
Esempio n. 8
0
 private bool IsMatchs(IIncomeMessage msg)
 {
     if (msg.MsgType == "text")
     {
         return(MatchesList.Contains((msg as TextMessage).Content.ToLower()) || MatchText == WidthCast);
     }
     if (msg.GetMsgType() == MessageTypes.MenuClick)
     {
         return(MatchesList.Contains((msg as MenuClickEventMessage).EventKey.ToLower()));
     }
     if (msg.GetMsgType() == MessageTypes.QRScan)
     {
         return(MatchesList.Contains((msg as QrScanEventMessage).EventKey.ToLower()));
     }
     if (msg.MsgType == "event")
     {
         return(MatchType.Contains((msg as EventMessage).Event));
     }
     return(false);
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="accountId"></param>
        /// <param name="endIndex"></param>
        /// <param name="queue"></param>
        /// <param name="matchesDetails"></param>
        /// <param name="lastGameCreationTime"></param>
        /// <returns></returns>
        private async Task <List <MatchDetail> > GetAllSummonerMatchesAsync(string accountId, int endIndex, int queue, List <MatchDetail> matchesDetails, long lastGameCreationTime)
        {
            int beginIndex = endIndex - _maxMatchesPerRequest;

            // Obtengo las partidas de la queue
            MatchesList summonerMatches = await _riotService.GetSummonerMatches(accountId,
                                                                                queue,
                                                                                _season2020,
                                                                                lastGameCreationTime,
                                                                                beginIndex,
                                                                                endIndex);

            // Obtengo el detalle de cada partida
            var newMatchesDetails = await GetMatchDetailsListAsync(summonerMatches.Matches);

            // Si la request regresa 0 partidas hago return
            if (newMatchesDetails.Count == 0)
            {
                return(matchesDetails);
            }

            // Upsert a base de datos
            await _matchDetailDao.InsertMany(newMatchesDetails);

            // Regreso entidades en memoria
            matchesDetails.AddRange(newMatchesDetails);


            if (endIndex > summonerMatches.TotalGames)
            {
                // Si mi endIndex es mayor que la cantidad de juegos totales de la queue entonces no vuelvo a iterar
                return(matchesDetails);
            }
            else
            {
                // Si mi endIndex no es mayor que la cantidad de juegos entonces me hacen falta juegos por obtener
                return(await GetAllSummonerMatchesAsync(accountId, endIndex + _maxMatchesPerRequest, queue, matchesDetails, lastGameCreationTime));
            }
        }
Esempio n. 10
0
 public void MatchesSearch(object obj = null) => Task.Factory.StartNew(() =>
 {
     MatchesResetInput();
     if (!String.IsNullOrEmpty(MatchesSearchText))
     {
         var searchList = MatchesSearchText.Split(' ');
         if (searchList.Count() > 0)
         {
             foreach (var item in searchList)
             {
                 if (!String.IsNullOrEmpty(item))
                 {
                     var text    = item?.ToUpper()?.Trim(' ') ?? "";
                     MatchesList = MatchesList.Where(
                         x => (x.Name?.ToUpper()?.Contains(text) ?? false) ||
                         (x.GoodId?.ToUpper()?.Contains(text) ?? false) ||
                         (x.CustomerGoodId?.ToUpper()?.Contains(text) ?? false) ||
                         (x.BarCode?.ToUpper()?.Contains(text) ?? false)
                         ).ToList();
                 }
             }
         }
     }
 });