Ejemplo n.º 1
0
        protected override IEnumerator <IAsyncResult> ListMessagesImpl(IAccountIdentifier identity, string account, string queue, string messageMarker, bool includeInvisibleMessages, bool incldueMessageTextProperty, int maxMessages, TimeSpan?timeout, RequestContext requestContext, AsyncIteratorContext <ListMessagesResult> context)
        {
            string   nextQueueStart;
            DateTime?nextVisibilityStart;
            Guid     guid;
            int?     subQueueId;
            object   obj;

            this.ValidateNumMessages(maxMessages, this.config.MaxMessagesToReturnForListMessages);
            RemainingTime remainingTime = new RemainingTime(timeout);
            SASAuthorizationParameters sASAuthorizationParameter = new SASAuthorizationParameters()
            {
                SupportedSasTypes  = SasType.ResourceSas | SasType.AccountSas,
                SignedResourceType = SasResourceType.Object,
                SignedPermission   = SASPermission.Read
            };
            SASAuthorizationParameters sASAuthorizationParameter1 = sASAuthorizationParameter;
            IAsyncResult asyncResult = this.BeginGetQueue(identity, account, queue, PermissionLevel.Read, sASAuthorizationParameter1, remainingTime, requestContext, context.GetResumeCallback(), context.GetResumeState("QueueManager.PeekMessagesImpl"));

            yield return(asyncResult);

            IQueueContainer operationStatus = this.EndGetQueue(asyncResult);

            if (requestContext != null)
            {
                operationStatus.OperationStatus = requestContext.OperationStatus;
            }
            operationStatus.Timeout = remainingTime;
            ListMessagesMarker listMessagesMarker = SummaryResult.DecodeMarker <ListMessagesMarker>(messageMarker);

            if (listMessagesMarker == null)
            {
                Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug.Log("ListMessageImpl marker is null");
            }
            else
            {
                IStringDataEventStream verboseDebug = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;
                verboseDebug.Log("ListMessageImpl marker.NextQueueStart: {0}", new object[] { listMessagesMarker.NextQueueStart });
                IStringDataEventStream stringDataEventStream = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;
                object[] objArray = new object[] { listMessagesMarker.SubQueueId };
                stringDataEventStream.Log("ListMessageImpl marker.SubQueueId: {0}", objArray);
                IStringDataEventStream verboseDebug1 = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;
                object[] nextMessageIdStart          = new object[] { listMessagesMarker.NextMessageIdStart };
                verboseDebug1.Log("ListMessageImpl marker.NextMessageIdStart: {0}", nextMessageIdStart);
                IStringDataEventStream stringDataEventStream1 = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;
                object[] objArray1 = new object[1];
                object[] objArray2 = objArray1;
                obj          = (listMessagesMarker.NextVisibilityStart.HasValue ? listMessagesMarker.NextVisibilityStart.Value.ToString("mm/dd/yy hh:mm:ss.fff") : "null");
                objArray2[0] = obj;
                stringDataEventStream1.Log("ListMessageImpl marker.NextVisibilityStart: {0}", objArray1);
            }
            IQueueContainer queueContainer = operationStatus;

            if (listMessagesMarker == null)
            {
                nextQueueStart = null;
            }
            else
            {
                nextQueueStart = listMessagesMarker.NextQueueStart;
            }
            if (listMessagesMarker == null)
            {
                nextVisibilityStart = null;
            }
            else
            {
                nextVisibilityStart = listMessagesMarker.NextVisibilityStart;
            }
            guid = (listMessagesMarker == null ? Guid.Empty : listMessagesMarker.NextMessageIdStart);
            if (listMessagesMarker == null)
            {
                subQueueId = null;
            }
            else
            {
                subQueueId = listMessagesMarker.SubQueueId;
            }
            asyncResult = queueContainer.BeginListMessages(nextQueueStart, nextVisibilityStart, guid, subQueueId, includeInvisibleMessages, maxMessages, context.GetResumeCallback(), context.GetResumeState("QueueManager.PeekMessagesImpl"));
            yield return(asyncResult);

            ListMessagesResult listMessagesResults = operationStatus.EndListMessages(asyncResult);

            listMessagesResults.PoppedMessages = this.WrapGetMessageResults(listMessagesResults.Messages);
            context.ResultData = listMessagesResults;
            StringBuilder stringBuilder = new StringBuilder();
            int           num           = 0;

            foreach (PoppedMessage poppedMessage in context.ResultData.PoppedMessages)
            {
                stringBuilder.Append(string.Format("[{0}],", poppedMessage.ToString()));
                num++;
            }
            IStringDataEventStream verboseDebug2 = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;

            object[] str = new object[] { num, stringBuilder.ToString() };
            verboseDebug2.Log("ListMessages response: Count={0} Messages={1}", str);
        }