Exemplo n.º 1
0
        public async Task WriteBlockDataAsync(IBlockNinja blockData)
        {
            var key   = Guid.NewGuid().ToString();
            var bytes = blockData.ToJson().ToUtf8ByteArray();
            await _azureBlob.SaveBlobAsync(BlobContainer, key, bytes);

            await _tableStorage.InsertOrReplaceAsync(BlockNinjaEntity.Create(blockData.Hash, key));
        }
Exemplo n.º 2
0
        public async Task <IBlockNinja> GetBlockDataAsync(string blockId)
        {
            var rowKey       = BlockNinjaEntity.GenerateRowKey(blockId);
            var partiteonKey = BlockNinjaEntity.GeneratePartiteonKey();
            var block        = await _tableStorage.GetDataAsync(partiteonKey, rowKey);

            if (block == null)
            {
                return(null);
            }
            var blobBlockData = await _azureBlob.GetAsync(BlobContainer, block.BlobId);

            var jsonStr = Encoding.UTF8.GetString(blobBlockData.ToBytes());

            return(JsonConvert.DeserializeObject <DeserializeBlockNinja>(jsonStr));
        }