public void SetAndGetMessageReference()
 {
     var cloudMessage = new CloudQueueMessage("dummy");
     var queueMessage = new TestAzureQueueMessage();
     queueMessage.SetMessageReference(cloudMessage);
     Assert.AreEqual(cloudMessage, queueMessage.GetMessageReference());
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="queueName"></param>
 /// <param name="cloudQueueMessage"></param>
 /// 
 public static void DeleteMessage(string queueName, CloudQueueMessage cloudQueueMessage)
 {
     if (cloudQueueMessage != null)
     {
         DeleteMessage(queueName, cloudQueueMessage.Id, cloudQueueMessage.PopReceipt);
     }
 }
Ejemplo n.º 3
0
 static void addJob(string UUID)
 {
     CloudQueue queue = queueClient.GetQueueReference("taskqueue");
     queue.CreateIfNotExist();
     CloudQueueMessage message = new CloudQueueMessage(UUID);
     queue.AddMessage(message);
 }
Ejemplo n.º 4
0
        public void Send(string destinationQueueName, TransportMessageToSend message, ITransactionContext context)
        {
            var outputQueue = cloudQueueClient.GetQueueReference(destinationQueueName);

            using (var memoryStream = new MemoryStream())
            {
                var formatter = new BinaryFormatter();
                var receivedTransportMessage = new ReceivedTransportMessage
                    {
                        Id = Guid.NewGuid().ToString(),
                        Headers = message.Headers,
                        Body = message.Body,
                        Label = message.Label,
                    };

                formatter.Serialize(memoryStream, receivedTransportMessage);
                memoryStream.Position = 0;

                var cloudQueueMessage = new CloudQueueMessage(memoryStream.ToArray());

                var timeToLive = GetTimeToLive(message);
                if (timeToLive.HasValue)
                {
                    outputQueue.AddMessage(cloudQueueMessage, timeToLive.Value);
                }
                else
                {
                    outputQueue.AddMessage(cloudQueueMessage);
                }
            }
        }
        //
        // GET: /Subscription/
        public ActionResult Index(string From, string To, string Body)
        {
            TwilioRestClient twilio;
            SMSMessage text;

            PhoneNumberUtil phoneUtil = PhoneNumberUtil.GetInstance();
            string oldFrom = From;

            try
            {
                From = phoneUtil.Parse(Body, "US").NationalNumber.ToString();

                twilio = new TwilioRestClient("accountSid", "authToken");
                text = twilio.SendSmsMessage("+YOURTWILIONUMBER", oldFrom, "You're so thoughtful. Steve will call your friend soon!");
            }
            catch (NumberParseException e)
            {

            }

            string storageConnectionString = "DefaultEndpointsProtocol=https;AccountName=AccountName;AccountKey=ACCOUNTKEY";

            CloudStorageAccount storageAccount = CloudStorageAccount.Parse(storageConnectionString);
            CloudQueueClient queueClient = storageAccount.CreateCloudQueueClient();
            CloudQueue queue = queueClient.GetQueueReference("messages");
            queue.CreateIfNotExist();
            CloudQueueMessage message = new CloudQueueMessage(From);
            queue.AddMessage(message, new TimeSpan(1, 0, 0), new TimeSpan(0, 1, 0));

            twilio = new TwilioRestClient("accountSid", "authToken");
            text = twilio.SendSmsMessage("+YOURTWILIONUMBER", From, "Sorry you're not feeling well. You'll soon hear from Steve! If you want Steve to call a friend just send their number!");

            return View();
        }
        public override bool OnStart()
        {
            // Set the maximum number of concurrent connections
            ServicePointManager.DefaultConnectionLimit = 100;

            //Initialize Indexer
            storageAccount = CloudStorageAccount.Parse(RoleEnvironment.GetConfigurationSettingValue("CrawlerStorage"));

            //Initialize URL Queue
            urlQueueClient = storageAccount.CreateCloudQueueClient();
            urlQueue = urlQueueClient.GetQueueReference("urlqueue");
            if (urlQueue.CreateIfNotExist())
            {
                //Add first URL to the queue
                CloudQueueMessage firstURL = new CloudQueueMessage(startURL);
                urlQueue.AddMessage(firstURL);
            }

            //Initialize Index Queue
            indexQueueClient = storageAccount.CreateCloudQueueClient();
            indexQueue = indexQueueClient.GetQueueReference("indexqueue");
            indexQueue.CreateIfNotExist();

            //Initialize Database Blob
            databaseClient = storageAccount.CreateCloudBlobClient();
            databaseContainer = databaseClient.GetContainerReference("wordfrequencies");
            databaseContainer.CreateIfNotExist();
            var permission = databaseContainer.GetPermissions();
            permission.PublicAccess = BlobContainerPublicAccessType.Container;
            databaseContainer.SetPermissions(permission);

            return base.OnStart();
        }
Ejemplo n.º 7
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();
        }
