private void InsertGameBetBatchAsync()
        {
            IGameBetItem[] bBuffer;
            lock (this)
            {
                bBuffer = new IGameBetItem[_gameBetCache.Count];
                _gameBetCache.CopyTo(bBuffer);
                _gameBetCache.Clear();
            }
            Thread t = new Thread(new ParameterizedThreadStart(InsertGameBetBatchTSig));

            t.Start(bBuffer);
        }
示例#2
0
 public static GameBetEntity CreateEntity(IGameBetItem src)
 {
     return(new GameBetEntity
     {
         PartitionKey = GetPartitionKey(src.UserId, DateTime.UtcNow),
         RowKey = GetRowKey(src.BoxId, src.Date),
         UserId = src.UserId,
         BoxId = src.BoxId,
         AssetPair = src.AssetPair,
         BetAmount = src.BetAmount,
         Box = src.Box,
         Date = src.Date,
         Parameters = src.Parameters,
         BetStatus = src.BetStatus
     });
 }
        public Task SaveGameBet(IGameBetItem bet)
        {
            if (bet == null)
            {
                return(Task.FromResult(0));
            }

            var existingBet = _gameBetCache.Where(b => b.BoxId == bet.BoxId).FirstOrDefault();

            if (existingBet != null)
            {
                _gameBetCache.Remove(existingBet);
            }

            _gameBetCache.Add(bet);
            if (_gameBetCache.Count > _maxBuffer)
            {
                InsertGameBetBatchAsync();
            }

            return(Task.FromResult(0));
        }
示例#4
0
 public Task SaveGameBet(IGameBetItem bet)
 {
     throw new NotImplementedException();
 }