示例#1
0
 private void CheckResultsOfGetFolder()
 {
     foreach (GetFolderRequest getFolderRequest in this.getFolderRequests)
     {
         BaseQuery query = getFolderRequest.Query;
         if (string.IsNullOrEmpty(getFolderRequest.ResultFolderId))
         {
             GetFolderAndProxyRequest.GetFolderRequestTracer.TraceDebug <object, EmailAddress>((long)this.GetHashCode(), "{0}: No ResultFolderId returned for mailbox {1}.", TraceContext.Get(), query.Email);
         }
         else
         {
             StoreObjectId storeObjectId      = StoreId.EwsIdToStoreObjectId(getFolderRequest.ResultFolderId);
             StoreObjectId associatedFolderId = query.RecipientData.AssociatedFolderId;
             if (!associatedFolderId.Equals(storeObjectId))
             {
                 GetFolderAndProxyRequest.GetFolderRequestTracer.TraceDebug((long)this.GetHashCode(), "{0}: Requested folder id {2} doesn't match default folder id {3} for mailbox {1}.", new object[]
                 {
                     TraceContext.Get(),
                     query.Email,
                     associatedFolderId,
                     storeObjectId
                 });
                 query.SetResultOnFirstCall(base.Application.CreateQueryResult(new NotDefaultCalendarException()));
             }
         }
     }
 }
示例#2
0
        internal override BaseQueryResult GetData(BaseQuery query)
        {
            FreeBusyQuery   freeBusyQuery   = (FreeBusyQuery)query;
            Guid            serverRequestId = Trace.TraceCasStart(CasTraceEventType.Availability);
            EmailAddress    email           = freeBusyQuery.Email;
            BaseQueryResult dataInternal    = this.GetDataInternal(freeBusyQuery, email);

            this.TraceRequestStop(email, serverRequestId);
            return(dataInternal);
        }
示例#3
0
 public override void BeginInvoke(TaskCompleteCallback callback)
 {
     base.BeginInvoke(callback);
     GetFolderAndProxyRequest.GetFolderRequestTracer.TraceDebug <object, int, Uri>((long)this.GetHashCode(), "{0}: Dispatching GetFolder request for {1} mailboxes to Url {2}.", TraceContext.Get(), base.QueryList.Count, this.webServiceUri.Uri);
     this.getFolderRequests = new GetFolderRequest[base.QueryList.Count];
     for (int i = 0; i < base.QueryList.Count; i++)
     {
         BaseQuery query = base.QueryList[i];
         this.getFolderRequests[i] = new GetFolderRequest(base.Application, (InternalClientContext)base.ClientContext, base.RequestType, base.RequestLogger, query, this.webServiceUri.Uri);
     }
     this.parallel = new AsyncTaskParallel(this.getFolderRequests);
     this.parallel.BeginInvoke(new TaskCompleteCallback(this.Complete1));
 }
