protected override List<ExportError> ExportConversationAttachments(IConversation conversation, string exportFilename, out IAttachmentExportLocator exportLocator)
        {
            List<ExportError> exportErrors = new List<ExportError>();
            string exportBasePath = Path.GetDirectoryName(exportFilename);
            AttachmentExportLocator attachmentExportLocator = new AttachmentExportLocator(exportBasePath);
            string attachmentDirectoryPath = null;
            bool exportedVideoAttachment = false;
            bool exportedAudioAttachment = false;

            foreach (IConversationMessage message in conversation)
            {
                if (!message.HasAttachments())
                {
                    continue;
                }

                if (attachmentDirectoryPath == null)
                {
                    string attachmentDirectoryName = GenerateAttachmentExportDirectoryName(exportFilename);
                    attachmentDirectoryPath = Path.Combine(exportBasePath, attachmentDirectoryName);
                    attachmentDirectoryPath = FileCreator.CreateNewDirectoryWithRenameAttempts(attachmentDirectoryPath, _exportFileSystem, MaxRenameAttempts);
                }

                foreach (IMessageAttachment attachment in message.Attachments)
                {
                    try
                    {
                        string exportedPath = ExportMessageAttachment(attachment, attachmentDirectoryPath);
                        attachmentExportLocator.AddAttachmentExportLocation(attachment, exportedPath);

                        if (attachment.Type == AttachmentType.Video)
                        {
                            exportedVideoAttachment = true;
                        }
                        else if (attachment.Type == AttachmentType.Audio)
                        {
                            exportedAudioAttachment = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        exportErrors.Add(new ExportError(conversation, ex));
                    }
                }
            }

            if (exportedVideoAttachment)
            {
                string videoIconPath = PlaceVideoIconFile(attachmentDirectoryPath);
                attachmentExportLocator.AddFileExportLocation(VideoIconOutputFilename, videoIconPath);
            }
            if (exportedAudioAttachment)
            {
                string audioIconPath = PlaceAudioIconFile(attachmentDirectoryPath);
                attachmentExportLocator.AddFileExportLocation(AudioIconOutputFilename, audioIconPath);
            }

            exportLocator = attachmentExportLocator;
            return exportErrors;
        }
        private List <ExportError> DoConversationTextExport(IConversation conversation, IDisplayOptionsReadOnly displayOptions, string exportFilename, IAttachmentExportLocator exportLocator)
        {
            List <ExportError> exportErrors = new List <ExportError>();
            string             finalExportFilename;

            try
            {
                using (Stream exportFileStream = FileCreator.CreateNewFileWithRenameAttempts(exportFilename, _exportFileSystem, MaxRenameAttempts, out finalExportFilename))
                {
                    using (StreamWriter exportStreamWriter = new StreamWriter(exportFileStream, Encoding.UTF8))
                    {
                        WriteHeader(exportStreamWriter, conversation);
                        WriteConversationContents(exportStreamWriter, conversation, displayOptions, exportLocator);
                        WriteFooter(exportStreamWriter);
                    }
                }
            }
            catch (Exception ex)
            {
                exportErrors.Add(new ExportError(conversation, ex));
            }

            return(exportErrors);
        }
        private List <ExportError> DoAttachmentExport(IConversation conversation, IDisplayOptionsReadOnly displayOptions, string exportFilename, out IAttachmentExportLocator exportLocator)
        {
            List <ExportError> exportErrors;

            if (displayOptions.LoadMmsAttachments)
            {
                exportErrors = ExportConversationAttachments(conversation, exportFilename, out exportLocator);
            }
            else
            {
                exportErrors  = new List <ExportError>();
                exportLocator = new AttachmentExportLocator(null);
            }

            return(exportErrors);
        }
 protected abstract IConversationRenderer GetRenderer(IConversation conversation, IDisplayOptionsReadOnly displayOptions, IAttachmentExportLocator attachmentExportLocator);
 protected abstract List <ExportError> ExportConversationAttachments(IConversation conversation, string exportFilename, out IAttachmentExportLocator exportLocator);
        protected void WriteConversationContents(StreamWriter writer, IConversation conversation, IDisplayOptionsReadOnly displayOptions, IAttachmentExportLocator attachmentExportLocator)
        {
            IConversationRenderer renderer = GetRenderer(conversation, displayOptions, attachmentExportLocator);

            while (renderer.HasUnprocessedMessages)
            {
                const int RenderBufferSize = 5000;
                string    exportableString = renderer.RenderMessagesAsString(RenderBufferSize);
                writer.Write(exportableString);
            }
        }
 public ConversationRendererHtml(IDisplayOptionsReadOnly displayOptions, IConversation conversation, IAttachmentExportLocator attachmentExportLocator)
     : base(displayOptions, conversation)
 {
     _attachmentExportLocator = attachmentExportLocator;
 }
 protected override IConversationRenderer GetRenderer(IConversation conversation, IDisplayOptionsReadOnly displayOptions, IAttachmentExportLocator attachmentExportLocator)
 {
     return new ConversationRendererHtml(displayOptions, conversation, attachmentExportLocator);
 }
        private List<ExportError> DoConversationTextExport(IConversation conversation, IDisplayOptionsReadOnly displayOptions, string exportFilename, IAttachmentExportLocator exportLocator)
        {
            List<ExportError> exportErrors = new List<ExportError>();
            string finalExportFilename;
            try
            {
                using (Stream exportFileStream = FileCreator.CreateNewFileWithRenameAttempts(exportFilename, _exportFileSystem, MaxRenameAttempts, out finalExportFilename))
                {
                    using (StreamWriter exportStreamWriter = new StreamWriter(exportFileStream, Encoding.UTF8))
                    {
                        WriteHeader(exportStreamWriter, conversation);
                        WriteConversationContents(exportStreamWriter, conversation, displayOptions, exportLocator);
                        WriteFooter(exportStreamWriter);
                    }
                }
            }
            catch (Exception ex)
            {
                exportErrors.Add(new ExportError(conversation, ex));
            }

            return exportErrors;
        }
        private List<ExportError> DoAttachmentExport(IConversation conversation, IDisplayOptionsReadOnly displayOptions, string exportFilename, out IAttachmentExportLocator exportLocator)
        {
            List<ExportError> exportErrors;
            if (displayOptions.LoadMmsAttachments)
            {
                exportErrors = ExportConversationAttachments(conversation, exportFilename, out exportLocator);
            }
            else
            {
                exportErrors = new List<ExportError>();
                exportLocator = new AttachmentExportLocator(null);
            }

            return exportErrors;
        }
        protected void WriteConversationContents(StreamWriter writer, IConversation conversation, IDisplayOptionsReadOnly displayOptions, IAttachmentExportLocator attachmentExportLocator)
        {
            IConversationRenderer renderer = GetRenderer(conversation, displayOptions, attachmentExportLocator);

            while (renderer.HasUnprocessedMessages)
            {
                const int RenderBufferSize = 5000;
                string exportableString = renderer.RenderMessagesAsString(RenderBufferSize);
                writer.Write(exportableString);
            }
        }
 protected abstract IConversationRenderer GetRenderer(IConversation conversation, IDisplayOptionsReadOnly displayOptions, IAttachmentExportLocator attachmentExportLocator);
 protected abstract List<ExportError> ExportConversationAttachments(IConversation conversation, string exportFilename, out IAttachmentExportLocator exportLocator);
 protected override IConversationRenderer GetRenderer(IConversation conversation, IDisplayOptionsReadOnly displayOptions, IAttachmentExportLocator attachmentExportLocator)
 {
     return(new ConversationRendererHtml(displayOptions, conversation, attachmentExportLocator));
 }
 public ConversationRendererHtml(IDisplayOptionsReadOnly displayOptions, IConversation conversation, IAttachmentExportLocator attachmentExportLocator)
     : base(displayOptions, conversation)
 {
     _attachmentExportLocator = attachmentExportLocator;
 }
        protected override List <ExportError> ExportConversationAttachments(IConversation conversation, string exportFilename, out IAttachmentExportLocator exportLocator)
        {
            List <ExportError>      exportErrors            = new List <ExportError>();
            string                  exportBasePath          = Path.GetDirectoryName(exportFilename);
            AttachmentExportLocator attachmentExportLocator = new AttachmentExportLocator(exportBasePath);
            string                  attachmentDirectoryPath = null;
            bool exportedVideoAttachment = false;
            bool exportedAudioAttachment = false;

            foreach (IConversationMessage message in conversation)
            {
                if (!message.HasAttachments())
                {
                    continue;
                }

                if (attachmentDirectoryPath == null)
                {
                    string attachmentDirectoryName = GenerateAttachmentExportDirectoryName(exportFilename);
                    attachmentDirectoryPath = Path.Combine(exportBasePath, attachmentDirectoryName);
                    attachmentDirectoryPath = FileCreator.CreateNewDirectoryWithRenameAttempts(attachmentDirectoryPath, _exportFileSystem, MaxRenameAttempts);
                }

                foreach (IMessageAttachment attachment in message.Attachments)
                {
                    try
                    {
                        string exportedPath = ExportMessageAttachment(attachment, attachmentDirectoryPath);
                        attachmentExportLocator.AddAttachmentExportLocation(attachment, exportedPath);

                        if (attachment.Type == AttachmentType.Video)
                        {
                            exportedVideoAttachment = true;
                        }
                        else if (attachment.Type == AttachmentType.Audio)
                        {
                            exportedAudioAttachment = true;
                        }
                    }
                    catch (Exception ex)
                    {
                        exportErrors.Add(new ExportError(conversation, ex));
                    }
                }
            }

            if (exportedVideoAttachment)
            {
                string videoIconPath = PlaceVideoIconFile(attachmentDirectoryPath);
                attachmentExportLocator.AddFileExportLocation(VideoIconOutputFilename, videoIconPath);
            }
            if (exportedAudioAttachment)
            {
                string audioIconPath = PlaceAudioIconFile(attachmentDirectoryPath);
                attachmentExportLocator.AddFileExportLocation(AudioIconOutputFilename, audioIconPath);
            }

            exportLocator = attachmentExportLocator;
            return(exportErrors);
        }
 protected override List <ExportError> ExportConversationAttachments(IConversation conversation, string attachmentExportDirectory, out IAttachmentExportLocator exportLocator)
 {
     exportLocator = new AttachmentExportLocator(null);
     return(new List <ExportError>());
 }