Exemple #1
0
        private async Task delete(RecordQueueItem item)
        {
            if (await Application.Current.MainPage.DisplayAlert("Delete Recording", "Are you sure you want to delete the selected video?", "Yes", "No"))
            {
                try
                {
                    var response = await QueueClient.Delete(item.ID);

                    if ((response != null) && response.Success)
                    {
                        Items.Remove(item);
                        OnPropertyChanged(nameof(ItemsCount));

                        if (item.Equals(SelectedItem))
                        {
                            SelectedItem = null;
                        }

                        await accountViewModel.FetchUserCreditsAsync();

                        await Application.Current.MainPage.DisplayAlert("Recording Deleted", "The video has been successfully deleted.", "OK");
                    }
                    else if (response != null)
                    {
                        await Application.Current.MainPage.DisplayAlert("Delete Recording", response.ErrorMessageClean, "OK");
                    }
                }
                catch (Exception ex)
                {
                    //XXX : Handle error
                    LoggerService.Instance.Log("ERROR: Queue.delete: " + ex);
                }
            }
        }
Exemple #2
0
        public void Errors()
        {
            // Get a connection string to our Azure Storage account
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));

            queue.Create();

            try
            {
                // Try to create the queue again
                queue.Create();
            }
            catch (StorageRequestFailedException ex)
                when(ex.ErrorCode == QueueErrorCode.QueueAlreadyExists)
                {
                    // Ignore any errors if the queue already exists
                }
            catch (StorageRequestFailedException ex)
            {
                Assert.Fail($"Unexpected error: {ex}");
            }

            // Clean up after the test when we're finished
            queue.Delete();
        }
Exemple #3
0
        public void Enqueue()
        {
            // Get a connection string to our Azure Storage account.  You can
            // obtain your connection string from the Azure Portal (click
            // Access Keys under Settings in the Portal Storage account blade)
            // or using the Azure CLI with:
            //
            //     az storage account show-connection-string --name <account_name> --resource-group <resource_group>
            //
            // And you can provide the connection string to your application
            // using an environment variable.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));

            queue.Create();
            try
            {
                // Add a message to our queue
                queue.EnqueueMessage("Hello, Azure!");

                // Verify we uploaded one message
                Assert.AreEqual(1, queue.PeekMessages(10).Value.Count());
            }
            finally
            {
                // Clean up after the test when we're finished
                queue.Delete();
            }
        }
        public void DeleteQueue(string queueName)
        {
            QueueClient queueClient = CreateQueueClient(queueName);

            if (queueClient.Exists())
            {
                queueClient.Delete();
            }

            Console.WriteLine($"Queue deleted: '{queueClient.Name}'");
        }
Exemple #5
0
        /// <summary>
        /// delete Queue from Azure Storage account.
        /// </summary>
        /// <returns></returns>
        public static string DeleteQueue()
        {
            QueueClient queueClient = new QueueClient(queue_connection_string, queue_name);
            string      msg         = string.Empty;

            if (queueClient.Exists())
            {
                queueClient.Delete();
            }
            return("Queue delete successfully");
        }
        public void Sample01a_HelloWorld_Errors()
        {
            string      queueName = Randomize("sample-queue");
            QueueClient queue     = new QueueClient(ConnectionString, queueName);

            try
            {
                queue.Create();
                Sample01a_HelloWorld.Errors(ConnectionString, queueName);
            }
            finally
            {
                queue.Delete();
            }
        }
Exemple #7
0
        public void DequeueAndUpdate()
        {
            // Get a connection string to our Azure Storage account.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));

            queue.Create();
            try
            {
                // Add several messages to the queue
                queue.EnqueueMessage("first");
                queue.EnqueueMessage("second");
                queue.EnqueueMessage("third");

                // Get the messages from the queue with a short visibility timeout
                List <DequeuedMessage> messages = new List <DequeuedMessage>();
                foreach (DequeuedMessage message in queue.DequeueMessages(10, TimeSpan.FromSeconds(1)).Value)
                {
                    // Tell the service we need a little more time to process the message
                    UpdatedMessage changedMessage = queue.UpdateMessage(
                        message.MessageText,
                        message.MessageId,
                        message.PopReceipt,
                        TimeSpan.FromSeconds(5));
                    messages.Add(message.Update(changedMessage));
                }

                // Wait until the visibility window times out
                Thread.Sleep(TimeSpan.FromSeconds(1.5));

                // Ensure the messages aren't visible yet
                Assert.AreEqual(0, queue.DequeueMessages(10).Value.Count());

                // Finish processing the messages
                foreach (DequeuedMessage message in messages)
                {
                    // Tell the service we need a little more time to process the message
                    queue.DeleteMessage(message.MessageId, message.PopReceipt);
                }
            }
            finally
            {
                // Clean up after the test when we're finished
                queue.Delete();
            }
        }