示例#4
0
        private void ExecuteInternal(BaseQuery query)
        {
            IStandardBudget standardBudget = null;

            if (Interlocked.Exchange(ref this.firstThreadEntryTimeCaptured, 1) == 0)
            {
                base.RequestLogger.Add(RequestStatistics.Create(RequestStatisticsType.LocalFirstThreadExecute, this.localRequestStopwatch.ElapsedMilliseconds));
            }
            if (base.Aborted)
            {
                return;
            }
            RequestStatisticsForMapi requestStatisticsForMapi = RequestStatisticsForMapi.Begin();
            Stopwatch stopwatch = Stopwatch.StartNew();

            try
            {
                if (base.ClientContext.Budget != null)
                {
                    standardBudget = StandardBudget.Acquire(base.ClientContext.Budget.Owner);
                    if (standardBudget != null)
                    {
                        standardBudget.StartLocal("LocalRequest.ExecuteInternal", default(TimeSpan));
                    }
                }
                LocalRequest.RequestRoutingTracer.TraceDebug <object, int>((long)this.GetHashCode(), "{0}: Entered LocalRequest.Execute() using thread {1}", TraceContext.Get(), Environment.CurrentManagedThreadId);
                if (query.SetResultOnFirstCall(this.localQuery.GetData(query)))
                {
                    LocalRequest.RequestRoutingTracer.TraceDebug <object, EmailAddress, int>((long)this.GetHashCode(), "{0}: Request for mailbox {1} complete and result set in time. Thread {2}", TraceContext.Get(), query.Email, Environment.CurrentManagedThreadId);
                }
            }
            finally
            {
                stopwatch.Stop();
                if (standardBudget != null)
                {
                    standardBudget.EndLocal();
                    standardBudget.Dispose();
                }
                base.RequestLogger.Add(RequestStatistics.Create(RequestStatisticsType.LocalElapsedTimeLongPole, stopwatch.ElapsedMilliseconds, query.ExchangePrincipal.MailboxInfo.Location.ServerFqdn));
                base.RequestLogger.Add(requestStatisticsForMapi.End(RequestStatisticsType.Local, query.ExchangePrincipal.MailboxInfo.Location.ServerFqdn));
                if (Interlocked.Decrement(ref this.pendingItems) == 0)
                {
                    this.ComputeStatistics();
                    this.DisposeIfInternalContext();
                    base.Complete();
                }
                LocalRequest.RequestRoutingTracer.TraceDebug <object, int>((long)this.GetHashCode(), "{0}: Exited LocalRequest.Execute() using thread {1}", TraceContext.Get(), Environment.CurrentManagedThreadId);
            }
        }
示例#5
0
        private static string GetIntraForestLatency(BaseQuery query)
        {
            string text = string.Empty;

            if (query.Type == RequestType.Local || query.Type == RequestType.IntraSite || query.Type == RequestType.CrossSite)
            {
                if (query.ExchangePrincipalLatency > 0L)
                {
                    text = string.Format("{0}-{1}|", "EPL", query.ExchangePrincipalLatency);
                }
                if (query.ServiceDiscoveryLatency > 0L)
                {
                    text = string.Format("{0}{1}-{2}|", text, "SDL", query.ServiceDiscoveryLatency);
                }
            }
            return(text);
        }
 public DispatcherWithAutoDiscoverResults(Application application, QueryList queryList, IList <AutoDiscoverQueryItem> autoDiscoverQueryItems, ProxyAuthenticator proxyAuthenticator, RequestType requestType, DispatcherWithAutoDiscoverResults.CreateRequestWithQueryListDelegate createRequestDelegate)
 {
     DispatcherWithAutoDiscoverResults < > 4__this = this;
     this.createRequestDelegate = createRequestDelegate;
     for (int i = 0; i < queryList.Count; i++)
     {
         BaseQuery          baseQuery          = queryList[i];
         AutoDiscoverResult autoDiscoverResult = autoDiscoverQueryItems[i].Result;
         if (autoDiscoverResult.Exception != null)
         {
             DispatcherWithAutoDiscoverResults.RequestRoutingTracer.TraceError <object, EmailAddress>((long)this.GetHashCode(), "{0}: autodiscover for {1} failed and it will not be dispatched for query", TraceContext.Get(), baseQuery.Email);
             baseQuery.SetResultOnFirstCall(application.CreateQueryResult(autoDiscoverResult.Exception));
         }
         else
         {
             string key = autoDiscoverResult.WebServiceUri.Uri.ToString();
             if (autoDiscoverResult.WebServiceUri.EmailAddress != null)
             {
                 baseQuery.RecipientData.EmailAddress = autoDiscoverResult.WebServiceUri.EmailAddress;
             }
             base.Add(key, baseQuery, requestType, (QueryList perRequestQueryList) => < > 4__this.createRequestDelegate(perRequestQueryList, proxyAuthenticator ?? autoDiscoverResult.ProxyAuthenticator, autoDiscoverResult.WebServiceUri, UriSource.EmailDomain));
         }
     }
 }
