Exemplo n.º 1
0
        public void AddGuestBookEntry(GuestBookEntry newItem)
        {
            TableOperation operation = TableOperation.Insert(newItem);
            CloudTable     table     = context.ServiceClient.GetTableReference("GuestBookEntry");

            table.Execute(operation);
        }
Exemplo n.º 2
0
        protected void SignButton_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.HasFile)
            {
                this.InitializeStorage();

                // upload the image to blob storage
                string uniqueBlobName = string.Format("guestbookpics/image_{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(this.FileUpload1.FileName));
                CloudBlockBlob blob = blobStorage.GetBlockBlobReference(uniqueBlobName);
                blob.Properties.ContentType = this.FileUpload1.PostedFile.ContentType;
                blob.UploadFromStream(this.FileUpload1.FileContent);
                System.Diagnostics.Trace.TraceInformation("Uploaded image '{0}' to blob storage as '{1}'", this.FileUpload1.FileName, uniqueBlobName);

                // create a new entry in table storage
                GuestBookEntry entry = new GuestBookEntry() { GuestName = this.NameTextBox.Text, Message = this.MessageTextBox.Text, PhotoUrl = blob.Uri.ToString(), ThumbnailUrl = blob.Uri.ToString() };
                GuestBookDataSource ds = new GuestBookDataSource();
                ds.AddGuestBookEntry(entry);
                System.Diagnostics.Trace.TraceInformation("Added entry {0}-{1} in table storage for guest '{2}'", entry.PartitionKey, entry.RowKey, entry.GuestName);

                // queue a message to process the image
                var queue = queueStorage.GetQueueReference("guestthumbs");
                var message = new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri.ToString(), entry.PartitionKey, entry.RowKey));
                queue.AddMessage(message);
                System.Diagnostics.Trace.TraceInformation("Queued message to process blob '{0}'", uniqueBlobName);

            }

            this.NameTextBox.Text = string.Empty;
            this.MessageTextBox.Text = string.Empty;

            this.DataList1.DataBind();
        }
Exemplo n.º 3
0
        protected void SignButton_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.HasFile)
            {
                this.InitializeStorage();

                // upload the image to blob storage
                string uniqueBlobName = string.Format("guestbookpics/image_{0}{1}", Guid.NewGuid().ToString(), Path.GetExtension(this.FileUpload1.FileName));
                string blobUri = _storage.AddToBucket("guestbookpics1", uniqueBlobName, this.FileUpload1.FileContent);
                System.Diagnostics.Trace.TraceInformation("Uploaded image '{0}' to blob storage as '{1}'", this.FileUpload1.FileName, uniqueBlobName);

                // create a new entry in table storage
                var entry = new GuestBookEntry() { GuestName = this.NameTextBox.Text, Message = this.MessageTextBox.Text, PhotoUrl = blobUri, ThumbnailUrl = blobUri };
                var ds = new GuestBookDataSource();
                ds.AddGuestBookEntry(entry);
                System.Diagnostics.Trace.TraceInformation("Added entry {0} in table storage for guest '{1}'", entry.Id, entry.GuestName);

                // queue a message to process the image
                var queue = _queue.GetQueueById("guestthumbs");
                var message = string.Format("{0},{1}", blobUri, entry.Id);
                _queue.SendMessage(queue, message);
                System.Diagnostics.Trace.TraceInformation("Queued message to process blob '{0}'", uniqueBlobName);
            }

            this.NameTextBox.Text = string.Empty;
            this.MessageTextBox.Text = string.Empty;

            this.DataList1.DataBind();
        }
Exemplo n.º 4
0
        public void AddGuestBookEntry(GuestBookEntry newItem)
        {
            var item = JObject.FromObject(newItem);
            var properties = new Dictionary<string, string>();

            foreach (var property in item.Properties())
            {
                if (property.Name != "Id")
                {
                    var val = property.Value;
                    properties.Add(property.Name, val.ToString());
                }
            }

            _storage.Put("GuestBookEntry1", newItem.Id, properties);
        }
