Exemplo n.º 1
0
        async Task <bool> ExecuteLoadQueueMessagesAsync(bool force = false)
        {
            if (IsBusy)
            {
                return(false);
            }

            try
            {
                IsBusy = true;
                NoQueueMessagesFound = false;

                if (!Queue.BaseQueue.ApproximateMessageCount.HasValue || force)
                {
                    await queue.BaseQueue.FetchAttributesAsync();

                    OnPropertyChanged("Queue");
                }
                if (Queue.BaseQueue.ApproximateMessageCount.Value == 0)
                {
                    NoQueueMessagesFound = true;
                    return(true);
                }


                QueueMessages.Clear();

                var queueMessages = await Queue.BaseQueue.GetMessagesAsync(Queue.BaseQueue.ApproximateMessageCount.Value,
                                                                           TimeSpan.FromSeconds(Settings.Current.QueueVisibilityTimeoutSeconds), null, null);

                QueueMessageCount = Queue.BaseQueue.ApproximateMessageCount.Value;
                foreach (var queueMessage in queueMessages)
                {
                    QueueMessages.Add(queueMessage);
                }
                SortQueueMessages();
                if (QueueMessages.Count == 0)
                {
                    NoQueueMessagesFoundMessage = "No Queue Messages Found";
                    NoQueueMessagesFound        = true;
                }
                else
                {
                    NoQueueMessagesFound = false;
                }
            }
            catch (Exception ex)
            {
                Logger.Report(ex, "Method", "ExecuteLoadQueueMessagesAsync");
                MessagingService.Current.SendMessage(MessageKeys.Error, ex);
            }
            finally
            {
                IsBusy = false;
            }
            return(true);
        }
Exemplo n.º 2
0
 public void AddQueueMessage(CloudQueueMessage queueMessage)
 {
     QueueMessages.Add(queueMessage);
     SortQueueMessages();
     QueueMessageCount = QueueMessages.Count;
 }