コード例 #1
0
        private async Task ProcessHotWalletCashout(ProcessHotWalletErc20EventCommand queueMessage)
        {
            string             transactionId = queueMessage.OperationId;
            CashOutContextData context       = await _transactionService.GetTransactionContext <CashOutContextData>(transactionId);

            if (context == null)
            {
                _log.Error(new NullReferenceException("Context is null for hotwallet cashout"),
                           context: queueMessage.ToJson());

                return;
            }

            string clientId        = context.ClientId;
            string hash            = queueMessage.TransactionHash;
            string cashOperationId = context.CashOperationId;

            var clientAcc = await _clientAccountClient.GetByIdAsync(clientId);

            var clientEmail = await _personalDataService.GetEmailAsync(clientId);

            await _cashOperationsRepositoryClient.UpdateBlockchainHashAsync(clientId, cashOperationId, hash);

            await _srvEmailsFacade.SendNoRefundOCashOutMail(clientAcc.PartnerId, clientEmail, context.Amount, context.AssetId, hash);
        }
コード例 #2
0
        public async Task <CommandHandlingResult> Handle(ProcessHotWalletErc20EventCommand command, IEventPublisher eventPublisher)
        {
            try
            {
                switch (command.EventType)
                {
                case HotWalletEventType.CashinCompleted:
                    await ProcessHotWalletCashin(command, eventPublisher);

                    break;

                case HotWalletEventType.CashoutCompleted:
                    await ProcessHotWalletCashout(command);

                    break;

                default:
                    throw new ArgumentOutOfRangeException($"{command.EventType} - is not supported for processing {command.ToJson()}. ");
                }

                return(CommandHandlingResult.Ok());
            }
            catch (Exception e)
            {
                _log.Error(nameof(ProcessHotWalletErc20EventCommand), e, context: command);
                throw;
            }
        }
        public async Task <CommandHandlingResult> Handle(ProcessHotWalletErc20EventCommand command, IEventPublisher eventPublisher)
        {
            var sw = new Stopwatch();

            sw.Start();

            try
            {
                switch (command.EventType)
                {
                case HotWalletEventType.CashinCompleted:
                    await ProcessHotWalletCashin(command, eventPublisher);

                    break;

                case HotWalletEventType.CashoutCompleted:
                    await ProcessHotWalletCashout(command);

                    break;

                default:
                    throw new ArgumentOutOfRangeException(
                              $"{command.EventType} - is not supported for processing {command.ToJson()}. ");
                }

                return(CommandHandlingResult.Ok());
            }
            catch (Exception e)
            {
                _log.Error(nameof(ProcessHotWalletErc20EventCommand), e, context: command);
                throw;
            }
            finally
            {
                sw.Stop();
                _log.Info("Command execution time",
                          context: new { TxHandler = new { Handler = nameof(EthereumCoreCommandHandler), Command = nameof(ProcessHotWalletErc20EventCommand),
                                                           Time    = sw.ElapsedMilliseconds } });
            }
        }