Ejemplo n.º 8
0
        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( );
        }
Ejemplo n.º 9
0
 // See Figure 2 in http://msdn.microsoft.com/en-us/magazine/ee335721.aspx
 public static AzureMessage FromMessage(CloudQueueMessage message)
 {
     byte[] buffer = message.AsBytes;
     MemoryStream ms = new MemoryStream(buffer);
     ms.Position = 0;
     BinaryFormatter bf = new BinaryFormatter();
     return (AzureMessage)bf.Deserialize(ms);
 }
Ejemplo n.º 10
0
        public void AddListingSearch(int leadSearchId )
        {
            var q = GetQ("listingsearch");

            // Create a message and add it to the queue
            var qMessage = new CloudQueueMessage(leadSearchId.ToString());
            q.AddMessage(qMessage);
        }
        public void AddMessage()
        {
            SomeClass someObject = new SomeClass() { Action = "MonteCarloSimulation" };

            Byte[] message = SomeClass.ToByte(someObject);

            CloudQueueMessage cloudQueueMessage = new CloudQueueMessage(message);
            cloudQueue.AddMessage(cloudQueueMessage);
        }
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (FileUploadImage.HasFiles & Page.IsValid)
            {
                string uniqueBobName = string.Format("{0}/funnyimage_{1}{2}", Utils.CloudBlobKey,
                                                     Guid.NewGuid().ToString(),
                                                     Path.GetExtension(FileUploadImage.FileName));

                CloudBlockBlob blob = _blobClient.GetBlockBlobReference(uniqueBobName);
                blob.Properties.ContentType = FileUploadImage.PostedFile.ContentType;
                blob.UploadFromStream(FileUploadImage.FileContent);

                FunnyAppRepository<Post> postRepository = new FunnyAppRepository<Post>();
                FunnyAppRepository<Tag> tagRepository = new FunnyAppRepository<Tag>();

                MembershipUser user = Membership.GetUser(Page.User.Identity.Name);
                if (user != null)
                {
                    Post post = new Post
                        {
                            PostContent = TextBoxDescription.Text,
                            PostTitle = TextBoxTitle.Text,
                            State = false,
                            UserId = user.ProviderUserKey.ToString()
                        };

                    string[] tags = TextBoxTag.Text.Split(';');
                    foreach (string tag in tags)
                    {
                        if (!string.IsNullOrEmpty(tag))
                        {
                            tagRepository.Create(new Tag()
                                {
                                    PostRowKey = post.RowKey,
                                    PostPartitionKey = post.PartitionKey,
                                    TagName = tag,
                                });
                            tagRepository.SubmitChange();
                        }
                    }

                    postRepository.Create(post);
                    postRepository.SubmitChange();

                    CloudQueue queue = _queueClient.GetQueueReference(Utils.CloudQueueKey);
                    CloudQueueMessage message =
                        new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri, post.PartitionKey, post.RowKey));
                    queue.AddMessage(message);

                    LabelResult.Text = "Uploaded";
                }
                else
                {
                    LabelResult.Text = "Failed";
                }
            }
        }
Ejemplo n.º 13
0
        public void PutQueueMessage(MessageType type, Dictionary<string, long> data)
        {
            System.IO.MemoryStream stream = new System.IO.MemoryStream(1024 * 64);
            _formatter.Serialize(stream, data);

            data.Add("Type", (long)type);

            CloudQueueMessage message = new CloudQueueMessage(stream.ToArray());
            queue.AddMessage(message);
        }
        public void AddMessages()
        {
            String content1 = "Do something";
            CloudQueueMessage message1 = new CloudQueueMessage(content1);
            cloudQueue.AddMessage(message1);

            String content2 = "Do something else";
            CloudQueueMessage message2 = new CloudQueueMessage(content2);
            cloudQueue.AddMessage(message2, TimeSpan.FromDays(1.0));
        }
