Exemple #1
0
        protected override IEnumerator <IAsyncResult> PutMessageImpl(IAccountIdentifier identity, string account, string queue, List <PushedMessage> messagesList, TimeSpan?timeout, RequestContext requestContext, bool usePutMessageRowCommand, AsyncIteratorContext <IEnumerable <PoppedMessage> > context)
        {
            TimeSpan      timeSpan;
            RemainingTime remainingTime = new RemainingTime(timeout);
            SASAuthorizationParameters sASAuthorizationParameter = new SASAuthorizationParameters()
            {
                SupportedSasTypes  = SasType.ResourceSas | SasType.AccountSas,
                SignedResourceType = SasResourceType.Object,
                SignedPermission   = SASPermission.Add
            };
            SASAuthorizationParameters sASAuthorizationParameter1 = sASAuthorizationParameter;
            IAsyncResult asyncResult = this.BeginGetQueue(identity, account, queue, PermissionLevel.Write, sASAuthorizationParameter1, remainingTime, requestContext, context.GetResumeCallback(), context.GetResumeState("QueueManager.PutMessageImpl"));

            yield return(asyncResult);

            IQueueContainer operationStatus = this.EndGetQueue(asyncResult);

            if (requestContext != null)
            {
                operationStatus.OperationStatus = requestContext.OperationStatus;
            }
            object obj = messagesList;

            if (obj == null)
            {
                obj = Enumerable.Empty <PushedMessage>();
            }
            foreach (PushedMessage pushedMessage in (IEnumerable <PushedMessage>)obj)
            {
                PushedMessage nullable   = pushedMessage;
                TimeSpan?     messageTTL = pushedMessage.MessageTTL;
                timeSpan            = (messageTTL.HasValue ? messageTTL.GetValueOrDefault() : TimeSpan.FromSeconds((double)this.config.MaxTtlSeconds));
                nullable.MessageTTL = new TimeSpan?(timeSpan);
            }
            operationStatus.Timeout = remainingTime;
            asyncResult             = operationStatus.BeginPutMessage(messagesList, usePutMessageRowCommand, context.GetResumeCallback(), context.GetResumeState("QueueManager.PutMessageImpl"));
            yield return(asyncResult);

            List <IMessageData> messageDatas = operationStatus.EndPutMessage(asyncResult);

            context.ResultData = this.WrapGetMessageResults(messageDatas);
            IStringDataEventStream verboseDebug = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;

            verboseDebug.Log("PutMessage response: MessageId={0}", new object[] { context.ResultData });
        }