protected override void OnSetActive(EventArgs e) { base.OnSetActive(e); ExtensibleMessageInfo extensibleMessageInfo = null; if (base.Context != null && base.Context.DataHandler.DataSource != null) { extensibleMessageInfo = (base.Context.DataHandler.DataSource as ExtensibleMessageInfo); } if (extensibleMessageInfo == null) { this.FormatMissingMessageError(); return; } this.FormatMessagePreview(extensibleMessageInfo); }
private void FormatMessagePreview(ExtensibleMessageInfo message) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.IdColumn, message.Identity)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.SubjectColumn, message.Subject)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.InternetMessageIdColumn, message.InternetMessageId)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.FromAddressColumn, message.FromAddress)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.StatusColumn, message.Status)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.SizeColumn, Math.Max(1UL, message.Size.ToKB()))); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.MessageSourceNameColumn, message.MessageSourceName)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.SourceIPColumn, message.SourceIP)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.SCLColumn, message.SCL)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.DateReceivedColumn, message.DateReceived.ToString())); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.ExpirationTimeColumn, message.ExpirationTime)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.LastErrorColumn, message.LastError)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.QueueIdColumn, message.Queue)); stringBuilder.AppendLine(this.FormatPropertyParagraph(Strings.Recipients, message.Recipients)); this.exchangeTextBox1.Text = stringBuilder.ToString(); }
public bool GetRecipientStatus(long internalId, string messageId, string recipientAddress, out RecipientStatus?status, out string lastError, out DateTime?lastRetry, out DateTime?nextRetry, out string queueName, out bool isUnreachable) { status = null; lastError = null; lastRetry = null; nextRetry = null; queueName = null; isUnreachable = true; ExtensibleMessageInfo[] messageInfo = this.GetMessageInfo(internalId); if (messageInfo == null || messageInfo.Length == 0) { TraceWrapper.SearchLibraryTracer.TraceDebug <long>(this.GetHashCode(), "No results found for message internal ID: {0}", internalId); return(false); } ExtensibleMessageInfo extensibleMessageInfo = null; for (int i = 0; i < messageInfo.Length; i++) { string internetMessageId = messageInfo[i].InternetMessageId; if (string.IsNullOrEmpty(internetMessageId) || !internetMessageId.Equals(messageId) || messageInfo[i].Recipients == null) { TraceWrapper.SearchLibraryTracer.TraceError <string, string>(this.GetHashCode(), "Message-IDs did not match, Task: {0}, Queues: {1}", messageId, internetMessageId); } else { foreach (RecipientInfo recipientInfo in messageInfo[i].Recipients) { if (recipientInfo.Address.Equals(recipientAddress)) { lastError = recipientInfo.LastError; status = new RecipientStatus?(recipientInfo.Status); extensibleMessageInfo = messageInfo[i]; break; } } } } if (extensibleMessageInfo == null) { TraceWrapper.SearchLibraryTracer.TraceError(this.GetHashCode(), "Message did not match", new object[0]); return(false); } if (string.IsNullOrEmpty(lastError)) { lastError = extensibleMessageInfo.LastError; } QueueIdentity queue = extensibleMessageInfo.Queue; ExtensibleQueueInfo[] queueInfo = this.GetQueueInfo(queue); if (queueInfo == null || queueInfo.Length != 1) { TraceWrapper.SearchLibraryTracer.TraceError <QueueIdentity>(this.GetHashCode(), "No queue found with ID: {0}", queue); return(false); } queueName = queueInfo[0].Identity.ToString(); isUnreachable = (queueInfo[0].DeliveryType == DeliveryType.Unreachable); SmtpResponse smtpResponse; if (string.IsNullOrEmpty(lastError) || (SmtpResponse.TryParse(lastError, out smtpResponse) && smtpResponse.SmtpResponseType == SmtpResponseType.Success)) { lastError = queueInfo[0].LastError; } if (status == null && (queueInfo[0].Status == QueueStatus.Retry || queueInfo[0].Status == QueueStatus.Suspended)) { status = new RecipientStatus?(RecipientStatus.Retry); } lastRetry = queueInfo[0].LastRetryTime; nextRetry = queueInfo[0].NextRetryTime; return(true); }