Example #1
0
        internal static LogSearchCursor GetCursor(string server, ServerVersion version, string logFile, string messageId, ProxyAddressCollection senderProxyAddresses, DateTime startTime, DateTime endTime)
        {
            LogQuery        logQuery        = new LogQuery();
            LogAndCondition logAndCondition = new LogAndCondition();

            if (!string.IsNullOrEmpty(messageId))
            {
                LogCondition fieldStringComparison = TrackingSearch.GetFieldStringComparison(MessageTrackingField.MessageId, CsvFieldCache.NormalizeMessageID(messageId));
                logAndCondition.Conditions.Add(fieldStringComparison);
            }
            if (senderProxyAddresses != null)
            {
                LogOrCondition logOrCondition = new LogOrCondition();
                foreach (ProxyAddress proxyAddress in senderProxyAddresses)
                {
                    LogCondition fieldStringComparison2 = TrackingSearch.GetFieldStringComparison(MessageTrackingField.SenderAddress, proxyAddress.AddressString);
                    logOrCondition.Conditions.Add(fieldStringComparison2);
                }
                logAndCondition.Conditions.Add(logOrCondition);
            }
            logQuery.Filter    = logAndCondition;
            logQuery.Beginning = startTime;
            logQuery.End       = endTime;
            return(new LogSearchCursor(MessageTrackingSchema.MessageTrackingEvent, server, version, logFile, logQuery, null));
        }
Example #2
0
        internal static LogCondition GetRecipientCondition(ProxyAddressCollection[] addresses)
        {
            LogOrCondition logOrCondition = new LogOrCondition();
            int            num            = 0;
            int            num2           = 0;

            foreach (ProxyAddressCollection proxyAddressCollection in addresses)
            {
                foreach (ProxyAddress proxyAddress in proxyAddressCollection)
                {
                    if (proxyAddress.Prefix == ProxyAddressPrefix.Smtp)
                    {
                        logOrCondition.Conditions.Add(TrackingSearch.GetSingleRecipientCondition(proxyAddress.AddressString, string.Concat(new object[]
                        {
                            "r",
                            num,
                            ",",
                            num2
                        })));
                        num2++;
                    }
                }
                num++;
            }
            return(logOrCondition);
        }
Example #3
0
        private List <MessageTrackingLogEntry> ReadLogs(RpcReason rpcReason, string logFilePrefix, ProxyAddressCollection senderProxyAddresses, string messageId, DateTime startTime, DateTime endTime, TrackingEventBudget eventBudget)
        {
            Exception ex  = null;
            int       num = 0;
            List <MessageTrackingLogEntry> list = null;
            bool flag  = !string.IsNullOrEmpty(messageId);
            bool flag2 = senderProxyAddresses != null;

            if (flag && flag2)
            {
                throw new InvalidOperationException("Cannot get logs with both message id and sender address criteria");
            }
            if (rpcReason == RpcReason.None)
            {
                InfoWorkerMessageTrackingPerformanceCounters.GetMessageTrackingReportQueries.Increment();
            }
            else
            {
                InfoWorkerMessageTrackingPerformanceCounters.SearchMessageTrackingReportQueries.Increment();
            }
            try
            {
                this.context.DiagnosticsContext.LogRpcStart(this.server, rpcReason);
                using (LogSearchCursor cursor = TrackingSearch.GetCursor(this.server, this.version, logFilePrefix, messageId, senderProxyAddresses, startTime, endTime))
                {
                    list = this.ReadLogsFromCursor(cursor, eventBudget);
                }
            }
            catch (LogSearchException ex2)
            {
                ex  = ex2;
                num = ex2.ErrorCode;
            }
            catch (RpcException ex3)
            {
                ex  = ex3;
                num = ex3.ErrorCode;
            }
            finally
            {
                this.context.DiagnosticsContext.LogRpcEnd(ex, (list == null) ? 0 : list.Count);
            }
            if (ex != null)
            {
                TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Error reading from log-search RPC server for {0}: {1}, ErrorCode: {2}, Exception: {3}", new object[]
                {
                    flag ? "message id" : "sender",
                    flag ? messageId : senderProxyAddresses[0].ToString(),
                    num,
                    ex
                });
                TrackingTransientException.AddAndRaiseETX(this.context.Errors, ErrorCode.LogSearchConnection, this.server, ex.ToString());
            }
            return(list);
        }
Example #4
0
        internal static LogCondition GetFieldStringComparison(MessageTrackingField field, string[] values)
        {
            LogOrCondition logOrCondition = new LogOrCondition();

            foreach (string value in values)
            {
                LogCondition fieldStringComparison = TrackingSearch.GetFieldStringComparison(field, value);
                logOrCondition.Conditions.Add(fieldStringComparison);
            }
            return(logOrCondition);
        }
Example #5
0
        public List <MessageTrackingLogEntry> GetMessageLog(RpcReason rpcReason, ILogReader reader, TrackingLogPrefix logPrefix, ProxyAddressCollection senderAddresses, MessageTrackingSource eventSource, HashSet <MessageTrackingEvent> eventIdFilterSet, ProxyAddressCollection[] recipientAddresses, string messageId)
        {
            List <MessageTrackingLogEntry> list = new List <MessageTrackingLogEntry>();
            string text = null;
            bool   flag = false;

            if (senderAddresses == null && string.IsNullOrEmpty(messageId))
            {
                throw new ArgumentException("Either senderAddresses or messageId must be specified to use log cache");
            }
            if (!string.IsNullOrEmpty(messageId))
            {
                text = TrackingSearch.RemoveAngleBracketsIfNeeded(messageId);
            }
            List <MessageTrackingLogEntry> messageLog;

            if (!string.IsNullOrEmpty(text))
            {
                messageLog = this.GetMessageLog(rpcReason, reader, logPrefix, text);
                flag       = true;
            }
            else
            {
                messageLog = this.GetMessageLog(rpcReason, reader, logPrefix, senderAddresses);
            }
            foreach (MessageTrackingLogEntry messageTrackingLogEntry in messageLog)
            {
                if (messageTrackingLogEntry.Source == eventSource && (eventIdFilterSet == null || eventIdFilterSet.Contains(messageTrackingLogEntry.EventId)) && (!flag || senderAddresses == null || LogCache.AtLeastOneAddressFoundInProxy(new string[]
                {
                    messageTrackingLogEntry.SenderAddress
                }, senderAddresses)) && (recipientAddresses == null || LogCache.AtLeastOneAddressFoundInProxies(messageTrackingLogEntry.RecipientAddresses, recipientAddresses)))
                {
                    list.Add(messageTrackingLogEntry);
                }
            }
            return(list);
        }
Example #6
0
 internal static LogSearchCursor GetCursorForMessageId(string server, ServerVersion version, string logFile, string messageId, DateTime startTime, DateTime endTime)
 {
     return(TrackingSearch.GetCursor(server, version, logFile, messageId, null, startTime, endTime));
 }
Example #7
0
 internal static LogSearchCursor GetCursorForMessageId(string server, ServerVersion version, string logFile, string messageId)
 {
     return(TrackingSearch.GetCursor(server, version, logFile, messageId, null, CultureInfo.CurrentCulture.Calendar.MinSupportedDateTime, DateTime.UtcNow.AddDays(1.0)));
 }
Example #8
0
 internal static LogSearchCursor GetCursorForMessageId(string server, ServerVersion version, string messageId)
 {
     return(TrackingSearch.GetCursorForMessageId(server, version, "MSGTRK", messageId));
 }