Esempio n. 1
0
    private void Search(string searchText)
    {
        int current = Convert.ToInt32(HiddenFieldCurrentPage.Value) - 1;
        int total = Convert.ToInt32(HiddenFieldTotalPages.Value);

        TeamsList teamsList = new TeamsList();
        if (TextBoxSearchBox.Text == "")
            teamsList.GetAll(current == 0 ? 0 : ((current * itemsPerPage) + 1), current == 0 ? itemsPerPage : itemsPerPage - 1);
        else
            teamsList.GetByLikeName(TextBoxSearchBox.Text, current == 0 ? 0 : ((current * itemsPerPage) + 1), current == 0 ? itemsPerPage : itemsPerPage - 1);

        // If exact match found, move to the top of the list.
        DotaDbGenLib.Business.Teams team = teamsList.Find(x => x.TeamName == TextBoxSearchBox.Text);
        if (team != null)
        {
            teamsList.Remove(team);
            teamsList.Insert(0, team);
        }

        ListViewPlayers.DataSource = teamsList;
        ListViewPlayers.DataBind();
    }
Esempio n. 2
0
        public bool GetTeams(XmlDocument response, int? teamID)
        {
            TeamsList teamsList = new TeamsList();

            if (teamID != null)
            {
                Teams tempTeams = new Teams((int)teamID);
                if (!tempTeams.RecordExists)
                {
                    teamsList.Add(new Teams() { ID = Convert.ToInt32(teamID), TeamName = "UNKNOWN" });
                }
                else
                {
                    teamsList.Add(tempTeams);
                }
            }

            bool newTeamsAdded = false;
            PlayersList players = new PlayersList();

            foreach (XmlNode subRootNode in response.DocumentElement.ChildNodes)
            {
                if (subRootNode.Name == "teams")
                {
                    foreach (XmlNode teamNode in subRootNode)
                    {
                        Teams team = new Teams();
                        if (teamNode["team_id"] != null)
                        {
                            team.LoadItem(Convert.ToInt32(teamNode["team_id"].InnerText));
                            if (!team.RecordExists)
                            {
                                team = new Teams();
                            }
                        }
                        else
                        {
                            team = new Teams();
                        }

                        if (teamNode["team_id"] != null)
                            team.ID = Convert.ToInt32(teamNode["team_id"].InnerText);

                        if (team.ID == teamID)
                        {
                            Teams tempTeams = teamsList.Find(x => x.ID == teamID);
                            if (tempTeams != null)
                            {
                                teamsList.Remove(tempTeams);
                            }
                        }

                        if (teamNode["name"] != null)
                            team.TeamName = teamNode["name"].InnerText;
                        if (teamNode["tag"] != null)
                            team.Tag = teamNode["tag"].InnerText;
                        if (teamNode["time_created"] != null)
                            team.TimeCreated = teamNode["time_created"].InnerText;
                        if (teamNode["rating"] != null)
                            team.Rating = teamNode["rating"].InnerText;
                        if (teamNode["logo"] != null)
                            team.Logo = teamNode["logo"].InnerText;
                        if (teamNode["logo_sponsor"] != null)
                            team.LogoSponsor = teamNode["logo_sponsor"].InnerText;
                        if (teamNode["country_code"] != null)
                            team.CountryCode = teamNode["country_code"].InnerText;
                        if (teamNode["url"] != null)
                            team.URL = teamNode["url"].InnerText;
                        if (teamNode["games_played_with_current_roster"] != null)
                            team.GamesPlayed = Convert.ToInt32(teamNode["games_played_with_current_roster"].InnerText);
                        if (teamNode["admin_account_id"] != null)
                            team.AdminAccount = Convert.ToInt32(teamNode["admin_account_id"].InnerText);

                        team.LastUpdated = DateTime.Now;

                        if (!QuiteMode)
                            Console.WriteLine("Team ID: " + team.ID + " Name: " + team.TeamName);

                        if (!team.RecordExists)
                        {
                            newTeamsAdded = true;
                        }

                        team.InsertOrUpdate();

                        TeamPlayersList teamPlayers = new TeamPlayersList();
                        teamPlayers.GetByTeam(team.ID);

                        //Players
                        addPlayer(players, teamPlayers, team.ID, teamNode, "player_0_account_id");
                        addPlayer(players, teamPlayers, team.ID, teamNode, "player_1_account_id");
                        addPlayer(players, teamPlayers, team.ID, teamNode, "player_2_account_id");
                        addPlayer(players, teamPlayers, team.ID, teamNode, "player_3_account_id");
                        addPlayer(players, teamPlayers, team.ID, teamNode, "player_4_account_id");

                        // Reserves
                        addPlayer(players, teamPlayers, team.ID, teamNode, "player_5_account_id");
                        addPlayer(players, teamPlayers, team.ID, teamNode, "player_6_account_id");
                        addPlayer(players, teamPlayers, team.ID, teamNode, "player_7_account_id");

                        players.UpdateAll();
                        //leagues;

                        team = null;
                        players.Clear();

                        teamPlayers.ForEach(x => x.Delete());
                    }
                }
            }

            if (teamsList.Count > 0)
            {
                teamsList.ForEach(x => x.LastUpdated = DateTime.Now);
                teamsList.UpdateAll();
            }

            if (File.Exists("GetTeamInfo" + (teamID != null ? teamID.ToString() : "") + "(" +
                                                DateTime.Now.ToString("ddMMyyyy") + ").xml"))
            {
                File.Delete("GetTeamInfo" + (teamID != null ? teamID.ToString() : "") + "(" +
                            DateTime.Now.ToString("ddMMyyyy") + ").xml");
            }

            return newTeamsAdded;
        }