Esempio n. 1
0
 public TransactionExecutionAggregate ToDomain([CanBeNull] TransactionExecutionBlobEntity blobData)
 {
     return(TransactionExecutionAggregate.Restore(
                version: ETag,
                transactionId: TransactionId,
                address: Address,
                neoAssetId: NeoAssetId,
                gasAssetId: GasAssetId,
                neoBlockchainType: NeoBlockchainType,
                neoBlockchainAssetId: NeoBlockchainAssetId,
                gasBlockchainType: GasBlockchainType,
                gasBlockchainAssetId: GasBlockchainAssetId,
                unsignedTransactionContext: blobData?.UnsignedTransactionContext,
                claimedGas: ClaimedGas,
                allGas: AllGas,
                signedTransactionContext: blobData?.SignedTransactionContext,
                transactionHash: TransactionHash,
                broadcastingBlock: BroadcastingBlock,
                lockAcquiredAt: LockAcquiredAt,
                lockRejectedAt: LockRejectedAt,
                assetInfoRetrievedAt: AssetInfoRetrievedAt,
                transactionBuiltAt: TransactionBuiltAt,
                claimableGasNotAvailableReportedAt: ClaimableGasNotAvailableReportedAt,
                transactionSignedAt: TransactionSignedAt,
                transactionBroadcastedAt: TransactionBroadcastedAt,
                transactionExecutedAt: TransactionExecutedAt,
                transactionClearedAt: TransactionClearedAt,
                lockReleasedAt: LockReleasedAt));
 }
Esempio n. 2
0
        public Task SaveAsync(TransactionExecutionAggregate aggregate)
        {
            var blobEntity = TransactionExecutionBlobEntity.FromDomain(aggregate);

            return(Task.WhenAll
                   (
                       SaveBlobEntityAsync(aggregate.TransactionId, blobEntity),
                       _aggregateRepository.SaveAsync(aggregate)
                   ));
        }
Esempio n. 3
0
        private async Task <TransactionExecutionBlobEntity> TryGetBlobEntityAsync(
            Guid operationId)
        {
            var containerName = TransactionExecutionBlobEntity.GetContainerName();
            var blobName      = TransactionExecutionBlobEntity.GetBlobName(operationId);

            if (!await _blob.HasBlobAsync(containerName, blobName))
            {
                return(null);
            }

            using (var stream = await _blob.GetAsync(containerName, blobName))
                using (var textReader = new StreamReader(stream))
                    using (var jsonReader = new JsonTextReader(textReader))
                    {
                        stream.Position = 0;

                        return(_blobJsonSerializer.Deserialize <TransactionExecutionBlobEntity>(jsonReader));
                    }
        }
Esempio n. 4
0
        private async Task SaveBlobEntityAsync(
            Guid operationId,
            TransactionExecutionBlobEntity blobEntity)
        {
            var containerName = TransactionExecutionBlobEntity.GetContainerName();
            var blobName      = TransactionExecutionBlobEntity.GetBlobName(operationId);

            using (var stream = new MemoryStream())
                using (var textWriter = new StreamWriter(stream))
                    using (var jsonWriter = new JsonTextWriter(textWriter))
                    {
                        _blobJsonSerializer.Serialize(jsonWriter, blobEntity);

                        await jsonWriter.FlushAsync();

                        await textWriter.FlushAsync();

                        await stream.FlushAsync();

                        stream.Position = 0;

                        await _blob.SaveBlobAsync(containerName, blobName, stream);
                    }
        }