public abstract void WriteProcessedData(string prefix, string id, string topic, string agent, MailItem mailItem);
Exemple #2
0
        public override void WriteOriginalData(int agentId, string id, string topic, string address, MailItem mailItem)
        {
            if (this.state.IsOriginalWritten || (this.state.OriginalWriterAgentId != null && agentId != this.state.OriginalWriterAgentId))
            {
                return;
            }
            FileMode fileMode = FileMode.Append;

            if (this.state.OriginalWriterAgentId == null)
            {
                this.state.OriginalWriterAgentId = new int?(agentId);
                fileMode = FileMode.Create;
            }
            string pipelineTracingPath = mailItem.PipelineTracingPath;

            if (string.IsNullOrEmpty(pipelineTracingPath))
            {
                return;
            }
            string snapshotFolder           = this.GetSnapshotFolder(pipelineTracingPath);
            string originalSnapshotFileName = this.GetOriginalSnapshotFileName(snapshotFolder);

            try
            {
                this.EnsureSnapshotFolderCreated(snapshotFolder);
                using (FileStream fileStream = new FileStream(originalSnapshotFileName, fileMode, FileAccess.Write, FileShare.None))
                {
                    if (topic == "OnRcptCommand")
                    {
                        if (fileMode == FileMode.Create)
                        {
                            MessageSnapshotWriter.WriteBeginningHeadersToFile(fileStream, id, topic, null);
                            MessageSnapshotWriter.WriteSenderHeaderToFile(fileStream, mailItem.FromAddress.ToString());
                        }
                        MessageSnapshotWriter.WriteReceiverHeaderToFile(fileStream, address);
                    }
                    else if (topic == "OnEndOfHeaders")
                    {
                        MessageSnapshotWriter.WriteEndHeadersToFile(fileStream);
                        this.WriteMessageHeadersToFile(fileStream, mailItem);
                    }
                    else if (topic == "OnEndOfData")
                    {
                        this.AppendBodyToFile(fileStream, mailItem);
                        this.state.IsOriginalWritten = true;
                    }
                    else if (topic == "OnSubmittedMessage")
                    {
                        this.WriteMessageToFile(fileStream, id, topic, null, mailItem);
                        this.state.IsOriginalWritten = true;
                    }
                }
            }
            catch (IOException)
            {
            }
            catch (UnauthorizedAccessException)
            {
            }
            catch (SecurityException)
            {
            }
        }
 public abstract void WriteOriginalData(int agentId, string id, string topic, string address, MailItem mailItem);
Exemple #4
0
 private void AppendBodyToFile(FileStream file, MailItem mailItem)
 {
     file.WriteByte(13);
     file.WriteByte(10);
     mailItem.MimeDocument.RootPart.WriteTo(file, null, MessageSnapshotWriter.RootHeaderFilter);
 }
Exemple #5
0
 private void WriteMessageHeadersToFile(FileStream file, MailItem mailItem)
 {
     mailItem.MimeDocument.RootPart.Headers.WriteTo(file);
 }
Exemple #6
0
        private void WriteMessageToFile(FileStream file, string id, string topic, string agent, MailItem mailItem)
        {
            if (mailItem.HasBeenDeferred || mailItem.HasBeenDeleted)
            {
                MessageSnapshotWriter.WriteInjectedHeadersToFile(file, id, topic, agent, null, null, mailItem.HasBeenDeferred ? "Deferred" : "Deleted");
                return;
            }
            string[] array = new string[mailItem.Recipients.Count];
            int      num   = 0;

            foreach (EnvelopeRecipient envelopeRecipient in mailItem.Recipients)
            {
                array[num++] = envelopeRecipient.Address.ToString();
            }
            MessageSnapshotWriter.WriteInjectedHeadersToFile(file, id, topic, agent, mailItem.FromAddress.ToString(), array);
            mailItem.MimeDocument.RootPart.WriteTo(file);
        }
Exemple #7
0
 public override void WriteProcessedData(string prefix, string id, string topic, string agent, MailItem mailItem)
 {
     try
     {
         if (!mailItem.HasBeenDeferred)
         {
             string pipelineTracingPath = mailItem.PipelineTracingPath;
             if (!string.IsNullOrEmpty(pipelineTracingPath))
             {
                 string snapshotFolder       = this.GetSnapshotFolder(pipelineTracingPath);
                 string nextSnapshotFilePath = this.GetNextSnapshotFilePath(snapshotFolder, topic, prefix);
                 this.EnsureSnapshotFolderCreated(snapshotFolder);
                 using (FileStream fileStream = new FileStream(nextSnapshotFilePath, FileMode.Create, FileAccess.Write, FileShare.None))
                 {
                     this.WriteMessageToFile(fileStream, id, topic, agent, mailItem);
                 }
             }
         }
     }
     catch (IOException)
     {
     }
     catch (UnauthorizedAccessException)
     {
     }
     catch (SecurityException)
     {
     }
 }
Exemple #8
0
 public override void WritePreProcessedData(int agentId, string prefix, string id, string topic, MailItem mailItem)
 {
     if (topic != this.state.LastPreProcessedSnapshotTopic)
     {
         this.state.LastPreProcessedSnapshotTopic = topic;
         this.WriteProcessedData(prefix, id, topic, string.Empty, mailItem);
     }
 }