protected void SignButton_Click( object sender, EventArgs e ) { if ( FileUpload1.HasFile ) { InitializeStorage( ); //Subo la imagen al Blob Storage CloudBlobContainer container = blobStorage.GetContainerReference( "fotogolpics" ); string uniqueBlobName = string.Format( "image_{0}.jpg", Guid.NewGuid( ).ToString( ) ); CloudBlockBlob blob = container.GetBlockBlobReference( uniqueBlobName ); blob.Properties.ContentType = FileUpload1.PostedFile.ContentType; blob.UploadFromStream( FileUpload1.FileContent ); System.Diagnostics.Trace.TraceInformation( "Uploaded image '{0}' to blob storage as '{1}'", FileUpload1.FileName, uniqueBlobName ); //Creo un nuevo registro en la tabla FotoGolEntry entry = new FotoGolEntry( ) { GuestName = NameTextBox.Text, Message = MessageTextBox.Text, PhotoUrl = blob.Uri.ToString( ), ThumbnailUrl = blob.Uri.ToString( ) }; FotoGolEntryDataSource ds = new FotoGolEntryDataSource( ); ds.AddGuestBookEntry( entry ); System.Diagnostics.Trace.TraceInformation( "Added entry {0}-{1} in table storage for guest '{2}'", entry.PartitionKey, entry.RowKey, entry.GuestName ); //Pongo un mensaje en cola para que se procese var queue = queueStorage.GetQueueReference( "fotogolthumbs" ); var message = new CloudQueueMessage( String.Format( "{0},{1},{2}", uniqueBlobName, entry.PartitionKey, entry.RowKey ) ); queue.AddMessage( message ); System.Diagnostics.Trace.TraceInformation( "Queued message to process blob '{0}'", uniqueBlobName ); } NameTextBox.Text = ""; MessageTextBox.Text = ""; DataList1.DataBind( ); }
public override void Run() { Trace.WriteLine("FotoGol_Email entry point called", "Information"); InitializeStorage(); while (true) { Thread.Sleep(10000); Trace.WriteLine("Working", "Information"); var list = MailGetter.GetPhotoData(true); foreach (var item in list) { //Subo la imagen al Blob Storage CloudBlobContainer container = blobStorage.GetContainerReference("fotogolpics"); string uniqueBlobName = string.Format("image_{0}.jpg", Guid.NewGuid().ToString()); CloudBlockBlob blob = container.GetBlockBlobReference(uniqueBlobName); //blob.Properties.ContentType = item.ImageType; blob.UploadFromStream(new MemoryStream(item.Data)); System.Diagnostics.Trace.TraceInformation("Uploaded image '{0}' to blob storage as '{1}'", item.FileName, uniqueBlobName); //Creo un registro en la tabla FotoGolEntry entry = new FotoGolEntry() { GuestName = item.From, Message = item.Title, PhotoUrl = blob.Uri.ToString(), ThumbnailUrl = blob.Uri.ToString() }; FotoGolEntryDataSource ds = new FotoGolEntryDataSource(); ds.AddGuestBookEntry(entry); System.Diagnostics.Trace.TraceInformation("Added entry {0}-{1} in table storage for guest '{2}'", entry.PartitionKey, entry.RowKey, entry.GuestName); //Pongo un mensaje para procesar var queue = queueStorage.GetQueueReference("fotogolthumbs"); var message = new CloudQueueMessage(String.Format("{0},{1},{2}", uniqueBlobName, entry.PartitionKey, entry.RowKey)); queue.AddMessage(message); System.Diagnostics.Trace.TraceInformation("Queued message to process blob '{0}'", uniqueBlobName); } } }