コード例 #1
0
 private void detach_QueueMessages(QueueMessage entity)
 {
     this.SendPropertyChanging();
     entity.QueueContainer = null;
 }
コード例 #2
0
        private IEnumerator <IAsyncResult> ListMessagesImpl(string queueNameStart, DateTime?visibilityStart, Guid messageIdStart, int?subQueueId, bool includeInvisibleMessages, int numberOfMessages, AsyncIteratorContext <ListMessagesResult> context)
        {
            IAsyncResult asyncResult = this.StorageManager.AsyncProcessor.BeginExecute <ListMessagesResult>((TimeSpan remaining) => {
                ListMessagesResult listMessagesResults;
                using (DevelopmentStorageDbDataContext dbContext = DevelopmentStorageDbDataContext.GetDbContext())
                {
                    Microsoft.WindowsAzure.DevelopmentStorage.Store.QueueContainer queueContainer = this.LoadQueueContainer(dbContext);
                    this._queue       = queueContainer;
                    queueNameStart    = (string.IsNullOrEmpty(queueNameStart) ? this._queue.QueueName : queueNameStart);
                    DateTime?nullable = visibilityStart;
                    visibilityStart   = new DateTime?((nullable.HasValue ? nullable.GetValueOrDefault() : DateTime.UtcNow));
                    IQueryable <QueueMessage> queueMessages =
                        from m in dbContext.QueueMessages
                        select m;
                    queueMessages =
                        from m in queueMessages
                        where (m.AccountName == this._queue.AccountName) && (m.QueueName == queueNameStart) && (m.ExpiryTime >= DateTime.UtcNow)
                        select m;
                    if (messageIdStart != Guid.Empty)
                    {
                        queueMessages = (!includeInvisibleMessages ?
                                         from m in queueMessages
                                         where ((DateTime?)m.VisibilityStartTime > visibilityStart) && (m.VisibilityStartTime <= DateTime.UtcNow) || ((DateTime?)m.VisibilityStartTime == visibilityStart) && (m.VisibilityStartTime <= DateTime.UtcNow) && string.Compare(m.MessageId.ToString(), messageIdStart.ToString(), true) >= 0
                                         select m :
                                         from m in queueMessages
                                         where ((DateTime?)m.VisibilityStartTime > visibilityStart) || ((DateTime?)m.VisibilityStartTime == visibilityStart) && string.Compare(m.MessageId.ToString(), messageIdStart.ToString(), true) >= 0
                                         select m);
                    }
                    else if (!includeInvisibleMessages)
                    {
                        queueMessages =
                            from m in queueMessages
                            where (DateTime?)m.VisibilityStartTime <= visibilityStart
                            select m;
                    }
                    queueMessages = (
                        from m in queueMessages
                        orderby m.VisibilityStartTime
                        select m).Take <QueueMessage>(numberOfMessages);
                    ListMessagesResult listMessagesResults1 = new ListMessagesResult();
                    List <IMessageData> messageDatas        = new List <IMessageData>();
                    int num = 1;
                    QueueMessage queueMessage = null;
                    foreach (QueueMessage queueMessage1 in queueMessages)
                    {
                        queueMessage = queueMessage1;
                        messageDatas.Add(new DbMessageData(queueMessage1, true));
                        num++;
                    }
                    if (num > numberOfMessages && queueMessage != null)
                    {
                        IQueryable <QueueMessage> queueMessages1 = (
                            from msg in dbContext.QueueMessages
                            where (msg.AccountName == queueMessage.AccountName) && (msg.QueueName == queueMessage.QueueName) && ((msg.VisibilityStartTime > queueMessage.VisibilityStartTime) || (msg.VisibilityStartTime == queueMessage.VisibilityStartTime) && string.Compare(msg.MessageId.ToString(), queueMessage.MessageId.ToString(), true) > 0)
                            orderby msg.VisibilityStartTime, msg.MessageId
                            select msg).Take <QueueMessage>(1);
                        if (queueMessages1 != null && queueMessages1.Count <QueueMessage>() > 0)
                        {
                            QueueMessage queueMessage2      = queueMessages1.First <QueueMessage>();
                            listMessagesResults1.NextMarker = SummaryResult.EncodeMarker <ListMessagesMarker>(new ListMessagesMarker(queueMessage2.QueueName, 0, new DateTime?(queueMessage2.VisibilityStartTime), queueMessage2.MessageId));
                        }
                    }
                    listMessagesResults1.Messages = messageDatas;
                    listMessagesResults           = listMessagesResults1;
                }
                return(listMessagesResults);
            }, this.Timeout, context.GetResumeCallback(), context.GetResumeState("DbQueueContainer.PeekMessage"));

            yield return(asyncResult);

            context.ResultData = this.StorageManager.AsyncProcessor.EndExecute <ListMessagesResult>(asyncResult);
        }
コード例 #3
0
 public DbMessageData(QueueMessage message, bool isPeekMessage)
 {
     this.m_message       = message;
     this.m_isPeekMessage = isPeekMessage;
 }