private void ProcessClassificationsForJournalReport(StoreDriverDeliveryEventArgsImpl argsImpl) { ClassificationSummary classificationSummary = this.GetClassificationSummary(argsImpl); if (classificationSummary != null && classificationSummary.IsValid && classificationSummary.IsClassified) { using (ItemAttachment itemAttachment = this.TryOpenFirstAttachment(argsImpl.ReplayItem) as ItemAttachment) { if (itemAttachment != null) { using (MessageItem itemAsMessage = itemAttachment.GetItemAsMessage(StoreObjectSchema.ContentConversionProperties)) { if (itemAsMessage != null) { ClassificationApplicationAgent.diag.TraceDebug <string>(0L, "Promote banner for recipient {0} on embedded message of journal report", argsImpl.MailRecipient.Email.ToString()); itemAsMessage[ItemSchema.IsClassified] = classificationSummary.IsClassified; itemAsMessage[ItemSchema.Classification] = classificationSummary.DisplayName; itemAsMessage[ItemSchema.ClassificationDescription] = classificationSummary.RecipientDescription; itemAsMessage[ItemSchema.ClassificationGuid] = classificationSummary.ClassificationID.ToString(); itemAsMessage[ItemSchema.ClassificationKeep] = classificationSummary.RetainClassificationEnabled; itemAsMessage.Save(SaveMode.NoConflictResolution); itemAttachment.Save(); } } } } } }
public Signal Unpack(MessageItem mailMessage) { this.itemAttach = new Dictionary <Guid, byte[]>(); this.messageItemAttach = new Dictionary <Guid, MessageItem>(); foreach (AttachmentHandle handle in mailMessage.AttachmentCollection.GetHandles()) { using (Attachment attachment = mailMessage.AttachmentCollection.Open(handle)) { StreamAttachment streamAttachment = attachment as StreamAttachment; if (streamAttachment != null) { byte[] value = Unpacker.ReadBytes(streamAttachment.GetContentStream(PropertyOpenMode.ReadOnly)); this.itemAttach.Add(new Guid(streamAttachment.FileName), value); } else { ItemAttachment itemAttachment = attachment as ItemAttachment; if (itemAttachment != null) { MessageItem itemAsMessage = itemAttachment.GetItemAsMessage(); string contentId = itemAttachment.ContentId; if (contentId != null) { this.messageItemAttach.Add(new Guid(contentId), itemAsMessage); } } } } } return(this.ReadSignal(mailMessage)); }
private MessageItem GetAttachedMessageItem(MessageItem message, IAgentInfoWriter agentInfo) { foreach (AttachmentHandle handle in message.AttachmentCollection.GetHandles()) { using (Attachment attachment = message.AttachmentCollection.Open(handle)) { ItemAttachment itemAttachment = attachment as ItemAttachment; if (itemAttachment != null) { return(itemAttachment.GetItemAsMessage()); } string text = "Warning: Message does not contain the expected attachment."; this.logger.TraceDebug(new string[] { text }); agentInfo.AddAgentInfo("AttachmentCheck", text); } } return(null); }
private static bool IsDecision(MessageItem messageItem, out MessageItem decisionMessageItem, out bool needsDisposing) { decisionMessageItem = messageItem; needsDisposing = false; if (messageItem == null || messageItem.Session == null) { return(false); } if (!string.IsNullOrEmpty(messageItem.VotingInfo.Response)) { return(true); } if (messageItem.AttachmentCollection != null && messageItem.AttachmentCollection.Count == 1) { IList <AttachmentHandle> handles = messageItem.AttachmentCollection.GetHandles(); if (handles != null && handles.Count > 0) { using (ItemAttachment itemAttachment = messageItem.AttachmentCollection.Open(handles[0], AttachmentType.EmbeddedMessage) as ItemAttachment) { if (itemAttachment != null) { decisionMessageItem = itemAttachment.GetItemAsMessage(); needsDisposing = true; bool flag = decisionMessageItem != null && decisionMessageItem.Session != null && !string.IsNullOrEmpty(decisionMessageItem.VotingInfo.Response); if (decisionMessageItem != null && !flag) { decisionMessageItem.Dispose(); needsDisposing = false; } return(flag); } } return(false); } } return(false); }