Exemple #8
0
        // </snippet_DequeueMessages>

        // <snippet_DeleteQueue>
        //-------------------------------------------------
        // Delete the queue
        //-------------------------------------------------
        public void DeleteQueue(string queueName)
        {
            // Get the connection string from app settings
            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];

            // Instantiate a QueueClient which will be used to manipulate the queue
            QueueClient queueClient = new QueueClient(connectionString, queueName);

            if (queueClient.Exists())
            {
                // Delete the queue
                queueClient.Delete();
            }

            Console.WriteLine($"Queue deleted: '{queueClient.Name}'");
        }
Exemple #9
0
        public void DeleteQueue()
        {
            // <snippet_DeleteQueue>
            // Get the connection string from app settings
            string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"];

            // Instantiate a QueueClient which will be used to create and manipulate the queue
            QueueClient queueClient = new QueueClient(connectionString, "myqueue");

            if (queueClient.Exists())
            {
                // Delete the queue
                queueClient.Delete();
            }
            // </snippet_DeleteQueue>
        }
        public void Sample01a_HelloWorld_SendMessage()
        {
            string      queueName = Randomize("sample-queue");
            QueueClient queue     = new QueueClient(ConnectionString, queueName);

            try
            {
                Sample01a_HelloWorld.SendMessage(ConnectionString, queueName);

                // Verify we uploaded one message
                Assert.AreEqual(1, queue.PeekMessages().Value.Length);
            }
            finally
            {
                queue.Delete();
            }
        }
        public void Sample01a_HelloWorld_ReceiveMessages()
        {
            string      queueName = Randomize("sample-queue");
            QueueClient queue     = new QueueClient(ConnectionString, queueName);

            try
            {
                queue.Create();
                Sample01a_HelloWorld.ReceiveMessages(ConnectionString, queueName);

                // Verify we processed all the messages
                Assert.AreEqual(0, queue.PeekMessages().Value.Length);
            }
            finally
            {
                queue.Delete();
            }
        }
        public void Sample01a_HelloWorld_PeekMesssages()
        {
            string      queueName = Randomize("sample-queue");
            QueueClient queue     = new QueueClient(ConnectionString, queueName);

            try
            {
                queue.Create();
                Sample01a_HelloWorld.PeekMesssages(ConnectionString, queueName);

                // Verify we haven't emptied the queue
                Assert.Less(0, queue.PeekMessages().Value.Length);
            }
            finally
            {
                queue.Delete();
            }
        }
Exemple #13
0
        public void Dequeue()
        {
            // Get a connection string to our Azure Storage account.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));

            queue.Create();
            try
            {
                // Add several messages to the queue
                queue.EnqueueMessage("first");
                queue.EnqueueMessage("second");
                queue.EnqueueMessage("third");
                queue.EnqueueMessage("fourth");
                queue.EnqueueMessage("fifth");

                // Get the next 10 messages from the queue
                List <string> messages = new List <string>();
                foreach (DequeuedMessage message in queue.DequeueMessages(maxMessages: 10).Value)
                {
                    // "Process" the message
                    messages.Add(message.MessageText);

                    // Let the service know we finished with the message and
                    // it can be safely deleted.
                    queue.DeleteMessage(message.MessageId, message.PopReceipt);
                }

                // Verify the messages
                Assert.AreEqual(5, messages.Count);
                Assert.Contains("first", messages);
                Assert.Contains("second", messages);
                Assert.Contains("third", messages);
                Assert.Contains("fourth", messages);
                Assert.Contains("fifth", messages);
            }
            finally
            {
                // Clean up after the test when we're finished
                queue.Delete();
            }
        }
        public static void Main()
        {
            IronMqRestClient client = Client.New(IronMqConstants.ProjectId, IronMqConstants.Token);
            QueueClient      queue  = client.Queue(IronMqConstants.QueueName);

            Console.WriteLine("Listening for new messages from IronMQ server:");
            while (true)
            {
                var msg = queue.Next();

                if (msg.Result != null)
                {
                    Console.WriteLine(msg.Result.Body);
                    Console.WriteLine();
                    queue.Delete();
                }

                Thread.Sleep(100);
            }
        }
