private static IOrderedEnumerable <MessageModel> GetMessageListModel()
        {
            var mailPaths = MailHelper.ListMailFiles(Properties.Settings.Default.MailDir);
            var mails     = mailPaths.Select(path => new MailModel(path));

            var smsPaths = SmsHelper.ListSmsFiles(Properties.Settings.Default.MailDir);
            var sms      = smsPaths.Select(path => new SmsModel(path));

            var messages = mails.Cast <MessageModel>().Concat(sms)
                           .OrderByDescending(m => m.SentOn);

            return(messages);
        }
        private void FillCache()
        {
            var mailPaths = MailHelper.ListMailFiles(Properties.Settings.Default.MailDir);

            foreach (var mailPath in mailPaths.Reverse()) // Fill cache from reverse to not run from the same direction as HomeController.GetMailListModel
            {
                MailHelper.ReadMessage(mailPath);
            }

            var smsPaths = SmsHelper.ListSmsFiles(Properties.Settings.Default.MailDir);

            foreach (var smsPath in smsPaths.Reverse())
            {
                SmsHelper.ReadMessage(smsPath);
            }
        }
Exemple #3
0
        public static IEnumerable <MessageTimeModel> GetMessageListModel(string subPath)
        {
            if (!(string.IsNullOrEmpty(subPath) || DirectoryHelper.ListDirectories().Contains(subPath)))
            {
                throw new ArgumentException("Invalid path", nameof(subPath));
            }
            var mailDir   = Path.Combine(Properties.Settings.Default.MailDir, subPath ?? "");
            var mailPaths = MailHelper.ListMailFiles(mailDir);
            var mails     = mailPaths.Select(path => new MessageTimeModel {
                Model = new Lazy <MessageModel>(() => new MailModel(path.FullName)), MessageTime = path.CreationTimeUtc
            });

            var smsPaths = SmsHelper.ListSmsFiles(mailDir);
            var sms      = smsPaths.Select(path => new MessageTimeModel {
                Model = new Lazy <MessageModel>(() => new SmsModel(path.FullName)), MessageTime = path.CreationTimeUtc
            });

            var messages = mails.Concat(sms)
                           .OrderByDescending(m => m.MessageTime);

            return(messages);
        }