public void Serializable() { var minter = new Address(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, }); var account = new Address(new byte[] { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, }); var currency = new Currency("PLT", 0, minter); var exc = new InsufficientBalanceException( account, FungibleAssetValue.FromRawValue(currency, 99), "for testing" ); var formatter = new BinaryFormatter(); using (var ms = new MemoryStream()) { formatter.Serialize(ms, exc); ms.Seek(0, SeekOrigin.Begin); var deserialized = (InsufficientBalanceException)formatter.Deserialize(ms); Assert.Equal("for testing", deserialized.Message); Assert.Equal(account, deserialized.Address); Assert.Equal(FungibleAssetValue.FromRawValue(currency, 99), deserialized.Balance); } }
public async Task HandleAsync(InsufficientBalanceException exception) { if (exception.TransactionType == TransactionType.TransferTransaction) { await _commandService.SendAsync(new CancelTransferTransactionCommand(exception.TransactionId) { Id = exception.Id, Items = exception.Items }); } }
public Task <AsyncTaskResult> HandleAsync(InsufficientBalanceException exception) { if (exception.TransactionType == TransactionType.TransferTransaction) { return(_commandService.SendAsync(new CancelTransferTransactionCommand(exception.TransactionId))); } return(Task.FromResult(AsyncTaskResult.Success)); }
public Task <AsyncTaskResult> HandleAsync(InsufficientBalanceException exception) { Console.WriteLine("账户的余额不足,交易ID:{0},账户:{1},可用余额:{2},转出金额:{3}", exception.TransactionId, exception.AccountId, exception.CurrentAvailableBalance, exception.Amount); return(Task.FromResult(AsyncTaskResult.Success)); }
public Task HandleAsync(InsufficientBalanceException exception) { _logger.InfoFormat("账户的余额不足,交易ID:{0},账户:{1},可用余额:{2},转出金额:{3}", exception.TransactionId, exception.AccountId, exception.CurrentAvailableBalance, exception.Amount); return(Task.CompletedTask); }