Ejemplo n.º 15
0
 public void Enqueue(ItemBase item)
 {
     CloudQueueMessage message;
     using(var stream = new MemoryStream()){
         new BinaryFormatter().Serialize(stream, item);
         stream.Flush();
         message = new CloudQueueMessage(stream.ToArray());
     }
     GetQueue().AddMessage(message);
 }
        public void Push(string queueName, string data)
        {
            // Create the queue client
            CloudQueueClient queueClient = this.GetAccount().CreateCloudQueueClient();

            // Retrieve a reference to a queue
            CloudQueue queue = queueClient.GetQueueReference(queueName);
            var message = new CloudQueueMessage(data);
            queue.AddMessage(message);
        }
Ejemplo n.º 17
0
 public void Send(object command)
 {
     var formatter = new BinaryFormatter();
     using (var s = new MemoryStream())
     {
         formatter.Serialize(s, command);
         var msg = new CloudQueueMessage(s.ToArray());
         this.queue.AddMessage(msg);
     }
 }
Ejemplo n.º 18
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="queueName"></param>
 /// <param name="messageText"></param>
 /// <param name="createQueue"></param>
 /// 
 public static void AddMessage(string queueName, string messageText, bool createQueue = true)
 {
     var cloudQueue = GetCloudQueue(queueName);
     var cloudQueueMessage = new CloudQueueMessage(messageText);
     if (createQueue)
     {
         cloudQueue.CreateIfNotExist();
     }
     cloudQueue.AddMessage(cloudQueueMessage);
 }
        public BackoffExample(String queueName)
        {
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["DataConnectionString"]);
            CloudQueueClient cloudQueueClient = cloudStorageAccount.CreateCloudQueueClient();
            cloudQueue = cloudQueueClient.GetQueueReference(queueName);
            cloudQueue.CreateIfNotExist();

            CloudQueueMessage cloudQueueMessage = new CloudQueueMessage("Some message");
            cloudQueue.AddMessage(cloudQueueMessage);
        }
 public void SetupRecipe()
 {
     cloudQueue.CreateIfNotExist();
     for (Int32 i = 0; i < 100; i++)
     {
         String content = String.Format("Message_{0}", i);
         CloudQueueMessage message = new CloudQueueMessage(content);
         cloudQueue.AddMessage(message);
     }
 }
        public void UpdateQueueMessageShouldCallIUpdateableAzureQueueUpdateMessage()
        {
            var updateableQueue = new Mock<IUpdateableAzureQueue>();
            var cloudMessage = new CloudQueueMessage("dummy");
            var queueMessage = new TestAzureQueueMessage();
            queueMessage.SetMessageReference(cloudMessage);
            queueMessage.SetUpdateableQueueReference(updateableQueue.Object);
            queueMessage.UpdateQueueMessage();

            updateableQueue.Verify(q => q.UpdateMessage(queueMessage), Times.Once());
        }
Ejemplo n.º 22
0
 public static QueueEnvelope GetFromDefaultQueue(out CloudQueueMessage message)
 {
     message = CurrDefaultQueue.GetMessage(TimeSpan.FromMinutes(5));
     if (message == null)
         return null;
     try
     {
         QueueEnvelope queueEnvelope = QueueEnvelope.DeserializeFromXml(message.AsString);
         return queueEnvelope;
     } catch
     {
         return null;
     }
 }
Ejemplo n.º 23
0
 public static SystemError GetFromErrorQueue(out CloudQueueMessage message)
 {
     message = CurrErrorQueue.GetMessage();
     if (message == null)
         return null;
     try
     {
         SystemError error = SystemError.DeserializeFromXml(message.AsString);
         return error;
     } catch
     {
         return null;
     }
 }
Ejemplo n.º 24
0
 public void SolicitarGeracao(Guid processamentoId, int primeiro, int ultimo)
 {
     Trace.WriteLine(string.Format("Solicitando geração dos contratos {0} a {1}.", primeiro, ultimo));
     dynamic mensagem = new
                            {
                                Comando = "GerarContratos",
                                ProcessamentoId = processamentoId,
                                Primeiro = primeiro,
                                Ultimo = ultimo
                            };
     var message = new CloudQueueMessage(JsonConvert.SerializeObject(mensagem));
     CloudQueue cloudQueue = FilaDeMensagens.GetCloudQueue();
     cloudQueue.AddMessage(message);
 }
