Exemple #1
0
        public InternalGetMessageTrackingReportResponse GetMessageTrackingReport(string messageTrackingReportId, ReportTemplate reportTemplate, SmtpAddress[] recipientFilter, SearchScope scope, bool returnQueueEvents, TrackingEventBudget eventBudget)
        {
            GetMessageTrackingReportRequestType getMessageTrackingReportRequestType = new GetMessageTrackingReportRequestType();

            getMessageTrackingReportRequestType.MessageTrackingReportId = messageTrackingReportId;
            if (reportTemplate == ReportTemplate.Summary)
            {
                getMessageTrackingReportRequestType.ReportTemplate = MessageTrackingReportTemplateType.Summary;
            }
            else
            {
                if (reportTemplate != ReportTemplate.RecipientPath)
                {
                    throw new ArgumentException("ReportTemplate must be RecipientPath or Summary", "reportTemplate");
                }
                getMessageTrackingReportRequestType.ReportTemplate = MessageTrackingReportTemplateType.RecipientPath;
            }
            if (recipientFilter != null && recipientFilter.Length > 0)
            {
                getMessageTrackingReportRequestType.RecipientFilter = new EmailAddressType();
                getMessageTrackingReportRequestType.RecipientFilter.EmailAddress = recipientFilter[0].ToString();
            }
            getMessageTrackingReportRequestType.ReturnQueueEvents          = returnQueueEvents;
            getMessageTrackingReportRequestType.ReturnQueueEventsSpecified = true;
            if (this.diagnosticsContext.Enabled)
            {
                getMessageTrackingReportRequestType.DiagnosticsLevel = Names <DiagnosticsLevel> .Map[(int)this.diagnosticsContext.DiagnosticsLevel];
            }
            TimeSpan clientTimeout;
            TimeSpan value;

            this.directoryContext.TrackingBudget.GetTimeBudgetRemainingForWSCall(this.trackingAuthority.TrackingAuthorityKind, out clientTimeout, out value);
            TrackingExtendedProperties trackingExtendedProperties = new TrackingExtendedProperties(false, false, new TimeSpan?(value), reportTemplate == ReportTemplate.Summary, false);

            getMessageTrackingReportRequestType.Properties = trackingExtendedProperties.ToTrackingPropertyArray();
            getMessageTrackingReportRequestType.Scope      = WebServiceBinding.GetWebServiceScope(scope);
            Exception ex = null;
            InternalGetMessageTrackingReportResponse internalGetMessageTrackingReportResponse = null;

            this.WriteStartEvent(false, messageTrackingReportId, null);
            internalGetMessageTrackingReportResponse = this.TryCallWebServiceMethod <InternalGetMessageTrackingReportResponse, GetMessageTrackingReportRequestType>(delegate(GetMessageTrackingReportRequestType req)
            {
                if (clientTimeout == TimeSpan.Zero)
                {
                    throw new TimeoutExpiredException("Not enough time remaining");
                }
                return(this.clientProxy.GetMessageTrackingReport(new GetMessageTrackingReportRequestTypeWrapper(req), clientTimeout));
            }, getMessageTrackingReportRequestType, out ex);
            if (internalGetMessageTrackingReportResponse != null)
            {
                if (internalGetMessageTrackingReportResponse.Response.ResponseClass != ResponseClassType.Success)
                {
                    TrackingError trackingErrorFromWebResponseError = this.GetTrackingErrorFromWebResponseError(internalGetMessageTrackingReportResponse.Response.ResponseCode, this.trackingAuthority.Domain, internalGetMessageTrackingReportResponse.Response.MessageText);
                    this.errors.Errors.Add(trackingErrorFromWebResponseError);
                }
                this.errors.ReadErrorsFromWSMessage(internalGetMessageTrackingReportResponse.Response.Diagnostics, internalGetMessageTrackingReportResponse.Response.Errors);
                this.diagnosticsContext.MergeEvents(internalGetMessageTrackingReportResponse.Response.Diagnostics);
            }
            int num = 0;

            if (internalGetMessageTrackingReportResponse != null && internalGetMessageTrackingReportResponse.Response.MessageTrackingReport != null && internalGetMessageTrackingReportResponse.RecipientTrackingEvents != null)
            {
                num = internalGetMessageTrackingReportResponse.RecipientTrackingEvents.Count;
                if (this.diagnosticsContext.VerboseDiagnostics)
                {
                    foreach (RecipientTrackingEvent recipientTrackingEvent in internalGetMessageTrackingReportResponse.RecipientTrackingEvents)
                    {
                        SmtpAddress recipientAddress = recipientTrackingEvent.RecipientAddress;
                        string      text             = recipientTrackingEvent.RecipientAddress.ToString();
                        string      value2           = text;
                        if (!string.IsNullOrEmpty(recipientTrackingEvent.UniquePathId))
                        {
                            value2 = string.Format("[{0}]{1}", recipientTrackingEvent.UniquePathId, text);
                        }
                        this.diagnosticsContext.AddProperty(DiagnosticProperty.Data1, value2);
                        this.diagnosticsContext.WriteEvent();
                    }
                }
            }
            eventBudget.IncrementBy((uint)num);
            this.WriteEndEvent(ex, num);
            if (ex != null)
            {
                throw ex;
            }
            return(internalGetMessageTrackingReportResponse);
        }
