示例#1
0
 internal IList <RecipientData> Query(string recipientSmtpAddress, ADObjectId recipientAdObjectId)
 {
     if (!string.IsNullOrEmpty(recipientSmtpAddress) && SmtpAddress.IsValidSmtpAddress(recipientSmtpAddress))
     {
         RecipientQueryResults recipientQueryResults = base.Query(new EmailAddress[]
         {
             new EmailAddress(string.Empty, recipientSmtpAddress)
         });
         if (recipientQueryResults != null && recipientQueryResults.Count > 0 && recipientQueryResults[0].Exception == null && recipientQueryResults[0].ProviderError == null)
         {
             return(recipientQueryResults);
         }
     }
     if (recipientAdObjectId != null)
     {
         ADRecipient adrecipient = base.ADRecipientSession.Read(recipientAdObjectId);
         if (adrecipient != null)
         {
             EmailAddress emailAddress = RecipientQuery.CreateEmailAddressFromADRecipient(adrecipient);
             return(new RecipientData[]
             {
                 RecipientData.Create(emailAddress, adrecipient, UserPhotoRecipientQuery.RecipientProperties)
             });
         }
     }
     this.tracer.TraceDebug <string, ADObjectId>((long)this.GetHashCode(), "Target user not found in directory.  Search params were SMTP-address='{0}' OR ADObjectId='{1}'", recipientSmtpAddress, recipientAdObjectId);
     return(Array <RecipientData> .Empty);
 }
示例#2
0
        internal RecipientQueryResults Query(MailboxData[] mailboxDataArray)
        {
            EmailAddress[] array = new EmailAddress[mailboxDataArray.Length];
            for (int i = 0; i < mailboxDataArray.Length; i++)
            {
                array[i] = FreeBusyRecipientQuery.ConvertMailboxDataToEmailAddress(mailboxDataArray[i]);
            }
            RecipientQueryResults recipientQueryResults = base.Query(array);

            for (int j = 0; j < mailboxDataArray.Length; j++)
            {
                recipientQueryResults[j].AssociatedFolderId = mailboxDataArray[j].AssociatedFolderId;
            }
            return(recipientQueryResults);
        }
