public async Task <AsyncTaskResult> HandleAsync(TransferInPreparationConfirmedEvent evnt) { var task1 = _commandService.SendAsync(new CommitTransactionPreparationCommand(evnt.TransactionInfo.SourceAccountId, evnt.AggregateRootId) { Id = evnt.Id, Items = evnt.Items }); var task2 = _commandService.SendAsync(new CommitTransactionPreparationCommand(evnt.TransactionInfo.TargetAccountId, evnt.AggregateRootId) { Id = evnt.Id, Items = evnt.Items }); var totalResult = await Task.WhenAll(task1, task2).ConfigureAwait(false); var failedResults = totalResult.Where(x => x.Status == AsyncTaskStatus.Failed); if (failedResults.Count() > 0) { return(new AsyncTaskResult(AsyncTaskStatus.Failed, string.Join("|", failedResults.Select(x => x.ErrorMessage)))); } var ioExceptionResults = totalResult.Where(x => x.Status == AsyncTaskStatus.IOException); if (ioExceptionResults.Count() > 0) { return(new AsyncTaskResult(AsyncTaskStatus.IOException, string.Join("|", ioExceptionResults.Select(x => x.ErrorMessage)))); } return(AsyncTaskResult.Success); }
private void Handle(TransferInPreparationConfirmedEvent @event) { this.State.TransferInPreparationConfirmed = true; this.State.TransferInPreparationConfirmedAt = @event.UTCTimestamp; if (this.State.TransferOutPreparationConfirmed) { this.State.Status = TransactionStatus.PreparationCompleted; } }
public async Task HandleAsync(TransferInPreparationConfirmedEvent evnt) { var task1 = _commandService.SendAsync(new CommitTransactionPreparationCommand(evnt.TransactionInfo.SourceAccountId, evnt.AggregateRootId) { Id = evnt.Id, Items = evnt.Items }); var task2 = _commandService.SendAsync(new CommitTransactionPreparationCommand(evnt.TransactionInfo.TargetAccountId, evnt.AggregateRootId) { Id = evnt.Id, Items = evnt.Items }); await Task.WhenAll(task1, task2).ConfigureAwait(false); }
public Task <AsyncTaskResult> HandleAsync(TransferInPreparationConfirmedEvent evnt) { Console.WriteLine("预转入确认成功,交易ID:{0},账户:{1}", evnt.AggregateRootId, evnt.TransactionInfo.TargetAccountId); return(Task.FromResult(AsyncTaskResult.Success)); }
public Task HandleAsync(TransferInPreparationConfirmedEvent evnt) { _logger.InfoFormat("预转入确认成功,交易ID:{0},账户:{1}", evnt.AggregateRootId, evnt.TransactionInfo.TargetAccountId); return(Task.CompletedTask); }