コード例 #1
0
        public void LoadAuctions()
        {
            uint oldMSTime = Time.GetMSTime();

            // Clear in case we are reloading
            _auctions.Clear();

            PreparedStatement stmt   = DB.Characters.GetPreparedStatement(CharStatements.SEL_BLACKMARKET_AUCTIONS);
            SQLResult         result = DB.Characters.Query(stmt);

            if (result.IsEmpty())
            {
                Log.outInfo(LogFilter.ServerLoading, "Loaded 0 black market auctions. DB table `blackmarket_auctions` is empty.");
                return;
            }

            _lastUpdate = Time.UnixTime; //Set update time before loading

            SQLTransaction trans = new SQLTransaction();

            do
            {
                BlackMarketEntry auction = new BlackMarketEntry();

                if (!auction.LoadFromDB(result.GetFields()))
                {
                    auction.DeleteFromDB(trans);
                    continue;
                }

                if (auction.IsCompleted())
                {
                    auction.DeleteFromDB(trans);
                    continue;
                }

                AddAuction(auction);
            } while (result.NextRow());

            DB.Characters.CommitTransaction(trans);

            Log.outInfo(LogFilter.ServerLoading, "Loaded {0} black market auctions in {1} ms.", _auctions.Count, Time.GetMSTimeDiffToNow(oldMSTime));
        }