示例#3
0
        private void ExecuteFreeBusyQuery(AvailabilityQueryResult availabilityQueryResult)
        {
            Stopwatch stopwatch = Stopwatch.StartNew();

            AvailabilityQuery.CalendarViewTracer.TraceDebug((long)this.GetHashCode(), "{0}: Entering AvailabilityQuery.ExecuteFreeBusyQuery()", new object[]
            {
                TraceContext.Get()
            });
            base.RequestLogger.AppendToLog <int>("AddressCount", this.MailboxArray.Length);
            base.RequestLogger.AppendToLog <string>("MessageId", base.ClientContext.MessageId);
            base.RequestLogger.AppendToLog <string>("Requester", base.ClientContext.IdentityForFilteredTracing);
            try
            {
                Guid           serverRequestId = Microsoft.Exchange.Diagnostics.Trace.TraceCasStart(this.casTraceEventType);
                QueryType      queryType       = ((this.desiredFreeBusyView != null) ? QueryType.FreeBusy : ((QueryType)0)) | ((this.desiredSuggestionsView != null) ? QueryType.MeetingSuggestions : ((QueryType)0));
                ADObjectId     adobjectId      = null;
                OrganizationId organizationId  = OrganizationId.ForestWideOrgId;
                if (base.ClientContext is InternalClientContext && !this.IsCrossForestRequest)
                {
                    adobjectId     = base.ClientContext.QueryBaseDN;
                    organizationId = base.ClientContext.OrganizationId;
                }
                if (VariantConfiguration.GetSnapshot(MachineSettingsContext.Local, null, null).Global.MultiTenancy.Enabled&& (organizationId == null || organizationId == OrganizationId.ForestWideOrgId))
                {
                    AvailabilityQuery.CalendarViewTracer.TraceDebug <object, EmailAddress>((long)this.GetHashCode(), "{0}: Looking up the OrgId for address {1}", TraceContext.Get(), this.mailboxArray[0].Email);
                    organizationId = this.GetTargetOrganizationIdFromCache(this.mailboxArray[0].Email);
                }
                if (organizationId != null && organizationId.OrganizationalUnit != null)
                {
                    base.RequestLogger.AppendToLog <string>("ORG", organizationId.OrganizationalUnit.Name);
                }
                AvailabilityQuery.CalendarViewTracer.TraceDebug((long)this.GetHashCode(), "{0}: Ad scoping for the requester {1}: QueryBaseDN: {2}, OrganizationId: {3}", new object[]
                {
                    TraceContext.Get(),
                    base.ClientContext.ToString(),
                    (adobjectId == null) ? "<NULL>" : adobjectId.ToString(),
                    organizationId
                });
                FreeBusyApplication freeBusyApplication = new FreeBusyApplication(base.ClientContext, this.internalFreeBusyView, this.defaultFreeBusyOnly, queryType);
                try
                {
                    this.queryPrepareDeadline      = this.queryPrepareDeadline.AddMilliseconds(-this.PreExecutionTimeTaken);
                    this.requestProcessingDeadline = this.requestProcessingDeadline.AddMilliseconds(-this.PreExecutionTimeTaken);
                    using (RequestDispatcher requestDispatcher = new RequestDispatcher(base.RequestLogger))
                    {
                        FreeBusyRecipientQuery freeBusyRecipientQuery = new FreeBusyRecipientQuery(base.ClientContext, adobjectId, organizationId, this.queryPrepareDeadline);
                        RecipientQueryResults  recipientQueryResults  = freeBusyRecipientQuery.Query(this.mailboxArray);
                        QueryGenerator         queryGenerator         = new QueryGenerator(freeBusyApplication, base.ClientContext, base.RequestLogger, requestDispatcher, this.queryPrepareDeadline, this.requestProcessingDeadline, recipientQueryResults);
                        bool flag = false;
                        try
                        {
                            BaseQuery[] queries = queryGenerator.GetQueries();
                            this.freeBusyQueryArray = FreeBusyApplication.ConvertBaseToFreeBusyQuery(queries);
                            if (base.ClientContext.Budget != null)
                            {
                                base.ClientContext.Budget.EndLocal();
                                flag = true;
                            }
                            requestDispatcher.Execute(this.requestProcessingDeadline, base.HttpResponse);
                            this.individualMailboxesProcessed = queryGenerator.UniqueQueriesCount;
                        }
                        finally
                        {
                            if (flag)
                            {
                                base.ClientContext.Budget.StartLocal("AvailabilityQuery.ExecuteFreeBusyQuery", default(TimeSpan));
                            }
                            requestDispatcher.LogStatistics(base.RequestLogger);
                        }
                    }
                }
                finally
                {
                    freeBusyApplication.LogThreadsUsage(base.RequestLogger);
                }
                foreach (FreeBusyQuery freeBusyQuery in this.freeBusyQueryArray)
                {
                    if (freeBusyQuery.AttendeeKind == AttendeeKind.Group)
                    {
                        FreeBusyQueryResult resultOnFirstCall;
                        if (freeBusyQuery.GroupMembersForFreeBusy != null)
                        {
                            resultOnFirstCall = MergedFreeBusy.MergeGroupMemberResults(base.ClientContext.TimeZone, this.internalFreeBusyView.MergedFreeBusyIntervalInMinutes, new ExDateTime(base.ClientContext.TimeZone, this.internalFreeBusyView.TimeWindow.StartTime), new ExDateTime(base.ClientContext.TimeZone, this.internalFreeBusyView.TimeWindow.EndTime), freeBusyQuery.GroupMembersForFreeBusy, base.ClientContext.RequestSchemaVersion);
                        }
                        else
                        {
                            resultOnFirstCall = new FreeBusyQueryResult(FreeBusyViewType.None, null, null, null);
                        }
                        freeBusyQuery.SetResultOnFirstCall(resultOnFirstCall);
                    }
                }
                availabilityQueryResult.FreeBusyResults = new FreeBusyQueryResult[this.freeBusyQueryArray.Length];
                for (int j = 0; j < this.freeBusyQueryArray.Length; j++)
                {
                    availabilityQueryResult.FreeBusyResults[j] = this.freeBusyQueryArray[j].Result;
                }
                this.TraceExecuteFreeBusyQueryStop(serverRequestId);
                AvailabilityQuery.CalendarViewTracer.TraceDebug((long)this.GetHashCode(), "{0}: Leaving AvailabilityQuery.ExecuteFreeBusyQuery()", new object[]
                {
                    TraceContext.Get()
                });
            }
            finally
            {
                base.RequestLogger.CalculateQueryStatistics(this.freeBusyQueryArray);
                base.LogFailures(availabilityQueryResult, base.RequestLogger.ExceptionData);
                stopwatch.Stop();
                base.RequestLogger.AppendToLog <long>("TAQ", stopwatch.ElapsedMilliseconds);
            }
        }