コード例 #1
0
        public void GenerateRankings()
        {
            foreach (var path in TeamPaths)
            {
                _driver.Navigate().GoToUrl(path);
                _driver.FindElement(By.XPath("//div[@id='playerTableHeader']/ul/li[4]")).Click();
                var postDraftRankings = new List <PostDraftRanking>();

                Thread.Sleep(1000);


                var playerElements = _driver.FindElements(By.XPath("//tr[contains(@class, 'pncPlayerRow')]"));

                foreach (var playerElement in playerElements)
                {
                    var position = playerElement.FindElement(By.XPath("./td[1]")).Text;
                    var teamNameElementString = _driver.FindElement(By.XPath("//h3[@class='team-name']")).Text.Trim();
                    var teamName = teamNameElementString.Substring(0, teamNameElementString.IndexOf(" ("));

                    if (position != "IR")
                    {
                        var postDraftRanking = new PostDraftRanking();
                        postDraftRanking.TeamName = teamName;

                        if (playerElement.FindElements(By.XPath("./td[@class='playertablePlayerName']")).Count > 0)
                        {
                            postDraftRanking.PlayerPosition = position;
                            postDraftRanking.PlayerName     = playerElement.FindElement(By.XPath("./td[@class='playertablePlayerName']")).Text;

                            var projectedPoints = playerElement.FindElement(By.XPath("./td[contains(@class, 'appliedPoints')][1]")).Text;

                            var isDefense = postDraftRanking.PlayerName.Contains("D/ST");
                            postDraftRanking.Projection = isDefense ? 1600m : decimal.Parse(projectedPoints);

                            postDraftRankings.Add(postDraftRanking);
                        }
                    }
                }

                new PrintPostDraftRankingsService(postDraftRankings).WritePostDraftRankingsFile();
            }
        }
コード例 #2
0
 private void PrintLine(StreamWriter file, PostDraftRanking ranking)
 {
     file.WriteLine(ranking.PlayerName);
     file.WriteLine($"{ranking.Projection}\t\t{ranking.WeeklyProjection}\t\t\t");
     file.WriteLine();
 }