private static bool ProxyAddressArrayValidator(object value)
 {
     string[] array = (string[])value;
     foreach (string value2 in array)
     {
         if (!MessageTrackingLogRow.ProxyAddressValidator(value2))
         {
             return(false);
         }
     }
     return(true);
 }
 private static bool ValidateField(MessageTrackingLogRow logEntry, int fieldIdx, object value, TrackingErrorCollection errors)
 {
     MessageTrackingLogRow.ValidateMethod validator = MessageTrackingLogRow.GetValidator(logEntry, fieldIdx);
     if (validator != null && !validator(value))
     {
         string text = string.Format("The message-tracking data on server {0} had invalid data in column {1} for this message. Event \"{2}\" will be ignored", logEntry.serverFqdn, fieldIdx, logEntry.EventId.ToString());
         errors.Add(ErrorCode.UnexpectedErrorPermanent, logEntry.ServerHostName, text, string.Empty);
         TraceWrapper.SearchLibraryTracer.TraceError(logEntry.GetHashCode(), text, new object[0]);
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
        public static bool TryCreateFromCursor(LogSearchCursor cursor, string server, TrackingErrorCollection errors, out MessageTrackingLogEntry entry)
        {
            entry = null;
            MessageTrackingLogRow messageTrackingLogRow;

            if (MessageTrackingLogRow.TryRead(server, cursor, MessageTrackingLogEntry.allRows, errors, out messageTrackingLogRow))
            {
                entry = new MessageTrackingLogEntry(messageTrackingLogRow);
                return(true);
            }
            return(false);
        }
        public static bool TryRead(string server, LogSearchCursor cursor, BitArray fieldsToGet, TrackingErrorCollection errors, out MessageTrackingLogRow logEntry)
        {
            logEntry = null;
            MessageTrackingLogRow messageTrackingLogRow = new MessageTrackingLogRow();

            messageTrackingLogRow.serverFqdn = server;
            for (int i = 0; i < fieldsToGet.Length; i++)
            {
                if (fieldsToGet[i])
                {
                    object    obj = null;
                    Exception ex  = null;
                    try
                    {
                        obj = cursor.GetField(i);
                    }
                    catch (LogSearchException ex2)
                    {
                        ex = ex2;
                        int errorCode = ex2.ErrorCode;
                    }
                    catch (RpcException ex3)
                    {
                        ex = ex3;
                        int errorCode2 = ex3.ErrorCode;
                    }
                    if (ex != null)
                    {
                        TrackingTransientException.AddAndRaiseETX(errors, ErrorCode.LogSearchConnection, server, ex.ToString());
                    }
                    if (obj != null && obj.GetType() != MessageTrackingSchema.MessageTrackingEvent.Fields[i].Type)
                    {
                        throw new InvalidOperationException(string.Format("Schema for column {0} in message-tracking is of sync with tasks", i));
                    }
                    if (!MessageTrackingLogRow.ValidateField(messageTrackingLogRow, i, obj, errors))
                    {
                        return(false);
                    }
                    messageTrackingLogRow.columns[i]      = cursor.GetField(i);
                    messageTrackingLogRow.validColumns[i] = true;
                }
            }
            if (fieldsToGet[8] && (messageTrackingLogRow.EventId == MessageTrackingEvent.EXPAND || messageTrackingLogRow.EventId == MessageTrackingEvent.RESOLVE))
            {
                MessageTrackingLogRow.SmtpAddressValidatorWithNull(messageTrackingLogRow.RelatedRecipientAddress);
            }
            logEntry = messageTrackingLogRow;
            return(true);
        }
 private static MessageTrackingLogRow.ValidateMethod GetValidator(MessageTrackingLogRow logEntry, int fieldIdx)
 {
     if (!logEntry.IsValidColumn(MessageTrackingField.EventId))
     {
         return(null);
     }
     if (logEntry.EventId == MessageTrackingEvent.THROTTLE && fieldIdx == 12)
     {
         return(new MessageTrackingLogRow.ValidateMethod(MessageTrackingLogRow.ProxyAddressArrayValidator));
     }
     if (logEntry.EventId == MessageTrackingEvent.DEFER && logEntry.Source == MessageTrackingSource.SMTP && fieldIdx == 19)
     {
         return(null);
     }
     return(MessageTrackingLogRow.validateMethods[fieldIdx]);
 }
 private static bool SmtpAddressArrayValidator(object value)
 {
     if (value == null)
     {
         return(true);
     }
     string[] array = (string[])value;
     if (array.Length == 0 || (array.Length == 1 && string.IsNullOrEmpty(array[0])))
     {
         return(true);
     }
     foreach (string value2 in array)
     {
         if (!MessageTrackingLogRow.SmtpAddressValidator(value2))
         {
             return(false);
         }
     }
     return(true);
 }
 private static bool SmtpAddressValidatorWithNull(object value)
 {
     return(string.IsNullOrEmpty((string)value) || MessageTrackingLogRow.SmtpAddressValidator(value));
 }
Esempio n. 8
0
        private MessageTrackingLogEntry(MessageTrackingLogRow rowData)
        {
            this.rowData = rowData;
            string text = Names <MessageTrackingEvent> .Map[(int)this.rowData.EventId];

            if (this.rowData.EventId == MessageTrackingEvent.TRANSFER || (this.rowData.EventId == MessageTrackingEvent.RESUBMIT && this.rowData.Source == MessageTrackingSource.REDUNDANCY))
            {
                long num = 0L;
                if (this.rowData.References == null || this.rowData.References.Length != 1 || !long.TryParse(this.rowData.References[0], out num))
                {
                    TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "RelatedInternalId could not be parsed for TRANSFER event from server {0}", new object[]
                    {
                        this.Server
                    });
                }
                this.relatedMailItemId = num;
                return;
            }
            if (this.rowData.EventId == MessageTrackingEvent.RECEIVE)
            {
                if (this.rowData.Source == MessageTrackingSource.SMTP && string.IsNullOrEmpty(this.rowData.ClientHostName) && string.IsNullOrEmpty(this.rowData.ClientIP))
                {
                    TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No ClientHostName or ClientIP for SMTP RECEIVE from server {0}", new object[]
                    {
                        this.Server
                    });
                    return;
                }
            }
            else
            {
                if (this.rowData.EventId == MessageTrackingEvent.SEND && this.rowData.Source == MessageTrackingSource.SMTP)
                {
                    if (string.IsNullOrEmpty(this.rowData.ServerHostName) && string.IsNullOrEmpty(this.rowData.ServerIP))
                    {
                        TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No ServerHostName or ServerIP for SMTP SEND from server {0}", new object[]
                        {
                            this.Server
                        });
                    }
                    this.ProcessOutboundProxyTargetServer();
                    return;
                }
                if (this.rowData.EventId == MessageTrackingEvent.DELIVER && this.rowData.Source == MessageTrackingSource.STOREDRIVER && this.rowData.RecipientStatuses != null)
                {
                    if (this.rowData.RecipientAddresses == null || this.rowData.RecipientAddresses.Length != this.rowData.RecipientStatuses.Length)
                    {
                        TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "Mismatched RecipientAddress and RecipientStatus counts for STOREDRIVER DELIVER from server {0}", new object[]
                        {
                            this.Server
                        });
                    }
                    for (int i = 0; i < this.rowData.RecipientAddresses.Length; i++)
                    {
                        if (!string.IsNullOrEmpty(this.rowData.RecipientStatuses[i]))
                        {
                            if (this.recipientFolders == null)
                            {
                                this.recipientFolders = new Dictionary <string, string>(this.rowData.RecipientAddresses.Length);
                            }
                            this.recipientFolders.Add(this.rowData.RecipientAddresses[i], this.rowData.RecipientStatuses[i]);
                        }
                    }
                    return;
                }
                if (this.rowData.EventId == MessageTrackingEvent.INITMESSAGECREATED)
                {
                    if (this.rowData.References == null || this.rowData.References.Length < 1 || string.IsNullOrEmpty(this.rowData.References[0]) || !SmtpAddress.IsValidSmtpAddress(this.rowData.Context))
                    {
                        TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No RelatedMessageId for INITMESSAGECREATED from server {0}", new object[]
                        {
                            this.Server
                        });
                    }
                    this.arbitrationMailboxAddress = SmtpAddress.Parse(this.rowData.Context);
                    return;
                }
                if (this.rowData.EventId == MessageTrackingEvent.MODERATORAPPROVE || this.rowData.EventId == MessageTrackingEvent.MODERATORREJECT || this.rowData.EventId == MessageTrackingEvent.MODERATIONEXPIRE)
                {
                    if (this.rowData.References == null || this.rowData.References.Length < 1 || string.IsNullOrEmpty(this.rowData.References[0]))
                    {
                        TrackingFatalException.RaiseED(ErrorCode.UnexpectedErrorPermanent, "No RelatedMessageId for {0}", new object[]
                        {
                            text,
                            this.Server
                        });
                        return;
                    }
                }
                else if (this.rowData.EventId == MessageTrackingEvent.HAREDIRECT && this.rowData.Source == MessageTrackingSource.SMTP)
                {
                    this.FixupHARedirectEvent();
                }
            }
        }