Example #1
0
        protected override IEnumerator <IAsyncResult> DeleteMessageImpl(IAccountIdentifier identity, string account, string queue, string messageId, byte[] popReceipt, TimeSpan?timeout, RequestContext requestContext, AsyncIteratorContext <NoResults> context)
        {
            RemainingTime remainingTime = new RemainingTime(timeout);
            SASAuthorizationParameters sASAuthorizationParameter = new SASAuthorizationParameters()
            {
                SupportedSasTypes  = SasType.ResourceSas | SasType.AccountSas,
                SignedResourceType = SasResourceType.Object,
                SignedPermission   = SASPermission.Process
            };
            SASAuthorizationParameters sASAuthorizationParameter1 = sASAuthorizationParameter;

            NephosAssertionException.Assert(popReceipt != null);
            IAsyncResult asyncResult = this.BeginGetQueue(identity, account, queue, PermissionLevel.Delete, sASAuthorizationParameter1, remainingTime, requestContext, context.GetResumeCallback(), context.GetResumeState("QueueManager.DeleteMessageImpl"));

            yield return(asyncResult);

            IQueueContainer operationStatus = this.EndGetQueue(asyncResult);

            if (requestContext != null)
            {
                operationStatus.OperationStatus = requestContext.OperationStatus;
            }
            try
            {
                Guid guid = new Guid(messageId);
            }
            catch (Exception exception)
            {
                throw new MessageNotFoundException("Invalid message name", exception);
            }
            IQueueMessageReceipt queueMessageReceipt = this.DecodeReceipt(popReceipt, new Guid(messageId));

            operationStatus.Timeout = remainingTime;
            asyncResult             = operationStatus.BeginDeleteMessage(queueMessageReceipt, context.GetResumeCallback(), context.GetResumeState("QueueManager.DeleteMessageImpl"));
            yield return(asyncResult);

            bool flag = operationStatus.EndDeleteMessage(asyncResult);
            IStringDataEventStream verboseDebug = Logger <IRestProtocolHeadLogger> .Instance.VerboseDebug;

            object[] str = new object[] { flag, queueMessageReceipt.ToString() };
            verboseDebug.Log("DeleteMessage response: status={0} message={1}", str);
            if (!flag)
            {
                throw new MessageNotFoundException("The message could not be deleted or pop receipt invalid.");
            }
        }