public JsonResult QueuePhotoRender(ComicEffectType effect, string photoSource, int intensity) { // Generate render task PhotoTask task = new PhotoTask(); task.TaskId = Guid.NewGuid(); task.Status = TaskStatus.Queued; task.Effect = effect; task.Intensity = intensity; task.FacebookToken = this.Facebook.AccessToken; task.SourceUrl = photoSource; task.OwnerUid = this.ActiveUser.Uid; // Queue the task up using Azure Queue services. Store full task information using Blob storage. Only the task id is queued. // This is done because we need public visibility on render tasks before, during and after the task completes. // Save task to storage CloudBlobContainer container = this.BlobClient.GetContainerReference(ComicConfigSectionGroup.Blob.TaskContainer); CloudBlobDirectory directory = container.GetDirectoryReference(ComicConfigSectionGroup.Blob.PhotoTaskDirectory); CloudBlob blob = directory.GetBlobReference(task.TaskId.ToString()); blob.UploadText(task.ToXml()); // Queue up task CloudQueue queue = this.QueueClient.GetQueueReference(ComicConfigSectionGroup.Queue.PhotoTaskQueue); CloudQueueMessage message = new CloudQueueMessage(task.TaskId.ToString()); queue.AddMessage(message, TimeSpan.FromMinutes(5)); return(this.Json(new ClientPhotoTask(task, null), JsonRequestBehavior.DenyGet)); }
private void UpdateTask(PhotoTask task) { try { CloudBlobContainer container = this.BlobClient.GetContainerReference(ComicConfigSectionGroup.Blob.TaskContainer); CloudBlobDirectory directory = container.GetDirectoryReference(ComicConfigSectionGroup.Blob.PhotoTaskDirectory); CloudBlob progressBlob = directory.GetBlobReference(task.TaskId.ToString()); progressBlob.UploadText(task.ToXml()); } catch (Exception x) { this.Log.Error("Unable to update render progress", x); } }