예제 #1
0
        private async Task SaveBlobEntityAsync(
            Guid operationId,
            string blockchainType,
            TransactionExecutionBlobEntity blobEntity)
        {
            var containerName = TransactionExecutionBlobEntity.GetContainerName(blockchainType);
            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);
                    }
        }
예제 #2
0
        private async Task <TransactionExecutionBlobEntity> TryGetBlobEntityAsync(
            Guid operationId,
            string blockchainType)
        {
            var containerName = TransactionExecutionBlobEntity.GetContainerName(blockchainType);
            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));
                    }
        }