Esempio n. 1
0
 public async Task RefreshLine(string ric)
 {
     if (listBkp != null)
     {
         var listFiltered = listBkp.Where(x => x.Atleta.Contains(ric.ToUpper())).ToList().OrderBy(x => x.PosizioneClassifica);
         ListAtleti.ReplaceRange(listFiltered);
     }
 }
Esempio n. 2
0
        async Task TransalteHtmlString(string html)
        {
            IsBusy = true;
            //var load = Acr.UserDialogs.UserDialogs.Instance.Loading("RicercaTitle");
            //await Task.Delay(100);
            await Task.Run(() =>
            {
                using (TextReader sr = new StringReader(html))
                {
                    HtmlDocument doc = new HtmlDocument();
                    doc.Load(sr);
                    var someNode = (from node in doc.DocumentNode.Descendants() where node.Name == "tr" select(node));

                    foreach (var node in someNode)
                    {
                        if (node.InnerHtml.Contains("RiRank.asp?"))
                        {
                            var stringArray = node.InnerHtml.Split(new string[] { "</td>" }, StringSplitOptions.RemoveEmptyEntries);

                            if (stringArray.Count() == 13)
                            {
                                if (listMatches == null)
                                {
                                    listMatches = new List <string>();
                                }
                                listMatches.Clear();

                                for (int x = 0; x < 13; x++)
                                {
                                    var testString = stringArray[x].Replace("\n", String.Empty).Replace("\t", String.Empty).Replace("\r", String.Empty);

                                    foreach (Match match in regexSimple.Matches(testString))
                                    {
                                        var regexValue    = match.Groups[1].Value;
                                        var replacedValue = regexValue.Replace('<', ' ').Replace('>', ' ').Trim();
                                        if (!String.IsNullOrEmpty(replacedValue))
                                        {
                                            System.Diagnostics.Debug.WriteLine(replacedValue);
                                            listMatches.Add(replacedValue);
                                            if (listMatches.Count() == 7)
                                            {
                                                ListAtleti.Add(new RankingDataModel()
                                                {
                                                    PosizioneClassifica = Convert.ToInt16(listMatches[0]),
                                                    Atleta      = listMatches[1],
                                                    AnnoNascita = Convert.ToInt16(listMatches[0]),
                                                    Categoria   = listMatches[3],
                                                    Societa     = listMatches[4],
                                                    ValueRank   = listMatches[5],
                                                    CodSquadra  = Convert.ToInt16(listMatches[6])
                                                });
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                    listBkp = ListAtleti.ToList();
                }

                //load.Dispose();
                IsBusy = false;
            });
        }