示例#7
0
        public void Add(string key, BaseQuery query, RequestType requestType, BaseRequestDispatcher.CreateRequestDelegate createRequestDelegate)
        {
            BaseRequestDispatcher.RequestRoutingTracer.TraceDebug((long)this.GetHashCode(), "{0}: Adding a proxy web request of type {1} for mailbox {2} to request key {3}", new object[]
            {
                TraceContext.Get(),
                requestType,
                query.Email,
                key
            });
            query.Type = new RequestType?(requestType);
            QueryList queryList;

            if (!this.queryListDictionary.TryGetValue(key, out queryList))
            {
                BaseRequestDispatcher.RequestRoutingTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: key {1} was not found. Creating new request for it", TraceContext.Get(), key);
                queryList = new QueryList();
                queryList.Add(query);
                this.requests.Add(createRequestDelegate(queryList));
                this.queryListDictionary.Add(key, queryList);
            }
            else
            {
                BaseRequestDispatcher.RequestRoutingTracer.TraceDebug <object, string>((long)this.GetHashCode(), "{0}: key {1} was found.", TraceContext.Get(), key);
                queryList.Add(query);
            }
            switch (requestType)
            {
            case RequestType.Local:
                PerformanceCounters.IntraSiteCalendarQueriesPerSecond.Increment();
                this.intraSiteQueryCount++;
                return;

            case RequestType.IntraSite:
                PerformanceCounters.IntraSiteProxyFreeBusyQueriesPerSecond.Increment();
                this.intraSiteProxyQueryCount++;
                return;

            case RequestType.CrossSite:
                PerformanceCounters.CrossSiteCalendarQueriesPerSecond.Increment();
                this.crossSiteQueryCount++;
                return;

            case RequestType.CrossForest:
                PerformanceCounters.CrossForestCalendarQueriesPerSecond.Increment();
                this.crossForestQueryCount++;
                return;

            case RequestType.FederatedCrossForest:
                PerformanceCounters.FederatedFreeBusyQueriesPerSecond.Increment();
                this.federatedCrossForestQueryCount++;
                return;

            case RequestType.PublicFolder:
                PerformanceCounters.PublicFolderQueriesPerSecond.Increment();
                this.publicFolderQueryCount++;
                return;

            default:
                return;
            }
        }
示例#8
0
 internal abstract BaseQueryResult GetData(BaseQuery query);
示例#9
0
        public GetFolderRequest(Application application, InternalClientContext clientContext, RequestType requestType, RequestLogger requestLogger, BaseQuery query, Uri url) : base(application, clientContext, requestLogger, "GetFolderRequest")
        {
            if (query.RecipientData == null || query.RecipientData.AssociatedFolderId == null)
            {
                throw new InvalidOperationException("Unable to get associated folder id");
            }
            this.query       = query;
            this.url         = url.OriginalString;
            this.binding     = new ExchangeServiceBinding(Globals.CertificateValidationComponentId, new RemoteCertificateValidationCallback(CertificateErrorHandler.CertValidationCallback));
            this.binding.Url = url.OriginalString;
            this.binding.RequestServerVersionValue         = new RequestServerVersion();
            this.binding.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;
            Server localServer = LocalServerCache.LocalServer;

            if (localServer != null && localServer.InternetWebProxy != null)
            {
                GetFolderRequest.GetFolderRequestTracer.TraceDebug <GetFolderRequest, Uri>((long)this.GetHashCode(), "{0}: Using custom InternetWebProxy {1}", this, localServer.InternetWebProxy);
                this.binding.Proxy = new WebProxy(localServer.InternetWebProxy);
            }
        }
示例#10
0
 public AutoDiscoverQueryItem(RecipientData recipientData, LocalizedString applicationName, BaseQuery sourceQuery)
 {
     this.EmailAddress        = recipientData.EmailAddress;
     this.initialEmailAddress = recipientData.EmailAddress;
     this.recipientData       = recipientData;
     this.applicationName     = applicationName;
     this.sourceQuery         = sourceQuery;
 }