public TweetTableEntity(Tweet tweet, bool flipId)
        {
            PartitionKey = TweetPartitionKey;
            RowKey = flipId ? string.Format("{0:d19}", long.MaxValue - tweet.Id) : string.Format("{0:d19}", tweet.Id);

            TweetJson = JsonConvert.SerializeObject(tweet);
        }
Ejemplo n.º 2
0
 private void UploadTweetToTable(Tweet tweet)
 {
     var insertOperation = TableOperation.InsertOrReplace(new TweetTableEntity(tweet, false));
     _tweetsTable.Execute(insertOperation);
     Trace.TraceInformation("Successfully uploaded tweet to tablestorage");
 }
Ejemplo n.º 3
0
        private async Task UploadTweetToBlobAsync(Tweet tweet)
        {
            CloudBlockBlob tweetBlob = _blobContainer.GetBlockBlobReference(tweet.IdString);
            using (var ms = new MemoryStream())
            {
                var writer = new StreamWriter(ms);
                writer.Write(JsonConvert.SerializeObject(tweet));
                writer.Flush();
                ms.Position = 0;

                await tweetBlob.UploadFromStreamAsync(ms);
            }
        }