Exemplo n.º 5
0
        public void UpdateImageThumbnail(string partitionKey, string rowKey, string thumbUrl)
        {
            CloudTable     table             = context.ServiceClient.GetTableReference("GuestBookEntry");
            TableOperation retrieveOperation = TableOperation.Retrieve <GuestBookEntry>(partitionKey, rowKey);

            TableResult    retrievedResult = table.Execute(retrieveOperation);
            GuestBookEntry updateEntity    = (GuestBookEntry)retrievedResult.Result;

            if (updateEntity != null)
            {
                updateEntity.ThumbnailUrl = thumbUrl;

                TableOperation replaceOperation = TableOperation.Replace(updateEntity);
                table.Execute(replaceOperation);
            }
        }
Exemplo n.º 6
0
        public IEnumerable<GuestBookEntry> GetGuestBookEntries()
        {
            /*
            var results = from g in this.context.GuestBookEntry
                          where g.PartitionKey == DateTime.UtcNow.ToString("MMddyyyy")
                          select g;
            return results;
            */
            /*
            return from bag in _storage.GetAll("GuestBookEntry1")
                   select new GuestBookEntry()
                              {
                                  Id = bag["Id"].ToString(),
                                  GuestName = bag["GuestName"].ToString(),
                                  Message = bag["Message"].ToString()
                              };
            */
            var entriesG = _storage.GetAll("GuestBookEntry1").ToList();

            /*
            var entries = from bag in entriesG
                          select new GuestBookEntry
                                     {
                                         Id = bag["Id"].ToString(),
                                         GuestName = bag["GuestName"].ToString(),
                                         Message = bag["Message"].ToString()
                                     };
            var result = entries.ToList();
            */
            var result = new List<GuestBookEntry>();

            foreach (var bag in entriesG)
            {
                var r = new GuestBookEntry
                {
                    Id = bag["RowKey"].ToString(),
                    GuestName = bag["GuestName"].ToString(),
                    Message = bag["Message"].ToString(),
                    Timestamp = bag["Timestamp"].ToString()
                };

                result.Add(r);
            }

            return result;
        }
 public void AddGuestBookEntry(GuestBookEntry newItem)
 {
     TableOperation operation = TableOperation.Insert(newItem);
     context.GuestBookTable.Execute(operation);
 }
Exemplo n.º 8
0
 public void AddGuestBookEntry(GuestBookEntry newItem)
 {
     this.context.AddObject("GuestBookEntry", newItem);
     this.context.SaveChanges();
 }
Exemplo n.º 9
0
 public void AddGuestBookEntry(GuestBookEntry newItem)
 {
     this.context.AddObject("GuestBookEntry", newItem);
     this.context.SaveChanges();
 }
Exemplo n.º 10
0
 public void AddGuestBookEntry(GuestBookEntry newItem)
 {
   TableOperation operation = TableOperation.Insert(newItem);
   CloudTable table = context.ServiceClient.GetTableReference("GuestBookEntry");
   table.Execute(operation);
 }
 private static void createNewEntryInCloudTableStorage(string name, string message, string uploadedFileBlobUri,
                                                       out string newEntryPartitionKey, out string newEntryRowKey)
 {
     var newGuestBookEntry = new GuestBookEntry
         {
             GuestName = name,
             Comment = message,
             PhotoUrl = uploadedFileBlobUri,
             ThumbnailUrl = uploadedFileBlobUri
         };
     var guestBookDataSource = new GuestBookDataSource();
     guestBookDataSource.AddGuestBookEntry(newGuestBookEntry);
     newEntryPartitionKey = newGuestBookEntry.PartitionKey;
     newEntryRowKey = newGuestBookEntry.RowKey;
     Trace.TraceInformation("Added entry {0}-{1} in table storage for guest '{2}'", newEntryPartitionKey,
                            newEntryRowKey, newGuestBookEntry.GuestName);
 }