コード例 #1
0
ファイル: Highscores.cs プロジェクト: PRSears/RS_Tracker
        /// <summary>
        /// Creates a new Player object with data pulled from the Highscores website
        /// </summary>
        /// <param name="Username">Username of the player to search for.</param>
        /// <returns>Player object built from Highscores website. Returns null if download failed.</returns>
        public static Player Update(string Username)
        {
            Player fetchedPlayer = new Player(Username);

            if (Highscores.Update(fetchedPlayer))
            {
                return(fetchedPlayer);
            }
            else
            {
                return(null);
            }
        }
コード例 #2
0
ファイル: Highscores.cs プロジェクト: PRSears/RS_Tracker
        public static bool Update(Player player)
        {
            int  UpdateInterval = Properties.Settings.Default.MinUpdateInterval;
            bool outcome        = true;

            Data.DatabaseInterface db = new Data.DatabaseInterface();
            List <Skill>           skills;

            bool DatabaseOutofDate = DateTime.Now.Subtract(db.LastUpdate(player)).TotalMinutes >= UpdateInterval;

            if (DatabaseOutofDate)
            {
                skills = parseHighscores(player.Username);
            }
            else
            {
                skills = db.GetSkillList(player.UserID);
            }

            if (skills == null)
            {
                outcome &= false;
            }
            else
            {
                player.UpdateCurrentSkills(skills);
            }

            if (DatabaseOutofDate)
            {
                db.AddPlayer(player);
            }

            outcome &= Highscores.PurgeLocalFile(player.Username); // delete the local copy of the file now that we're finished with it

            return(outcome);
        }