Ejemplo n.º 25
0
 private static SystemError GetErrorFromMessage(CloudQueueMessage message)
 {
     SystemError error = new SystemError
                             {
                                 ErrorTitle = "Cloud Message: " + message.Id,
                                 OccurredAt = DateTime.UtcNow,
                                 SystemErrorItems = new SystemErrorItemCollection()
                             };
     error.SystemErrorItems.CollectionContent.Add(new SystemErrorItem()
                                                      {
                                                          ShortDescription = "Message content",
                                                          LongDescription = message.AsString
                                                      });
     return error;
 }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            // initialize the account information
            var storageAccount = CloudStorageAccount.FromConfigurationSetting("DataConnectionString");

            // retrieve a reference to the messages queue
            var queueClient = storageAccount.CreateCloudQueueClient();
            var queue = queueClient.GetQueueReference("messagequeue");
            queue.CreateIfNotExist();

            // add the message to the queue
            var msg = new CloudQueueMessage(this.txtMessage.Text);
            queue.AddMessage(msg);
            this.txtMessage.Text = string.Empty;
        }
Ejemplo n.º 27
0
 public void Log(string message)
 {
     try
     {
         writeLog(message);
         Console.WriteLine("Log:" + message);
         var queue = GetQueue(QUEUE_NAME);
         CloudQueueMessage cloudMessage = new CloudQueueMessage(message);
         queue.AddMessage(cloudMessage);
     }
     catch (Exception ex)
     {
         Trace.WriteLine("from logger: " + ex.Message, "Error");
     }
 }
Ejemplo n.º 28
0
        protected void ButtonSave_Click(object sender, EventArgs e)
        {
            if (VideoUpload.HasFiles & Page.IsValid)
            {
                ChannelPerformingRepository<Media> mediaRepository = new ChannelPerformingRepository<Media>();
                ChannelPerformingRepository<Tag> tagRepository = new ChannelPerformingRepository<Tag>();

                string uniqueBobName = string.Format("{0}/ShowVideo_{1}{2}", Utils.CloudBlobKey, Guid.NewGuid().ToString(), Path.GetExtension(VideoUpload.FileName));
                CloudBlockBlob blob = blobClient.GetBlockBlobReference(uniqueBobName);
                blob.Properties.ContentType = VideoUpload.PostedFile.ContentType;
                blob.UploadFromStream(VideoUpload.FileContent);

                Media media = new Media
                {
                    Description = TextBoxVideoDescription.Text,
                    Title = TextBoxVideoName.Text
                };

                string[] tagArray = TextBoxTags.Text.Split(';');
                foreach (string t in tagArray)
                {
                    if (!string.IsNullOrEmpty(t))
                    {
                        Tag tag = new Tag
                        {
                            TagName = t,
                            MediaPartitionKey = media.PartitionKey,
                            MediaRowKey = media.RowKey,
                            RecordDate = DateTime.Now
                        };

                        tagRepository.Create(tag);
                        tagRepository.SubmitChange();
                    }
                }

                media.MediaProgressStateType = Utils.MediaProgressStateTypeWait;
                mediaRepository.Create(media);
                mediaRepository.SubmitChange();

                CloudQueue queue = queueClient.GetQueueReference(Utils.CloudQueueKey);
                CloudQueueMessage message = new CloudQueueMessage(string.Format("{0},{1},{2}", blob.Uri, media.PartitionKey, media.RowKey));
                queue.AddMessage(message);

                LabelResult.Text = "Video Uploaded";
                Response.Redirect("/Manager/VideoProgressListPage.aspx");
            }
        }
Ejemplo n.º 29
0
        static void Main(string[] args)
        {
            var account = CloudStorageAccount.Parse("DefaultEndpointsProtocol=https;AccountName=prdc;AccountKey=6mEliBWPnykttQyZsLS9JJIY4xYNWMXLt3AFsH7FIRnkxLjAPkXQk2kvM/uiQnSidRUvY7DdA2OnW8AFRh0scA==");

            var queueClient = account.CreateCloudQueueClient();
            var queue = queueClient.GetQueueReference("prdc");
            queue.CreateIfNotExist();

            int i = 0;
            while (true)
            {
                var message = new CloudQueueMessage("I am message number " + i++);
                queue.AddMessage(message);
                Console.ReadLine();
            }
        }
 public void SolicitarFaturamento(Guid processamentoId, int ano, int mes, int primeiro, int ultimo)
 {
     Trace.WriteLine(string.Format("Solicitando faturamento para {0}/{1} dos contratos {2} a {3}.", mes, ano,
                                   primeiro, ultimo));
     dynamic mensagem = new
                            {
                                Comando = "Faturar",
                                ProcessamentoId = processamentoId,
                                Ano = ano,
                                Mes = mes,
                                Primeiro = primeiro,
                                Ultimo = ultimo
                            };
     var message = new CloudQueueMessage(JsonConvert.SerializeObject(mensagem));
     CloudQueue cloudQueue = FilaDeMensagens.GetCloudQueue();
     cloudQueue.AddMessage(message);
 }