/// <summary> /// Return current banner that should be displayed, NULL otherwise /// </summary> /// <param name="type"></param> /// <param name="position">if you want to get different position than 1st banner (e.g. you have multiple banner controls)</param> /// <returns></returns> public static BannerAdvert GetCurrentBanner(BannerAdvertDimensions dimensions, int position = 1) { using (var bridge = ParserPool.Acquire(Database.Client)) { var currentSql = bridge.Instance.ExecuteRawCommandToDataTable(BannerAuctionSQLManager.GetCurrentSQL(dimensions)); var currentList = TableHelper.GetListFromDataTable <BannerAuction>(currentSql, 1); if (currentList.Count > 0) { BannerAuction auction = currentList[0]; BannerBid bid = auction.GetHighestBid(position); if (bid != null) { if (!bid.RefAndPoolsCredited) { BannerCrediter crediter = new BannerCrediter(new Member(bid.Username)); Money moneyLeftForPools = crediter.CreditReferer(bid.BidValue); PoolDistributionManager.AddProfit(ProfitSource.Banners, moneyLeftForPools); bid.RefAndPoolsCredited = true; bid.Save(); } return(new BannerAdvert(bid.BannerAdvertId)); } } return(null); } }
public static BannerAuction GetFirstActiveAuction(BannerAdvertDimensions dimensions) { using (var bridge = ParserPool.Acquire(Database.Client)) { var currentSql = bridge.Instance.ExecuteRawCommandToDataTable(BannerAuctionSQLManager.GetFirstActiveAuctionSQL(dimensions)); var currentList = TableHelper.GetListFromDataTable <BannerAuction>(currentSql, 1); if (currentList.Count > 0) { return(currentList[0]); } else { BannerAuctionManager.CRON(); //No auctions created yet, do it return(null); } } }
public static void CRON() { BannerAuctionSQLManager.ExecuteCRONSQL(); }