예제 #1
0
        private static bool GetOlderMatchesPerPlayer(long steamID64)
        {
            Dota2DataMiner.Class1 d2Dm = new Dota2DataMiner.Class1();

            PlayersList playersList = new PlayersList();
            int matchID = 0;
            // Make sure there is older matches to find.
            if (playersList.LastMatchFound(steamID64, out matchID))
                return false;

            // Check for and Recover Local Data.
            d2Dm.GetMatchPerPlayerLocalData(steamID64, matchID);

            // Check if System Config permits this method call.
            SystemConfig systemConfig = new SystemConfig();
            systemConfig.GetByKey("GetOlderMatchesPerPlayer");

            if (systemConfig.RecordExists)
            {
                if (DateTime.Now < Convert.ToDateTime(systemConfig.SCValue).AddSeconds(1))
                    return true;
            }
            else
            {
                systemConfig.SCKey = "GetOlderMatchesPerPlayer";
            }

            // Get or Create SteamRequest
            SteamRequests steamRequests;
            GetSteamRequest(out steamRequests);

            // Check if API can be used else return
            if (DateTime.Now < steamRequests.LastUpdated.AddSeconds(1))
                return true;

            // Increment the Steam Request Counter
            Console.WriteLine("Steam request number : " + steamRequests.RequestNumber + " - Get Older Matches Per Player");
            steamRequests.RequestNumber++;
            steamRequests.LastUpdated = DateTime.Now;
            steamRequests.InsertOrUpdate();

            Players player = new Players();

            // Get Live Data.
            try
            {
                if (!d2Dm.GetMatchPerPlayer(steamID64, matchID, "GetOlderMatchesPerPlayer", systemConfig))
                {
                    if (!QuiteMode)
                        Console.WriteLine("Oldest Player match found.");

                    player.GetBySteamID64(steamID64);
                    player.OldestMatchFound = true;
                    player.Update();
                }

                systemConfig.SCValue = DateTime.Now.ToString();
                systemConfig.InsertOrUpdate();
            }
            catch (Exception)
            {
                steamRequests.RequestNumber--;
                steamRequests.InsertOrUpdate();
            }

            if (player.RecordExists && player.OldestMatchFound)
                return false;
            else
                return true;
        }
예제 #2
0
        private bool GetPlayers(XmlDocument response, PlayersList players)
        {
            bool newPlayersAdded = false;

            foreach (XmlNode subRootNode in response.DocumentElement.ChildNodes)
            {
                if (subRootNode.Name == "players")
                {
                    foreach (XmlNode playerNode in subRootNode)
                    {
                        Players player = new Players();
                        if (playerNode["steamid"] != null)
                        {
                            player =
                                players.Find(
                                    x =>
                                    x.SteamID ==
                                    Convert.ToInt32(Convert.ToInt64(playerNode["steamid"].InnerText) - 76561197960265728));
                            if (!player.RecordExists)
                            {
                                player = new Players();
                                players.Add(player);
                            }
                        }
                        else
                        {
                            player = new Players();
                            players.Add(player);
                        }

                        if (playerNode["steamid"] != null)
                            player.SteamID64 = Convert.ToInt64(playerNode["steamid"].InnerText);
                        if (playerNode["communityvisibilitystate"] != null)
                            player.CommunityVisibilityState = Convert.ToInt32(playerNode["communityvisibilitystate"].InnerText);
                        if (playerNode["profilestate"] != null)
                            player.ProfileState = Convert.ToInt32(playerNode["profilestate"].InnerText);
                        if (playerNode["personaname"] != null)
                            player.PersonaName = playerNode["personaname"].InnerText;
                        if (playerNode["lastlogoff"] != null)
                            player.LastLogOff = UnixTimeStampToDateTime(Convert.ToDouble(playerNode["lastlogoff"].InnerText));
                        if (playerNode["profileurl"] != null)
                            player.ProfileURL = playerNode["profileurl"].InnerText;
                        if (playerNode["avatar"] != null)
                            player.Avatar = playerNode["avatar"].InnerText;
                        if (playerNode["avatarmedium"] != null)
                            player.AvatarMedium = playerNode["avatarmedium"].InnerText;
                        if (playerNode["avatarfull"] != null)
                            player.AvatarFull = playerNode["avatarfull"].InnerText;
                        if (playerNode["personastate"] != null)
                            player.PersonaState = Convert.ToInt32(playerNode["personastate"].InnerText);
                        if (playerNode["realname"] != null)
                            player.RealName = playerNode["realname"].InnerText;

                        if (playerNode["primaryclanid"] != null)
                            player.PrimaryClanID = Convert.ToInt64(playerNode["primaryclanid"].InnerText);
                        if (playerNode["timecreated"] != null)
                            player.TimeCreated = UnixTimeStampToDateTime(Convert.ToDouble(playerNode["timecreated"].InnerText));
                        if (playerNode["loccountrycode"] != null)
                            player.LocCountyCode = playerNode["loccountrycode"].InnerText;
                        if (playerNode["locstatecode"] != null)
                            player.LocStateCode = playerNode["locstatecode"].InnerText;
                        if (playerNode["loccityid"] != null)
                            player.LocCityID = playerNode["loccityid"].InnerText;

                        if (!QuiteMode)
                            Console.WriteLine("Steam ID: " + player.SteamID + " Name: " + player.PersonaName + " Real Name: " + (player.RealName ?? ""));

                        newPlayersAdded = true;
                    }
                }
            }

            players.ForEach(x => x.LastUpdated = DateTime.Now);
            players.UpdateAll();

            if (File.Exists("PlayerSummaryInfo" + players[0].SteamID + "(" +
                                                DateTime.Now.ToString("ddMMyyyy") + ").xml"))
            {
                File.Delete("PlayerSummaryInfo" + players[0].SteamID + "(" +
                            DateTime.Now.ToString("ddMMyyyy") + ").xml");
            }

            return newPlayersAdded;
        }
