public async Task <Stream> GetTransactionsReport(string assetId)
        {
            var transactionIds  = _assetTransactionsService.GetTransactionsForAsset(assetId);
            var assetDictionary = _assetDefinitionService.GetAssetDefinitionsAsync();

            await Task.WhenAll(transactionIds, assetDictionary);

            var txResps = await _transactionService.GetTransactions(transactionIds.Result.Select(p => p.TransactionId));

            var xlsxData = XlsxTransactionsReportData.Create(
                txResps,
                assetDictionary.Result,
                _network);

            return(await _transactionXlsxRenderer.RenderTransactionReport(xlsxData));
        }
Exemple #2
0
        public async Task <Stream> GetTransactionsReport(string addressId)
        {
            var assetDefinitionDictionary = _assetDefinitionService.GetAssetDefinitionsAsync();
            var addressTransactionIds     = Retry.Try(() => GetAddressTransactions(addressId).WithTimeout(60 * 1000),
                                                      component: nameof(GetAddressTransactions),
                                                      tryCount: 10,
                                                      secondsToWaitOnFail: 5,
                                                      logger: _log);

            await Task.WhenAll(assetDefinitionDictionary, addressTransactionIds);

            var txResps = await _transactionService.GetTransactions(addressTransactionIds.Result);

            var xlsxData = XlsxTransactionsReportData.Create(
                txResps,
                assetDefinitionDictionary.Result,
                _network);

            return(await _transactionXlsxRenderer.RenderTransactionReport(xlsxData));
        }
        public async Task<CommandResult> CreateReport([FromBody]AssetTransactionsReportsRequest input)
        {
            if (!ModelState.IsValid)
            {
                return CommandResultBuilder.Fail(ModelState.GetErrorsList().ToArray());
            }

            var assetDefinitions = await _assetDefinitionService.GetAssetDefinitionsAsync();

            if (!assetDefinitions.ContainsKey(input.Asset))
            {
                return CommandResultBuilder.Fail("Asset not found");
            }

            var asset = assetDefinitions[input.Asset];
            var assetId = asset.AssetIds.First();

            await _reportMetadataRepository.InsertOrReplace(ReportMetadata.Create(assetId, queuedAt: DateTime.UtcNow));
            await _commandProducer.CreateCommand(assetId, input.Email);
            
            return CommandResultBuilder.Ok();
        }
        public async Task <Stream> GetTransactionsReport(string blockId)
        {
            var getBlock = _blockService.GetBlock(BlockFeature.Parse(blockId));
            var getAssetDefDictionary = _assetDefinitionService.GetAssetDefinitionsAsync();

            await Task.WhenAll(getBlock, getAssetDefDictionary);

            if (getBlock.Result == null)
            {
                throw new Exception($"Block {blockId} not found");
            }

            var transactionIds = getBlock.Result.Block.Transactions.Select(p => p.GetHash());

            var txResps = await _transactionService.GetTransactions(transactionIds);

            var xlsxData = XlsxTransactionsReportData.Create(
                txResps,
                getAssetDefDictionary.Result,
                _network);

            return(await _transactionXlsxRenderer.RenderTransactionReport(xlsxData));
        }