private void Enqueue(FanoutParameters.FanoutState state, SearchMailboxesResponse response, Exception exception)
        {
            Recorder.Trace(4L, TraceType.InfoTrace, new object[]
            {
                "FanoutSearchMailboxes.Enqueue State:",
                state,
                "Response:",
                response,
                "Exception:",
                exception
            });
            SearchMailboxesResults searchMailboxesResults = new SearchMailboxesResults(null);

            searchMailboxesResults.UpdateResults(state.Parameters, (SearchMailboxesInputs)base.Executor.Context.Input, response, exception);
            base.Executor.EnqueueNext(searchMailboxesResults);
        }
    object ParseResponse(EwsServiceXmlReader reader)
    {
        ServiceResponseCollection <SearchMailboxesResponse> serviceResponses = new ServiceResponseCollection <SearchMailboxesResponse>();

        reader.ReadStartElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages);

        while (true)
        {
            // Read ahead to see if we've reached the end of the response messages early.
            reader.Read();
            if (reader.IsEndElement(XmlNamespace.Messages, XmlElementNames.ResponseMessages))
            {
                break;
            }

            SearchMailboxesResponse response = new SearchMailboxesResponse();
            response.LoadFromXml(reader, this.GetResponseMessageXmlElementName());
            serviceResponses.Add(response);
        }

        reader.ReadEndElementIfNecessary(XmlNamespace.Messages, XmlElementNames.ResponseMessages);

        return(serviceResponses);
    }
 private void SearchCompletedCallback(IAsyncResult result)
 {
     Util.HandleExceptions(delegate
     {
         lock (this.locker)
         {
             Exception ex = null;
             bool flag2   = false;
             try
             {
                 Factory.Current.GeneralTracer.TraceDebug <Guid, string>((long)this.GetHashCode(), "Correlation Id:{0}. Reading response for the web service search call for group with URI {1}.", base.ExecutingUser.QueryCorrelationId, this.groupId.Uri.AbsoluteUri);
                 SearchMailboxesResponse searchMailboxesResponse = (SearchMailboxesResponse)this.client.EndEwsCall(this.asyncResult);
                 if (!this.cancelled)
                 {
                     if (searchMailboxesResponse.ErrorCode != null)
                     {
                         throw new WebServiceProxyInvalidResponseException(Strings.CrossServerCallFailed(string.Format("EDiscoveryError:E003::Server:{0}::", this.groupId.Uri.AbsoluteUri), searchMailboxesResponse.ErrorCode.ToString(), searchMailboxesResponse.ErrorMessage));
                     }
                     this.CreateSuccessResult(searchMailboxesResponse.SearchResult);
                 }
             }
             catch (ServiceResponseException ex2)
             {
                 if (this.retryCount > 0 && WebServiceMailboxSearchGroup.TransientServiceErrors.Contains(ex2.ErrorCode))
                 {
                     flag2 = true;
                 }
                 ex = ex2;
             }
             catch (ServiceRemoteException ex3)
             {
                 if (this.retryCount > 0)
                 {
                     flag2 = true;
                 }
                 ex = ex3;
             }
             catch (ServiceXmlDeserializationException ex4)
             {
                 ex = ex4;
             }
             catch (WebServiceProxyInvalidResponseException ex5)
             {
                 ex = ex5;
             }
             if (!this.cancelled)
             {
                 if (flag2)
                 {
                     Factory.Current.GeneralTracer.TraceDebug <Guid, string, string>((long)this.GetHashCode(), "Correlation Id:{0}. The web service search call for group with URI {1} hit a retryable exception {2}.", base.ExecutingUser.QueryCorrelationId, this.groupId.Uri.AbsoluteUri, ex.ToString());
                     this.Dispatch();
                 }
                 else
                 {
                     if (ex != null)
                     {
                         Factory.Current.GeneralTracer.TraceError <Guid, string, string>((long)this.GetHashCode(), "Correlation Id:{0}. Web service search call for group with URI {1} failed with the error {2}", base.ExecutingUser.QueryCorrelationId, this.groupId.Uri.AbsoluteUri, ex.ToString());
                         Factory.Current.EventLog.LogEvent(InfoWorkerEventLogConstants.Tuple_DiscoveryFanoutError, null, new object[]
                         {
                             base.ExecutingUser.QueryCorrelationId.ToString(),
                             this.Uri.ToString(),
                             ex.ToString()
                         });
                         this.CreateErrorResult(ex);
                     }
                     this.ReportCompletion();
                     this.completed = true;
                     this.watch.Stop();
                     base.ResultAggregator.ProtocolLog.Add("LongestFanoutTime", this.watch.ElapsedMilliseconds);
                     Factory.Current.GeneralTracer.TraceError <Guid, string, long>((long)this.GetHashCode(), "Correlation Id:{0}. Web service search call for group with URI {1} completed successfully. It ran for {2}ms.", base.ExecutingUser.QueryCorrelationId, this.groupId.Uri.AbsoluteUri, this.watch.ElapsedMilliseconds);
                 }
             }
         }
     }, delegate(GrayException ex)
     {
         this.CreateErrorResult(new WebServiceProxyInvalidResponseException(Strings.UnexpectedError, ex));
         Factory.Current.GeneralTracer.TraceError <Guid, string, string>((long)this.GetHashCode(), "Correlation Id:{0}. Web service search call for group with URI {1} failed with the error {2}", base.ExecutingUser.QueryCorrelationId, this.groupId.Uri.AbsoluteUri, ex.ToString());
         this.ReportCompletion();
         this.completed = true;
         this.watch.Stop();
         base.ResultAggregator.ProtocolLog.Add("LongestFanoutTime", this.watch.ElapsedMilliseconds);
     });
 }
예제 #4
0
        public void UpdateResults(IEnumerable <FanoutParameters> parameters, SearchMailboxesInputs input, SearchMailboxesResponse response, Exception exception)
        {
            Recorder.Trace(4L, TraceType.InfoTrace, new object[]
            {
                "SearchMailboxesResults.UpdateResults Parameters:",
                parameters,
                "Input:",
                input,
                "Response:",
                response,
                "Exception:",
                exception
            });
            this.AddSources(from t in parameters
                            select t.Source);
            using (WebServiceMailboxSearchGroup webServiceMailboxSearchGroup = new WebServiceMailboxSearchGroup(parameters.First <FanoutParameters>().GroupId, new WebServiceMailboxSearchGroup.FindMailboxInfoHandler(this.FindMailboxInfo), input.Criteria, input.PagingInfo, input.CallerInfo))
            {
                if (exception == null && (response.SearchResult == null || response.Result == 2))
                {
                    exception = new ServiceResponseException(response);
                }
                if (exception != null)
                {
                    using (IEnumerator <SearchSource> enumerator = this.Sources.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            SearchSource searchSource = enumerator.Current;
                            if (searchSource.MailboxInfo != null)
                            {
                                webServiceMailboxSearchGroup.MergeMailboxResult(searchSource.MailboxInfo, exception);
                            }
                        }
                        goto IL_10D;
                    }
                }
                if (response.SearchResult != null)
                {
                    webServiceMailboxSearchGroup.MergeSearchResults(response.SearchResult);
                }
IL_10D:
                this.SearchResult = webServiceMailboxSearchGroup.GetResultAggregator();
            }
        }