예제 #3
0
        private bool GetMatchs(XmlDocument response, long steamId64, int recordMatchID)
        {
            bool lastMatch = false;
            bool newPlayersAdded = false;

            foreach (XmlNode subRootNode in response.DocumentElement.ChildNodes)
            {
                if (subRootNode.Name == "status" && subRootNode.InnerText == "15")
                {

                    Players player = new Players();
                    player.GetBySteamID64(steamId64);

                    if (player.RecordExists)
                    {
                        if (!QuiteMode)
                            Console.WriteLine(player.PersonaName + " likes his/her privacy.");
                        player.IsPrivate = true;
                        // Not really updating the player, more of testing his private. *snicker*
                        //player.LastUpdated = DateTime.Now;
                        player.InsertOrUpdate();
                    }
                    else
                    {
                        if (!QuiteMode)
                            Console.WriteLine("ID: " + steamId64 + " likes his/her privacy.");
                    }
                    return true;
                }

                if (subRootNode.Name == "results_remaining" && subRootNode.InnerText == "0")
                    lastMatch = true;

                if (subRootNode.Name == "matches")
                {
                    foreach (XmlNode matchNode in subRootNode)
                    {
                        Matches matches = new Matches();
                        if (matchNode["match_id"] != null)
                        {
                            int matchID = Convert.ToInt32(matchNode["match_id"].InnerText);
                            matches.LoadItem(matchID);
                            if (!matches.RecordExists)
                            {
                                matches = new Matches();
                            }
                        }
                        else
                        {
                            matches = new Matches();
                        }

                        if (matchNode["match_id"] != null)
                            matches.ID = Convert.ToInt32(matchNode["match_id"].InnerText);

                        if (matchNode["match_seq_num"] != null)
                            matches.SequenceNumber = Convert.ToInt32(matchNode["match_seq_num"].InnerText);

                        if (matchNode["start_time"] != null)
                            matches.StartTime = UnixTimeStampToDateTime(Convert.ToDouble(matchNode["start_time"].InnerText));

                        if (matchNode["lobby_type"] != null)
                            matches.LobbyType = Convert.ToInt32(matchNode["lobby_type"].InnerText);

                        matches.InsertOrUpdate();
                        if (!QuiteMode)
                            Console.WriteLine("Match Found: " + matches.ID + "; Sequence Number: " + matches.SequenceNumber + "; Start Time: " + matches.StartTime.ToString());

                        if (matchNode["players"] != null)
                        {
                            MatchPlayerList matchPlayerList = new MatchPlayerList();
                            foreach (XmlNode playerNode in matchNode["players"])
                            {
                                MatchPlayer matchPlayer = new MatchPlayer();

                                if (playerNode["account_id"] == null)
                                {
                                    //BOT
                                    matchPlayer.GetByMatchSlot(matches.ID, Convert.ToInt32(playerNode["player_slot"].InnerText));

                                    if (!matchPlayer.RecordExists)
                                    {
                                        matchPlayer.Match = matches.ID;
                                        matchPlayer.Player = -1;
                                        matchPlayer.Player64 = -1;
                                        matchPlayer.Slot = Convert.ToInt32(playerNode["player_slot"].InnerText);
                                        matchPlayer.Hero = Convert.ToInt32(playerNode["hero_id"].InnerText);
                                        matchPlayerList.Add(matchPlayer);

                                        if (!QuiteMode)
                                            Console.WriteLine("Player: " + matchPlayer.Player64 + "; Playing hero: " +
                                                              matchPlayer.Hero);
                                    }
                                }
                                else
                                {
                                    matchPlayer.GetByMatchPlayer64(matches.ID,
                                                                   Convert.ToInt64(playerNode["account_id"].InnerText));

                                    if (!matchPlayer.RecordExists)
                                    {
                                        matchPlayer.Match = matches.ID;
                                        matchPlayer.Player64 = Convert.ToInt64(playerNode["account_id"].InnerText);
                                        matchPlayer.Slot = Convert.ToInt32(playerNode["player_slot"].InnerText);
                                        matchPlayer.Hero = Convert.ToInt32(playerNode["hero_id"].InnerText);
                                        matchPlayerList.Add(matchPlayer);

                                        if (!QuiteMode)
                                            Console.WriteLine("Player: " + matchPlayer.Player64 + "; Playing hero: " +
                                                              matchPlayer.Hero);

                                        //Players player = new Players();
                                        //player.GetBySteamID64((long)matchPlayer.Player64);

                                        //if (!player.RecordExists)
                                        //{
                                        //    Console.WriteLine("; NOT FOUND!");
                                        //    // Shit shit the player doesn't exist and I've already used this seconds request!
                                        //    // Make a plan!
                                        //}
                                        //Console.WriteLine("");
                                    }
                                }
                            }
                            matchPlayerList.UpdateAll();
                        }

                        newPlayersAdded = true;
                    }
                }
            }

            if (lastMatch)
            {
                Players playersLastMatch = new Players();
                playersLastMatch.GetBySteamID64(steamId64);
                playersLastMatch.OldestMatchFound = true;
                playersLastMatch.InsertOrUpdate();
            }

            if (File.Exists("GetMatchPerPlayer" + steamId64.ToString() + (recordMatchID != 0 ? recordMatchID.ToString() : "") + "(" +
                              DateTime.Now.ToString("ddMMyyyy") + ").xml"))
            {
                File.Delete("GetMatchPerPlayer" + steamId64.ToString() + (recordMatchID != 0 ? recordMatchID.ToString() : "") + "(" +
                              DateTime.Now.ToString("ddMMyyyy") + ").xml");
            }

            return newPlayersAdded;
        }
예제 #4
0
        private void addPlayer(PlayersList players, TeamPlayersList teamPlayersList, int teamID, XmlNode teamNode, string playerAccountId)
        {
            Players player = new Players();
            if (teamNode[playerAccountId] != null)
            {
                int steamID = Convert.ToInt32(teamNode[playerAccountId].InnerText);

                if (players.Find(x => x.SteamID == steamID) == null)
                {
                    player.LoadItem(steamID);

                    player.SteamID = steamID;
                    //player.TeamID = teamID;

                    players.Add(player);

                    TeamPlayers teamPlayers = new TeamPlayers();
                    teamPlayers.GetByTeamPlayer(teamID, steamID);

                    teamPlayers.Team = teamID;
                    teamPlayers.Player = steamID;
                    teamPlayers.InsertOrUpdate();

                    if (!QuiteMode)
                        Console.WriteLine("Player ID:" + player.SteamID);
                }

                TeamPlayers teamPlayer = teamPlayersList.Find(x => x.Player == steamID);
                if (teamPlayer != null)
                    teamPlayersList.Remove(teamPlayer);
            }
        }