Beispiel #1
0
 public SearchResultClan GetDetailClan()
 {
     using (var client = new CRClient(_uriBaseUrl, _credentials))
     {
         var clans = client.SearchClans(Clan.Name);
         return(clans.Items.FirstOrDefault(p => p.Tag == Clan.Tag));
     }
 }
Beispiel #2
0
        public List <SearchResultClan> GetClansRank(int startTrophes, int?locationId)
        {
            var result = new List <SearchResultClan>();

            try
            {
                using (var client = new CRClient(_uriBaseUrl, _credentials))
                {
                    var dico    = new Dictionary <string, SearchResultClan>();
                    var wait    = 2;
                    var waitEnd = wait;

                    while (waitEnd > 0)
                    {
                        if (DemandStopping)
                        {
                            break;
                        }
                        var clans = client.SearchClans(locationId: locationId, minScore: startTrophes);
                        foreach (var clanfind in clans.Items)
                        {
                            if (!dico.ContainsKey(clanfind.Tag))
                            {
                                dico.Add(clanfind.Tag, clanfind);
                            }
                        }
                        waitEnd       = clans.Items.Count < MaxItems ? waitEnd - 1 : wait;
                        startTrophes += 50;
                    }
                    result = dico.Select(p => p.Value).OrderByDescending(p => p.ClanScore).ToList();
                }
            }
            catch (Exception ex)
            {
                Logger?.Error(ex);
            }
            finally
            {
                DemandStopping = false;
            }
            return(result);
        }