private PullResponse PullNextBatch(EnumerationContextKey context, int maxElements, IEnumerable <Selector> selectors)
 {
     using (ClientContext <IWSEventingPullDeliveryContract> ctx =
                new ClientContext <IWSEventingPullDeliveryContract>(_endpointUri, _binding.MessageVersion.Addressing, _enumerationProxyFactory,
                                                                    mx =>
     {
         mx.Add(new ResourceUriHeader(_resourceUri));
         mx.Add(new SelectorSetHeader(selectors));
     }))
     {
         FilterMapExtension.Activate(_filterMap);
         EnumerationModeExtension.Activate(EnumerationMode.EnumerateObjectAndEPR, typeof(T));
         try
         {
             return(ctx.Channel.Pull(new PullRequest
             {
                 MaxTime = new MaxTime(TimeSpan.FromSeconds(10)),
                 EnumerationContext = context,
                 MaxElements = new MaxElements(maxElements)
             }));
         }
         catch (FaultException ex)
         {
             if (ex.IsA(Faults.TimedOut))
             {
                 return(new PullResponse {
                     EnumerationContext = context
                 });
             }
             throw;
         }
     }
 }
예제 #2
0
        public IEnumerable <EndpointAddress> EnumerateEPR(Uri resourceUri, Filter filter, int maxElements, IEnumerable <Selector> selectors)
        {
            EnumerateResponse response;

            using (ClientContext <IWSEnumerationContract> ctx =
                       new ClientContext <IWSEnumerationContract>(_endpointUri, _binding.MessageVersion.Addressing, _proxyFactory,
                                                                  mx =>
            {
                mx.Add(new ResourceUriHeader(resourceUri.ToString()));
                mx.Add(new SelectorSetHeader(selectors));
            }))
            {
                FilterMapExtension.Activate(_filterMap);
                EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
                response = ctx.Channel.Enumerate(new EnumerateRequest
                {
                    EnumerationMode     = EnumerationMode.EnumerateEPR,
                    OptimizeEnumeration = _optimize ? new OptimizeEnumeration() : null,
                    Filter      = filter,
                    MaxElements = new MaxElements(maxElements)
                });
            }
            if (response.Items != null)
            {
                foreach (EnumerationItem item in response.Items.Items)
                {
                    yield return(item.EprValue);
                }
            }
            EnumerationContextKey context = response.EnumerationContext;
            bool endOfSequence            = response.EndOfSequence != null;

            while (!endOfSequence)
            {
                PullResponse pullResponse = PullNextEPRBatch(context, resourceUri.ToString(), maxElements, selectors);
                foreach (EnumerationItem item in pullResponse.Items.Items)
                {
                    yield return(item.EprValue);
                }
                endOfSequence = pullResponse.EndOfSequence != null;
                context       = pullResponse.EnumerationContext;
            }
        }
예제 #3
0
 private PullResponse PullNextEPRBatch(EnumerationContextKey context, string resourceUri, int maxElements, IEnumerable <Selector> selectors)
 {
     using (ClientContext <IWSEnumerationContract> ctx =
                new ClientContext <IWSEnumerationContract>(_endpointUri, _binding.MessageVersion.Addressing, _proxyFactory,
                                                           mx =>
     {
         mx.Add(new ResourceUriHeader(resourceUri));
         mx.Add(new SelectorSetHeader(selectors));
     }))
     {
         FilterMapExtension.Activate(_filterMap);
         EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
         return(ctx.Channel.Pull(new PullRequest
         {
             EnumerationContext = context,
             MaxElements = new MaxElements(maxElements)
         }));
     }
 }
예제 #4
0
        public IPullSubscriptionClient <T> SubscribeUsingPullDelivery <T>(Uri subscriptionResourceUri, Uri pullResourceUri, Filter filter, IEnumerable <Selector> selectors)
        {
            SubscribeResponse response;

            using (ClientContext <IWSEventingContract> ctx =
                       new ClientContext <IWSEventingContract>(_endpointUri, _binding.MessageVersion.Addressing, _proxyFactory, mx => {
                mx.Add(new SelectorSetHeader(selectors));
                mx.Add(new ResourceUriHeader(subscriptionResourceUri.ToString()));
            }))
            {
                FilterMapExtension.Activate(_filterMap);
                response = ctx.Channel.Subscribe(new SubscribeRequest
                {
                    Delivery = Delivery.Pull(),
                    Filter   = filter,
                    Expires  = Expires.FromDateTime(DateTime.Now.AddYears(1))
                });
            }
            return(new PullSubscriptionClientImpl <T>(_endpointUri, _binding, _filterMap, response.EnumerationContext, pullResourceUri.ToString(), _proxyFactory));
        }
예제 #5
0
 public int EstimateCount(Uri resourceUri, Filter filter, IEnumerable <Selector> selectors)
 {
     using (ClientContext <IWSEnumerationContract> ctx =
                new ClientContext <IWSEnumerationContract>(_endpointUri, _binding.MessageVersion.Addressing, _proxyFactory,
                                                           mx =>
     {
         mx.Add(new ResourceUriHeader(resourceUri.ToString()));
         mx.Add(new SelectorSetHeader(selectors));
     }))
     {
         OperationContextProxy.Current.AddHeader(new RequestTotalItemsCountEstimate());
         FilterMapExtension.Activate(_filterMap);
         EnumerationModeExtension.Activate(EnumerationMode.EnumerateEPR, null);
         ctx.Channel.Enumerate(new EnumerateRequest
         {
             EnumerationMode     = EnumerationMode.EnumerateEPR,
             OptimizeEnumeration = _optimize ? new OptimizeEnumeration() : null,
             Filter = filter,
         });
         TotalItemsCountEstimate totalItemsCountEstimate =
             OperationContextProxy.Current.FindHeader <TotalItemsCountEstimate>();
         return(totalItemsCountEstimate.Value);
     }
 }