示例#1
0
        public Task <bool> SaveCharacter(
            DbAccount acc, DbChar character, DbClassStats stats, bool lockAcc)
        {
            var trans = _db.CreateTransaction();

            if (lockAcc)
            {
                trans.AddCondition(Condition.StringEqual(
                                       $"lock:{acc.AccountId}", acc.LockToken));
            }
            character.FlushAsync(trans);
            stats.Update(character);
            stats.FlushAsync(trans);
            return(trans.ExecuteAsync());
        }
示例#2
0
 public bool SaveCharacter(DbAccount acc, DbChar character, bool lockAcc)
 {
     using (var trans = CreateTransaction())
     {
         if (lockAcc)
         {
             trans.AddCondition(Condition.KeyEquals(1,
                                                    $"lock.{acc.AccountId}", acc.LockToken));
         }
         character.Flush(trans);
         var stats = new DbClassStats(acc);
         stats.Update(character);
         stats.Flush(trans);
         return(trans.Execute().Exec());
     }
 }