Exemple #15
0
        public void Peek()
        {
            // Get a connection string to our Azure Storage account.
            string connectionString = ConnectionString;

            // Get a reference to a queue named "sample-queue" and then create it
            QueueClient queue = new QueueClient(connectionString, Randomize("sample-queue"));

            queue.Create();
            try
            {
                // Add several messages to the queue
                queue.EnqueueMessage("first");
                queue.EnqueueMessage("second");
                queue.EnqueueMessage("third");
                queue.EnqueueMessage("fourth");
                queue.EnqueueMessage("fifth");

                // Get the messages from the queue
                List <string> messages = new List <string>();
                foreach (PeekedMessage message in queue.PeekMessages(maxMessages: 10).Value)
                {
                    // Inspect the message
                    messages.Add(message.MessageText);
                }

                // Verify the messages
                Assert.AreEqual(5, messages.Count);
                Assert.Contains("first", messages);
                Assert.Contains("second", messages);
                Assert.Contains("third", messages);
                Assert.Contains("fourth", messages);
                Assert.Contains("fifth", messages);
            }
            finally
            {
                // Clean up after the test when we're finished
                queue.Delete();
            }
        }
Exemple #16
0
 public void After()
 {
     queue.Delete();
 }
Exemple #17
0
        public async Task <IActionResult> Book(MovieUser u, string id)
        {
            var userId = User.FindFirstValue(ClaimTypes.NameIdentifier);

            u.userDetails.uid = userId;


            var          tmov = theatreMovie.Find(FilterDefinition <TheatreMovie> .Empty).ToList();
            TheatreMovie tm   = tmov.Where(p => p.TheatreMovieID == new MongoDB.Bson.ObjectId(id)).FirstOrDefault();

            if (u.userDetails.Seat <= tm.seat)
            {
                user.InsertOne(u.userDetails);
                tm.seat = tm.seat - u.userDetails.Seat;
                var filter = Builders <TheatreMovie> .Filter.Eq("TheatreMovieID", new ObjectId(id));

                var updateDef = Builders <TheatreMovie> .Update.Set("seat", tm.seat);

                theatreMovie.UpdateOne(filter, updateDef);
                if (CreateQueue(userId))
                {
                    // Instantiate a QueueClient which will be used to create and manipulate the queue
                    QueueClient queueClient = new QueueClient(connectionString, userId);

                    // Create the queue if it doesn't already exist
                    queueClient.CreateIfNotExists();

                    if (queueClient.Exists())
                    {
                        // Send a message to the queue
                        queueClient.SendMessage("success");
                        PeekedMessage[] peekedMessage = queueClient.PeekMessages();
                        if (peekedMessage.Length == 1)
                        {
                            string mseFromQ = peekedMessage[0].MessageText;
                            if (mseFromQ == "success")
                            {
                                Random generator = new Random();
                                string msg       = "Hey  <b>" + u.userDetails.name + "</b>," + Environment.NewLine + "<br/>" + "Your booking is confirmed now of your " + u.userDetails.Seat + " seats.<br/>" + Environment.NewLine + "Your booking Id is " + generator.Next(0, 999999).ToString("D6") + "<br/>" + Environment.NewLine + "Thanks,<br/>" + Environment.NewLine + "<b>BMS</b>";
                                await callSecondService(u.userDetails, msg);

                                queueClient.Delete();
                            }
                        }
                        else if (peekedMessage.Length > 1)
                        {
                        }
                        else
                        {
                            string msg = "Hey  <b>" + u.userDetails.name + "</b>," + Environment.NewLine + "<br/>" + "sorry for inconvenience." + " <br/>" + "Thanks,<br/>" + Environment.NewLine + "<b>BMS</b>";
                            await callSecondService(u.userDetails, msg);
                        }
                    }
                }
                return(RedirectToAction("index"));
            }

            else
            {
                Random generator = new Random();
                string msg       = "Hey  <b>" + u.userDetails.name + "</b>," + Environment.NewLine + "<br/>" + "sorry for inconvenience." + " <br/>" + "Thanks,<br/>" + Environment.NewLine + "<b>BMS</b>";
                await callSecondService(u.userDetails, msg);

                return(RedirectToAction("index"));
            }


            return(RedirectToAction("index"));
        }