Beispiel #1
0
        private void ProcessNotWritedMessages()
        {
            string processedDirectory = Config.ObservableFolderPath + @"\ProcessedFiles";

            if (Directory.Exists(processedDirectory))
            {
                foreach (string file in Directory.GetFiles(processedDirectory, "*.eml").ToList())
                {
                    try
                    {
                        MessageModel msgModel = MessageParser.GetMessageModelFromFile(file);
                        ProcessedMessages.Add(new MessageObject {
                            Model = msgModel, Path = file
                        });
                    }
                    catch { }
                }
            }
        }
Beispiel #2
0
        public bool ProcessMessage(string emailFile)
        {
            try
            {
                MessageModel  msgModel = MessageParser.GetMessageModelFromFile(emailFile);
                MessageObject message  = new MessageObject {
                    Model = msgModel, Path = emailFile
                };
                lock (processedMessagesLock)
                    ProcessedMessages.Add(message);

                message.Path = SendToSubfolder(emailFile, "ProcessedFiles");

                return(true);
            }
            catch (Exception ex)
            {
                _log.Error("Problem with file: " + emailFile, ex);
                SendToSubfolder(emailFile, "FailedFiles");
            }

            return(false);
        }
Beispiel #3
0
 public void ParseMessageFromFileTest_ThrowFormatException(string emailFileName)
 {
     Assert.Throws <FormatException>(() => MessageParser.GetMessageModelFromFile(emailFileName));
 }
Beispiel #4
0
        public void ParseMessageFromFileTest_NormalFile(string emailFileName)
        {
            MessageModel msg = MessageParser.GetMessageModelFromFile(emailFileName);

            Assert.True(msg.Message_ID != null && msg.Subject != null && msg.From != null && msg.To != null && msg.Date != null);
        }