Exemple #2
0
        public FindMessageTrackingReportResponseMessageType FindMessageTrackingReport(string domain, SmtpAddress?senderAddress, SmtpAddress?recipientAddress, string serverHint, SmtpAddress?federatedDeliveryMailbox, SearchScope scope, string messageId, string subject, bool expandTree, bool searchAsRecip, bool searchForModerationResult, DateTime start, DateTime end, TrackingEventBudget eventBudget)
        {
            FindMessageTrackingReportRequestType findMessageTrackingReportRequestType = new FindMessageTrackingReportRequestType();

            findMessageTrackingReportRequestType.StartDateTime          = start;
            findMessageTrackingReportRequestType.StartDateTimeSpecified = true;
            findMessageTrackingReportRequestType.EndDateTime            = end;
            findMessageTrackingReportRequestType.EndDateTimeSpecified   = true;
            findMessageTrackingReportRequestType.MessageId  = messageId;
            findMessageTrackingReportRequestType.Subject    = subject;
            findMessageTrackingReportRequestType.Domain     = domain;
            findMessageTrackingReportRequestType.Scope      = WebServiceBinding.GetWebServiceScope(scope);
            findMessageTrackingReportRequestType.ServerHint = serverHint;
            TimeSpan clientTimeout;
            TimeSpan value;

            this.directoryContext.TrackingBudget.GetTimeBudgetRemainingForWSCall(this.trackingAuthority.TrackingAuthorityKind, out clientTimeout, out value);
            TrackingExtendedProperties trackingExtendedProperties = new TrackingExtendedProperties(expandTree, searchAsRecip, new TimeSpan?(value), false, searchForModerationResult);

            findMessageTrackingReportRequestType.Properties = trackingExtendedProperties.ToTrackingPropertyArray();
            if (this.diagnosticsContext.Enabled)
            {
                findMessageTrackingReportRequestType.DiagnosticsLevel = Names <DiagnosticsLevel> .Map[(int)this.diagnosticsContext.DiagnosticsLevel];
            }
            if (federatedDeliveryMailbox != null)
            {
                findMessageTrackingReportRequestType.FederatedDeliveryMailbox = new EmailAddressType();
                findMessageTrackingReportRequestType.FederatedDeliveryMailbox.EmailAddress = federatedDeliveryMailbox.Value.ToString();
            }
            if (senderAddress != null)
            {
                findMessageTrackingReportRequestType.Sender = new EmailAddressType();
                findMessageTrackingReportRequestType.Sender.EmailAddress = senderAddress.Value.ToString();
            }
            if (recipientAddress != null)
            {
                findMessageTrackingReportRequestType.Recipient = new EmailAddressType();
                findMessageTrackingReportRequestType.Recipient.EmailAddress = recipientAddress.Value.ToString();
            }
            Exception ex = null;

            this.WriteStartEvent(true, messageId, serverHint);
            FindMessageTrackingReportResponseMessageType findMessageTrackingReportResponseMessageType = this.TryCallWebServiceMethod <FindMessageTrackingReportResponseMessageType, FindMessageTrackingReportRequestType>(delegate(FindMessageTrackingReportRequestType req)
            {
                if (clientTimeout == TimeSpan.Zero)
                {
                    throw new TimeoutExpiredException("Not enough time remaining");
                }
                return(this.clientProxy.FindMessageTrackingReport(new FindMessageTrackingReportRequestTypeWrapper(req), clientTimeout));
            }, findMessageTrackingReportRequestType, out ex);
            int count = 0;

            if (findMessageTrackingReportResponseMessageType != null)
            {
                if (findMessageTrackingReportResponseMessageType.ResponseClass != ResponseClassType.Success)
                {
                    TrackingError trackingErrorFromWebResponseError = this.GetTrackingErrorFromWebResponseError(findMessageTrackingReportResponseMessageType.ResponseCode, this.trackingAuthority.Domain, findMessageTrackingReportResponseMessageType.MessageText);
                    this.errors.Errors.Add(trackingErrorFromWebResponseError);
                }
                this.errors.ReadErrorsFromWSMessage(findMessageTrackingReportResponseMessageType.Diagnostics, findMessageTrackingReportResponseMessageType.Errors);
                this.diagnosticsContext.MergeEvents(findMessageTrackingReportResponseMessageType.Diagnostics);
                if (findMessageTrackingReportResponseMessageType.MessageTrackingSearchResults != null)
                {
                    count = findMessageTrackingReportResponseMessageType.MessageTrackingSearchResults.Length;
                    eventBudget.IncrementBy(10U);
                    if (this.diagnosticsContext.VerboseDiagnostics)
                    {
                        foreach (FindMessageTrackingSearchResultType findMessageTrackingSearchResultType in findMessageTrackingReportResponseMessageType.MessageTrackingSearchResults)
                        {
                            this.diagnosticsContext.AddProperty(DiagnosticProperty.Data1, findMessageTrackingSearchResultType.MessageTrackingReportId);
                            this.diagnosticsContext.WriteEvent();
                        }
                    }
                }
            }
            this.WriteEndEvent(ex, count);
            if (ex != null)
            {
                throw ex;
            }
            return(findMessageTrackingReportResponseMessageType);
        }