public static void AddAuction(Common.Auction auction) { lock (Auctions) Auctions.Add(auction); CharMgr.Database.AddObject(auction); }
public static void CheckAuctionExpiry(object arg) { int removeCount = 0; long expireTimeStart = TCPManager.GetTimeStamp() - (60 * 60 * 24 * 30); lock (Auctions) { for (int i = 0; i < Auctions.Count; ++i) { if (Auctions[i].StartTime >= expireTimeStart) { continue; } Common.Auction auction = Auctions[i]; if (auction.Item == null) { auction.Item = ItemService.GetItem_Info(auction.ItemId); } if (auction.Item != null) { // return item to lister Character_mail expireMail = new Character_mail { Guid = CharMgr.GenerateMailGuid(), CharacterId = auction.SellerId, ReceiverName = auction.Seller.Name, SendDate = (uint)TCPManager.GetTimeStamp(), AuctionType = 3, Content = auction.Item.Name, Money = 0, Opened = false }; expireMail.Items.Add(new MailItem(auction.ItemId, auction._Talismans, auction.PrimaryDye, auction.SecondaryDye, auction.Count)); CharMgr.AddMail(expireMail); } CharMgr.Database.DeleteObject(auction); Auctions.RemoveAt(i); ++removeCount; --i; } Log.Info("Auction House", $"Removed {removeCount} expired {(removeCount == 1 ? "auction": "auctions")}."); } }
public Auction() { InitializeComponent(); Globals.playerInfo.money = 1000; mainScreen = this; }
private void button_Save(object sender, EventArgs e) { //Gem auktion try { if (AuctionNameTextBox.Text.Length == 0) { MessageBox.Show("Giv auktionen et navn!"); throw new Exception(); } if (AuctionMultipler.Value < 1) { MessageBox.Show("Angiv en multiplier!"); throw new Exception(); } if (AuctionTimePerArtPiece.Value < 1) { MessageBox.Show("Angiv en tid pr kunstværk!"); throw new Exception(); } bool found = false; int count = 0; while (!found && count < ArtPieces.Count) { if (ArtPieces[count].Checked == true) { found = true; } count ++; } if (found != true) { MessageBox.Show("Vælg kunst!"); throw new Exception(); } TimeSpan ts = new TimeSpan(0, Int32.Parse(AuctionTimePerArtPiece.Value.ToString()), 0); List<ArtPiece> selectedArtPieces = (from artpiece in ArtPieces where artpiece.Checked == true select (artpiece)).ToList(); int count1 = 0; List<Lot> lots = new List<Lot>(); foreach (var artpiece in selectedArtPieces) { Lot l = new Lot() { Position = count1, MinBid = artpiece.PurchasePrice/2, ArtPiece = artpiece, }; lots.Add(l); count1 ++; } Auction a = new Auction() { AuctionName = AuctionNameTextBox.Text, LotDuration = ts, Multiplier = Int32.Parse(AuctionMultipler.Value.ToString()), Lots = lots, Status = Status.Ready, }; try { _auctionClient.AddAuction(a); MessageBox.Show("Auktionen blev oprettet!"); this.Close(); } catch (Exception ex) { ex.DebugGetLine(); MessageBox.Show("Der opstod en fejl, prøv igen!"); } } catch (Exception ex) { ex.DebugGetLine(); } }